clang
3.7.0
|
#include "clang/Serialization/ASTReader.h"
#include "ASTCommon.h"
#include "ASTReaderInternals.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/Version.h"
#include "clang/Basic/VersionTuple.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/Sema.h"
#include "clang/Serialization/ASTDeserializationListener.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/ModuleManager.h"
#include "clang/Serialization/SerializationDiagnostic.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstdio>
#include <iterator>
#include <system_error>
#include "clang/Basic/LangOptions.def"
#include "clang/Basic/Sanitizers.def"
#include "clang/Basic/DiagnosticOptions.def"
#include "clang/AST/TypeLocNodes.def"
#include "clang/Basic/OpenCLExtensions.def"
Go to the source code of this file.
Classes | |
class | clang::TypeLocReader |
class | clang::ASTIdentifierIterator |
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files. More... | |
class | clang::serialization::ReadMethodPoolVisitor |
Namespaces | |
clang | |
clang::serialization | |
Macros | |
#define | LANGOPT(Name, Bits, Default, Description) |
#define | VALUE_LANGOPT(Name, Bits, Default, Description) |
#define | ENUM_LANGOPT(Name, Type, Bits, Default, Description) |
#define | COMPATIBLE_LANGOPT(Name, Bits, Default, Description) |
#define | COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) |
#define | BENIGN_LANGOPT(Name, Bits, Default, Description) |
#define | BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) |
#define | CHECK_TARGET_OPT(Field, Name) |
#define | LANGOPT(Name, Bits, Default, Description) LangOpts.Name = Record[Idx++]; |
#define | ENUM_LANGOPT(Name, Type, Bits, Default, Description) LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); |
#define | SANITIZER(NAME, ID) LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); |
#define | DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++]; |
#define | ENUM_DIAGOPT(Name, Type, Bits, Default) DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); |
#define | ABSTRACT_TYPELOC(CLASS, PARENT) |
#define | TYPELOC(CLASS, PARENT) void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc); |
#define | OPENCLEXT(nm) SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++]; |
Functions | |
static bool | checkLanguageOptions (const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true) |
Compare the given set of language options against an existing set of language options. More... | |
static bool | checkTargetOptions (const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true) |
Compare the given set of target options against an existing set of target options. More... | |
static bool | checkDiagnosticGroupMappings (DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain) |
static bool | isExtHandlingFromDiagsError (DiagnosticsEngine &Diags) |
static bool | checkDiagnosticMappings (DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool IsSystem, bool Complain) |
static void | collectMacroDefinitions (const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl< StringRef > *MacroNames=nullptr) |
Collect the macro definitions provided by the given preprocessor options. More... | |
static bool | checkPreprocessorOptions (const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts) |
Check the preprocessor options deserialized from the control block against the preprocessor options in an existing preprocessor. More... | |
static bool | checkHeaderSearchOptions (const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts) |
static bool | isInterestingIdentifier (IdentifierInfo &II) |
Whether the given identifier is "interesting". More... | |
static std::string | resolveFileRelativeToOriginalDir (const std::string &Filename, const std::string &OriginalDir, const std::string &CurrDir) |
If a header file is not found at the path that we expect it to be and the PCH file was moved from its original location, try to resolve the file by assuming that header+PCH were moved together and the header is in the same place relative to the PCH. More... | |
static void | moveMethodToBackOfGlobalList (Sema &S, ObjCMethodDecl *Method) |
Move the given method to the back of the global list of methods. More... | |
static void | updateModuleTimestamp (ModuleFile &MF) |
static ASTFileSignature | readASTFileSignature (llvm::BitstreamReader &StreamFile) |
Reads and return the signature record from StreamFile's control block, or else returns 0. More... | |
static bool | startsWithASTFileMagic (BitstreamCursor &Stream) |
Whether Stream starts with the AST/PCH file magic number 'CPCH'. More... | |
static bool | SkipCursorToBlock (BitstreamCursor &Cursor, unsigned BlockID) |
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the given block ID, returning false on success and true on failure. More... | |
template<typename TemplateSpecializationDecl > | |
static void | completeRedeclChainForTemplateSpecialization (Decl *D) |
static Decl * | getPredefinedDecl (ASTContext &Context, PredefinedDeclIDs ID) |
static ModuleFile * | getDefinitiveModuleFileFor (const DeclContext *DC, ASTReader &Reader) |
Retrieve the "definitive" module file for the definition of the given declaration context, if there is one. More... | |
static void | PassObjCImplDeclToConsumer (ObjCImplDecl *ImplD, ASTConsumer *Consumer) |
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation, and codegen depends on this. We simulate this by deserializing and passing to consumer the methods of the implementation before passing the deserialized implementation decl. More... | |
template<typename Key , typename ModuleFile , unsigned InitialCapacity> | |
static void | dumpModuleIDMap (StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map) |
static void | addMethodsToPool (Sema &S, ArrayRef< ObjCMethodDecl * > Methods, ObjCMethodList &List) |
Add the given set of methods to the method list. More... | |
#define ABSTRACT_TYPELOC | ( | CLASS, | |
PARENT | |||
) |
Definition at line 5452 of file ASTReader.cpp.
#define BENIGN_ENUM_LANGOPT | ( | Name, | |
Type, | |||
Bits, | |||
Default, | |||
Description | |||
) |
#define BENIGN_LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) |
#define CHECK_TARGET_OPT | ( | Field, | |
Name | |||
) |
Referenced by checkTargetOptions().
#define COMPATIBLE_ENUM_LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) |
#define COMPATIBLE_LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) |
#define DIAGOPT | ( | Name, | |
Bits, | |||
Default | |||
) | DiagOpts->Name = Record[Idx++]; |
#define ENUM_DIAGOPT | ( | Name, | |
Type, | |||
Bits, | |||
Default | |||
) | DiagOpts->set##Name(static_cast<Type>(Record[Idx++])); |
#define ENUM_LANGOPT | ( | Name, | |
Type, | |||
Bits, | |||
Default, | |||
Description | |||
) |
#define ENUM_LANGOPT | ( | Name, | |
Type, | |||
Bits, | |||
Default, | |||
Description | |||
) | LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); |
#define LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) |
#define LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) | LangOpts.Name = Record[Idx++]; |
#define OPENCLEXT | ( | nm | ) | SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++]; |
#define SANITIZER | ( | NAME, | |
ID | |||
) | LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]); |
Definition at line 5453 of file ASTReader.cpp.
#define VALUE_LANGOPT | ( | Name, | |
Bits, | |||
Default, | |||
Description | |||
) |
|
static |
Add the given set of methods to the method list.
Definition at line 6989 of file ASTReader.cpp.
References clang::Sema::addMethodToGlobalList().
Referenced by clang::ASTReader::ReadMethodPool().
|
static |
Definition at line 328 of file ASTReader.cpp.
References clang::DiagnosticsEngine::Error, clang::DiagnosticsEngine::getDiagnosticIDs(), clang::DiagnosticsEngine::getDiagnosticLevel(), and clang::DiagnosticsEngine::Report().
Referenced by checkDiagnosticMappings().
|
static |
Definition at line 365 of file ASTReader.cpp.
References checkDiagnosticGroupMappings(), clang::DiagnosticsEngine::getEnableAllWarnings(), clang::DiagnosticsEngine::getSuppressSystemWarnings(), clang::DiagnosticsEngine::getWarningsAsErrors(), isExtHandlingFromDiagsError(), and clang::DiagnosticsEngine::Report().
Referenced by clang::PCHValidator::ReadDiagnosticOptions().
|
static |
Check the header search options deserialized from the control block against the header search options in an existing preprocessor.
Diags | If non-null, produce diagnostics for any mismatches incurred. |
Definition at line 608 of file ASTReader.cpp.
References clang::DiagnosticsEngine::Report().
Referenced by clang::PCHValidator::ReadHeaderSearchOptions().
|
static |
Compare the given set of language options against an existing set of language options.
Diags | If non-NULL, diagnostics will be emitted via this engine. |
AllowCompatibleDifferences | If true, differences between compatible language options will be permitted. |
Definition at line 172 of file ASTReader.cpp.
References clang::CommentOptions::BlockCommandNames, clang::LangOptions::CommentOpts, clang::LangOptions::ModuleFeatures, clang::LangOptions::ObjCRuntime, and clang::DiagnosticsEngine::Report().
Referenced by clang::PCHValidator::ReadLanguageOptions().
|
static |
Check the preprocessor options deserialized from the control block against the preprocessor options in an existing preprocessor.
Diags | If non-null, produce diagnostics for any mismatches incurred. |
Definition at line 482 of file ASTReader.cpp.
References collectMacroDefinitions(), clang::PreprocessorOptions::DetailedRecord, clang::PreprocessorOptions::ImplicitPCHInclude, clang::PreprocessorOptions::Includes, clang::PreprocessorOptions::MacroIncludes, clang::DiagnosticsEngine::Report(), and clang::PreprocessorOptions::UsePredefines.
Referenced by clang::PCHValidator::ReadPreprocessorOptions().
|
static |
Compare the given set of target options against an existing set of target options.
Diags | If non-NULL, diagnostics will be emitted via this engine. |
Definition at line 242 of file ASTReader.cpp.
References CHECK_TARGET_OPT, clang::TargetOptions::FeaturesAsWritten, and clang::DiagnosticsEngine::Report().
Referenced by clang::PCHValidator::ReadTargetOptions().
|
static |
Collect the macro definitions provided by the given preprocessor options.
Definition at line 443 of file ASTReader.cpp.
References End, and clang::PreprocessorOptions::Macros.
Referenced by checkPreprocessorOptions().
|
static |
Definition at line 5867 of file ASTReader.cpp.
|
static |
Definition at line 6721 of file ASTReader.cpp.
Referenced by clang::ASTReader::dump().
|
static |
Retrieve the "definitive" module file for the definition of the given declaration context, if there is one.
The "definitive" module file is the only place where we need to look to find information about the declarations within the given declaration context. For example, C++ and Objective-C classes, C structs/unions, and Objective-C protocols, categories, and extensions are all defined in a single place in the source code, so they have definitive module files associated with them. C++ namespaces, on the other hand, can have definitions in multiple different module files.
Note: this needs to be kept in sync with ASTWriter::AddedVisibleDecl's NDEBUG checking.
Definition at line 6314 of file ASTReader.cpp.
References clang::serialization::getDefinitiveDeclContext(), and clang::ASTReader::getOwningModuleFile().
|
static |
Definition at line 6032 of file ASTReader.cpp.
References clang::ASTContext::getBuiltinVaListDecl(), clang::ASTContext::getExternCContextDecl(), clang::ASTContext::getInt128Decl(), clang::ASTContext::getObjCClassDecl(), clang::ASTContext::getObjCIdDecl(), clang::ASTContext::getObjCInstanceTypeDecl(), clang::ASTContext::getObjCProtocolDecl(), clang::ASTContext::getObjCSelDecl(), clang::ASTContext::getTranslationUnitDecl(), clang::ASTContext::getUInt128Decl(), clang::serialization::PREDEF_DECL_BUILTIN_VA_LIST_ID, clang::serialization::PREDEF_DECL_EXTERN_C_CONTEXT_ID, clang::serialization::PREDEF_DECL_INT_128_ID, clang::serialization::PREDEF_DECL_NULL_ID, clang::serialization::PREDEF_DECL_OBJC_CLASS_ID, clang::serialization::PREDEF_DECL_OBJC_ID_ID, clang::serialization::PREDEF_DECL_OBJC_INSTANCETYPE_ID, clang::serialization::PREDEF_DECL_OBJC_PROTOCOL_ID, clang::serialization::PREDEF_DECL_OBJC_SEL_ID, clang::serialization::PREDEF_DECL_TRANSLATION_UNIT_ID, and clang::serialization::PREDEF_DECL_UNSIGNED_INT_128_ID.
Referenced by clang::ASTReader::GetExistingDecl().
|
static |
Definition at line 358 of file ASTReader.cpp.
References clang::diag::Error, clang::DiagnosticsEngine::getExtensionHandlingBehavior(), clang::DiagnosticsEngine::getWarningsAsErrors(), and clang::diag::Warning.
Referenced by checkDiagnosticMappings().
|
static |
Whether the given identifier is "interesting".
Definition at line 738 of file ASTReader.cpp.
References clang::IdentifierInfo::getFETokenInfo(), clang::IdentifierInfo::getObjCOrBuiltinID(), clang::IdentifierInfo::hadMacroDefinition(), clang::IdentifierInfo::hasRevertedTokenIDToIdentifier(), clang::IdentifierInfo::isExtensionToken(), and clang::IdentifierInfo::isPoisoned().
Referenced by clang::serialization::reader::ASTIdentifierLookupTrait::ReadData().
|
static |
Move the given method to the back of the global list of methods.
Definition at line 3220 of file ASTReader.cpp.
References clang::ObjCMethodList::getNext(), clang::ObjCMethodDecl::getSelector(), clang::ObjCMethodDecl::isInstanceMethod(), and clang::Sema::MethodPool.
Referenced by clang::ASTReader::makeNamesVisible().
|
static |
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation, and codegen depends on this. We simulate this by deserializing and passing to consumer the methods of the implementation before passing the deserialized implementation decl.
Definition at line 6568 of file ASTReader.cpp.
References clang::ASTConsumer::HandleInterestingDecl(), and clang::ObjCContainerDecl::methods().
|
static |
Reads and return the signature record from StreamFile's
control block, or else returns 0.
Definition at line 3846 of file ASTReader.cpp.
References clang::serialization::CONTROL_BLOCK_ID, clang::serialization::SIGNATURE, SkipCursorToBlock(), and startsWithASTFileMagic().
|
static |
If a header file is not found at the path that we expect it to be and the PCH file was moved from its original location, try to resolve the file by assuming that header+PCH were moved together and the header is in the same place relative to the PCH.
Definition at line 1131 of file ASTReader.cpp.
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the given block ID, returning false on success and true on failure.
Definition at line 3817 of file ASTReader.cpp.
References clang::serialized_diags::Error.
Referenced by clang::ASTReader::getOriginalSourceFile(), clang::ASTReader::readASTFileControlBlock(), and readASTFileSignature().
|
static |
Whether Stream
starts with the AST/PCH file magic number 'CPCH'.
Definition at line 3532 of file ASTReader.cpp.
Referenced by clang::ASTReader::getOriginalSourceFile(), clang::ASTReader::readASTFileControlBlock(), and readASTFileSignature().
|
static |
Definition at line 3335 of file ASTReader.cpp.
References clang::serialization::ModuleFile::getTimestampFilename().
Referenced by clang::ASTReader::ReadAST().