clang 22.0.0git
FrontendAction.cpp File Reference
#include "clang/Frontend/FrontendAction.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclGroup.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/LangStandard.h"
#include "clang/Basic/Sarif.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Stack.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Frontend/LayoutOverrideSource.h"
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Frontend/SARIFDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Sema/HLSLExternalSemaSource.h"
#include "clang/Sema/MultiplexExternalSemaSource.h"
#include "clang/Serialization/ASTDeserializationListener.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
#include <system_error>

Go to the source code of this file.

Functions

static SourceLocation ReadOriginalFileName (CompilerInstance &CI, std::string &InputFile, bool IsModuleMap=false)
 For preprocessed files, if the first line is the linemarker and specifies the original source file name, use that name as the input file name. Returns the location of the first token after the line marker directive.
static SmallVectorImpl< char > & operator+= (SmallVectorImpl< char > &Includes, StringRef RHS)
static void addHeaderInclude (StringRef HeaderName, SmallVectorImpl< char > &Includes, const LangOptions &LangOpts, bool IsExternC)
static std::error_code collectModuleHeaderIncludes (const LangOptions &LangOpts, FileManager &FileMgr, DiagnosticsEngine &Diag, ModuleMap &ModMap, clang::Module *Module, SmallVectorImpl< char > &Includes)
 Collect the set of header includes needed to construct the given module and update the TopHeaders file set of the module.
static bool loadModuleMapForModuleBuild (CompilerInstance &CI, bool IsSystem, bool IsPreprocessed, std::string &PresumedModuleMapFile, unsigned &Offset)
static ModuleprepareToBuildModule (CompilerInstance &CI, StringRef ModuleMapFilename)
static std::unique_ptr< llvm::MemoryBuffer > getInputBufferForModule (CompilerInstance &CI, Module *M)
 Compute the input buffer that should be used to build the specified module.

Function Documentation

◆ addHeaderInclude()

void addHeaderInclude ( StringRef HeaderName,
SmallVectorImpl< char > & Includes,
const LangOptions & LangOpts,
bool IsExternC )
static

Definition at line 550 of file FrontendAction.cpp.

Referenced by collectModuleHeaderIncludes(), and getInputBufferForModule().

◆ collectModuleHeaderIncludes()

std::error_code collectModuleHeaderIncludes ( const LangOptions & LangOpts,
FileManager & FileMgr,
DiagnosticsEngine & Diag,
ModuleMap & ModMap,
clang::Module * Module,
SmallVectorImpl< char > & Includes )
static

Collect the set of header includes needed to construct the given module and update the TopHeaders file set of the module.

Parameters
ModuleThe module we're collecting includes from.
IncludesWill be augmented with the set of #includes or #imports needed to load all of the named headers.

Definition at line 575 of file FrontendAction.cpp.

References addHeaderInclude(), clang::Module::addTopHeader(), collectModuleHeaderIncludes(), Diag(), clang::Module::getHeaders(), clang::Module::getUmbrellaDirAsWritten(), clang::Module::getUmbrellaHeaderAsWritten(), clang::Module::HK_Normal, clang::Module::HK_Private, clang::Module::isAvailable(), clang::Module::IsExternC, clang::ModuleMap::isHeaderUnavailableInModule(), clang::Module::MissingHeaders, clang::Module::Parent, clang::ModuleMap::resolveHeaderDirectives(), and clang::Module::submodules().

Referenced by collectModuleHeaderIncludes(), and getInputBufferForModule().

◆ getInputBufferForModule()

◆ loadModuleMapForModuleBuild()

◆ operator+=()

SmallVectorImpl< char > & operator+= ( SmallVectorImpl< char > & Includes,
StringRef RHS )
static

Definition at line 545 of file FrontendAction.cpp.

◆ prepareToBuildModule()

◆ ReadOriginalFileName()

SourceLocation ReadOriginalFileName ( CompilerInstance & CI,
std::string & InputFile,
bool IsModuleMap = false )
static

For preprocessed files, if the first line is the linemarker and specifies the original source file name, use that name as the input file name. Returns the location of the first token after the line marker directive.

Parameters
CIThe compiler instance.
InputFilePopulated with the filename from the line marker.
IsModuleMapIf true, add a line note corresponding to this line directive. (We need to do this because the directive will not be visited by the preprocessor.)

Definition at line 490 of file FrontendAction.cpp.

References clang::SourceManager::AddLineNote(), clang::SrcMgr::C_User_ModuleMap, clang::CompilerInstance::getLangOpts(), clang::SourceManager::getMainFileID(), clang::CompilerInstance::getPreprocessor(), clang::CompilerInstance::getSourceManager(), clang::Lexer::getSpelling(), and clang::T.

Referenced by clang::FrontendAction::BeginSourceFile(), and loadModuleMapForModuleBuild().