c2c/Clang/Preprocessor.cpp
/// EnterMainSourceFile - Enter the specified FileID as the main source file,
/// which implicitly adds the builtin defines etc.
Enter the specified FileID as the main source file,
which implicitly adds the builtin defines etc.
Enter the specified FileID as the main source file which implicitly adds the builtin defines etc .
void Preprocessor::EnterMainSourceFile() {
  assert(NumEnteredSourceFiles == 0 && "Cannot reenter the main file!");
  FileID MainFileID = SourceMgr.getMainFileID();
  if (!SourceMgr.isLoadedFileID(MainFileID)) {
    EnterSourceFile(MainFileID, nullptr, SourceLocation());
    if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
      HeaderInfo.IncrementIncludeCount(FE);
  }
  std::unique_ptr<llvm::MemoryBuffer> SB =
    llvm::MemoryBuffer::getMemBufferCopy(Predefines, "<built-in>");
  assert(SB && "Cannot create predefined source buffer");
  FileID FID = SourceMgr.createFileID(std::move(SB));
  assert(FID.isValid() && "Could not create FileID for predefines?");
  setPredefinesFileID(FID);
  EnterSourceFile(FID, nullptr, SourceLocation());
}
void Preprocessor :: EnterMainSourceFile ( ) { assert ( NumEnteredSourceFiles == 0 && " " ) ; FileID MainFileID = SourceMgr . getMainFileID ( ) ; if ( ! SourceMgr . isLoadedFileID ( MainFileID ) ) { EnterSourceFile ( MainFileID , nullptr , SourceLocation ( ) ) ; if ( const FileEntry * FE = SourceMgr . getFileEntryForID ( MainFileID ) ) HeaderInfo . IncrementIncludeCount ( FE ) ; } std :: unique_ptr < llvm :: MemoryBuffer > SB = llvm :: MemoryBuffer :: getMemBufferCopy ( Predefines , " " ) ; assert ( SB && " " ) ; FileID FID = SourceMgr . createFileID ( std :: move ( SB ) ) ; assert ( FID . isValid ( ) && " " ) ; setPredefinesFileID ( FID ) ; EnterSourceFile ( FID , nullptr , SourceLocation ( ) ) ; }
EnterMainSourceFile - Enter the specified FileID as the main source file,
which implicitly adds the builtin defines etc.
EnterMainSourceFile - Enter the specified FileID as the main source file which implicitly adds the builtin defines etc .
// We do not allow the preprocessor to reenter the main file.  Doing so will // cause FileID's to accumulate information from both runs (e.g. #line // information) and predefined macros aren't guaranteed to be set properly. // If MainFileID is loaded it means we loaded an AST file, no need to enter // a main file. // Enter the main file source buffer. // Tell the header info that the main file was entered.  If the file is later // #imported, it won't be re-entered. // Preprocess Predefines to populate the initial preprocessor state. // Start parsing the predefines.