#include #include #include #include #include #include #include #include #include #include #include #include ">

clang: lib/Frontend/ASTUnit.cpp File Reference (original) (raw)

#include "[clang/Frontend/ASTUnit.h](ASTUnit%5F8h%5Fsource.html)"
#include "[clang/AST/ASTConsumer.h](ASTConsumer%5F8h%5Fsource.html)"
#include "[clang/AST/ASTContext.h](ASTContext%5F8h%5Fsource.html)"
#include "[clang/AST/CommentCommandTraits.h](CommentCommandTraits%5F8h%5Fsource.html)"
#include "[clang/AST/Decl.h](Decl%5F8h%5Fsource.html)"
#include "[clang/AST/DeclBase.h](DeclBase%5F8h%5Fsource.html)"
#include "[clang/AST/DeclCXX.h](DeclCXX%5F8h%5Fsource.html)"
#include "[clang/AST/DeclGroup.h](DeclGroup%5F8h%5Fsource.html)"
#include "[clang/AST/DeclObjC.h](DeclObjC%5F8h%5Fsource.html)"
#include "[clang/AST/DeclTemplate.h](DeclTemplate%5F8h%5Fsource.html)"
#include "[clang/AST/DeclarationName.h](DeclarationName%5F8h%5Fsource.html)"
#include "[clang/AST/ExternalASTSource.h](ExternalASTSource%5F8h%5Fsource.html)"
#include "[clang/AST/PrettyPrinter.h](PrettyPrinter%5F8h%5Fsource.html)"
#include "[clang/AST/Type.h](Type%5F8h%5Fsource.html)"
#include "[clang/AST/TypeOrdering.h](TypeOrdering%5F8h%5Fsource.html)"
#include "[clang/Basic/Diagnostic.h](Basic%5F2Diagnostic%5F8h%5Fsource.html)"
#include "[clang/Basic/FileManager.h](FileManager%5F8h%5Fsource.html)"
#include "[clang/Basic/IdentifierTable.h](IdentifierTable%5F8h%5Fsource.html)"
#include "[clang/Basic/LLVM.h](LLVM%5F8h%5Fsource.html)"
#include "[clang/Basic/LangOptions.h](LangOptions%5F8h%5Fsource.html)"
#include "[clang/Basic/LangStandard.h](LangStandard%5F8h%5Fsource.html)"
#include "[clang/Basic/Module.h](Module%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceLocation.h](SourceLocation%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceManager.h](SourceManager%5F8h%5Fsource.html)"
#include "[clang/Basic/TargetInfo.h](include%5F2clang%5F2Basic%5F2TargetInfo%5F8h%5Fsource.html)"
#include "[clang/Basic/TargetOptions.h](TargetOptions%5F8h%5Fsource.html)"
#include "[clang/Frontend/CompilerInstance.h](CompilerInstance%5F8h%5Fsource.html)"
#include "[clang/Frontend/CompilerInvocation.h](CompilerInvocation%5F8h%5Fsource.html)"
#include "[clang/Frontend/FrontendAction.h](FrontendAction%5F8h%5Fsource.html)"
#include "[clang/Frontend/FrontendActions.h](Frontend%5F2FrontendActions%5F8h%5Fsource.html)"
#include "[clang/Frontend/FrontendDiagnostic.h](FrontendDiagnostic%5F8h%5Fsource.html)"
#include "[clang/Frontend/FrontendOptions.h](FrontendOptions%5F8h%5Fsource.html)"
#include "[clang/Frontend/MultiplexConsumer.h](MultiplexConsumer%5F8h%5Fsource.html)"
#include "[clang/Frontend/PrecompiledPreamble.h](PrecompiledPreamble%5F8h%5Fsource.html)"
#include "[clang/Frontend/Utils.h](Frontend%5F2Utils%5F8h%5Fsource.html)"
#include "[clang/Lex/HeaderSearch.h](HeaderSearch%5F8h%5Fsource.html)"
#include "[clang/Lex/HeaderSearchOptions.h](HeaderSearchOptions%5F8h%5Fsource.html)"
#include "[clang/Lex/Lexer.h](Lexer%5F8h%5Fsource.html)"
#include "[clang/Lex/PPCallbacks.h](PPCallbacks%5F8h%5Fsource.html)"
#include "[clang/Lex/PreprocessingRecord.h](PreprocessingRecord%5F8h%5Fsource.html)"
#include "[clang/Lex/Preprocessor.h](Preprocessor%5F8h%5Fsource.html)"
#include "[clang/Lex/PreprocessorOptions.h](PreprocessorOptions%5F8h%5Fsource.html)"
#include "[clang/Lex/Token.h](Token%5F8h%5Fsource.html)"
#include "[clang/Sema/CodeCompleteConsumer.h](CodeCompleteConsumer%5F8h%5Fsource.html)"
#include "[clang/Sema/CodeCompleteOptions.h](CodeCompleteOptions%5F8h%5Fsource.html)"
#include "[clang/Sema/Sema.h](Sema%5F8h%5Fsource.html)"
#include "[clang/Sema/SemaCodeCompletion.h](SemaCodeCompletion%5F8h%5Fsource.html)"
#include "[clang/Serialization/ASTBitCodes.h](ASTBitCodes%5F8h%5Fsource.html)"
#include "[clang/Serialization/ASTReader.h](ASTReader%5F8h%5Fsource.html)"
#include "[clang/Serialization/ASTWriter.h](ASTWriter%5F8h%5Fsource.html)"
#include "[clang/Serialization/ContinuousRangeMap.h](ContinuousRangeMap%5F8h%5Fsource.html)"
#include "[clang/Serialization/InMemoryModuleCache.h](InMemoryModuleCache%5F8h%5Fsource.html)"
#include "[clang/Serialization/ModuleFile.h](ModuleFile%5F8h%5Fsource.html)"
#include "[clang/Serialization/PCHContainerOperations.h](Serialization%5F2PCHContainerOperations%5F8h%5Fsource.html)"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Bitstream/BitstreamWriter.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/DJB.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <atomic>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions
template
static std::unique_ptr< T > valueOrNull (llvm::ErrorOr< std::unique_ptr< T > > Val)
template
static bool moveOnNoError (llvm::ErrorOr< T > Val, T &Output)
static std::unique_ptr< llvm::MemoryBuffer > getBufferForFileHandlingRemapping (const CompilerInvocation &Invocation, llvm::vfs::FileSystem *VFS, StringRef FilePath, bool isVolatile)
Get a source buffer for MainFilePath, handling all file-to-file and file-to-buffer remappings inside Invocation.
static uint64_t getDeclShowContexts (const NamedDecl *ND, const LangOptions &LangOpts, bool &IsNestedNameSpecifier)
Determine the set of code-completion contexts in which this declaration should be shown.
static ASTUnit::StandaloneDiagnostic makeStandaloneDiagnostic (const LangOptions &LangOpts, const StoredDiagnostic &InDiag)
static bool isInMainFile (const clang::Diagnostic &D)
static void AddDefinedMacroToHash (const Token &MacroNameTok, unsigned &Hash)
Add the given macro to the hash of all top-level entities.
static void AddTopLevelDeclarationToHash (Decl *D, unsigned &Hash)
Add the given declaration to the hash of all top-level entities.
static bool isNonDriverDiag (const StoredDiagnostic &StoredDiag)
static void checkAndRemoveNonDriverDiags (SmallVectorImpl< StoredDiagnostic > &StoredDiags)
static void checkAndSanitizeDiags (SmallVectorImpl< StoredDiagnostic > &StoredDiagnostics, SourceManager &SM)
static std::pair< unsigned, unsigned > makeStandaloneRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
static ASTUnit::StandaloneFixIt makeStandaloneFixIt (const SourceManager &SM, const LangOptions &LangOpts, const FixItHint &InFix)
static void CalculateHiddenNames (const CodeCompletionContext &Context, CodeCompletionResult *Results, unsigned NumResults, ASTContext &Ctx, llvm::StringSet< llvm::BumpPtrAllocator > &HiddenNames)
Helper function that computes which global names are hidden by the local code-completion results.
static bool serializeUnit (ASTWriter &Writer, SmallVectorImpl< char > &Buffer, Sema &S, raw_ostream &OS)
Variables
const unsigned DefaultPreambleRebuildInterval = 5
After failing to build a precompiled preamble (due to errors in the source that occurs in the preamble), the number of reparses during which we'll skip even trying to precompile the preamble.
static std::atomic< unsigned > ActiveASTUnitObjects
Tracks the number of ASTUnit objects that are currently active.

AddDefinedMacroToHash()

static void AddDefinedMacroToHash ( const Token & MacroNameTok, unsigned & Hash ) static

AddTopLevelDeclarationToHash()

static void AddTopLevelDeclarationToHash ( Decl * D, unsigned & Hash ) static

CalculateHiddenNames()

Helper function that computes which global names are hidden by the local code-completion results.

Definition at line 2010 of file ASTUnit.cpp.

References clang::CodeCompletionContext::CCC_ArrowMemberAccess, clang::CodeCompletionContext::CCC_Attribute, clang::CodeCompletionContext::CCC_ClassOrStructTag, clang::CodeCompletionContext::CCC_ClassStructUnion, clang::CodeCompletionContext::CCC_DotMemberAccess, clang::CodeCompletionContext::CCC_EnumTag, clang::CodeCompletionContext::CCC_Expression, clang::CodeCompletionContext::CCC_IncludedFile, clang::CodeCompletionContext::CCC_MacroName, clang::CodeCompletionContext::CCC_MacroNameUse, clang::CodeCompletionContext::CCC_Namespace, clang::CodeCompletionContext::CCC_NaturalLanguage, clang::CodeCompletionContext::CCC_NewName, clang::CodeCompletionContext::CCC_ObjCCategoryName, clang::CodeCompletionContext::CCC_ObjCClassForwardDecl, clang::CodeCompletionContext::CCC_ObjCClassMessage, clang::CodeCompletionContext::CCC_ObjCImplementation, clang::CodeCompletionContext::CCC_ObjCInstanceMessage, clang::CodeCompletionContext::CCC_ObjCInterface, clang::CodeCompletionContext::CCC_ObjCInterfaceName, clang::CodeCompletionContext::CCC_ObjCIvarList, clang::CodeCompletionContext::CCC_ObjCMessageReceiver, clang::CodeCompletionContext::CCC_ObjCPropertyAccess, clang::CodeCompletionContext::CCC_ObjCProtocolName, clang::CodeCompletionContext::CCC_Other, clang::CodeCompletionContext::CCC_OtherWithMacros, clang::CodeCompletionContext::CCC_ParenthesizedExpression, clang::CodeCompletionContext::CCC_PreprocessorDirective, clang::CodeCompletionContext::CCC_PreprocessorExpression, clang::CodeCompletionContext::CCC_Recovery, clang::CodeCompletionContext::CCC_SelectorName, clang::CodeCompletionContext::CCC_Statement, clang::CodeCompletionContext::CCC_Symbol, clang::CodeCompletionContext::CCC_SymbolOrNewName, clang::CodeCompletionContext::CCC_TopLevel, clang::CodeCompletionContext::CCC_TopLevelOrExpression, clang::CodeCompletionContext::CCC_Type, clang::CodeCompletionContext::CCC_TypeQualifiers, clang::CodeCompletionContext::CCC_UnionTag, clang::ASTContext::getLangOpts(), Identifier, clang::Decl::IDNS_Member, clang::Decl::IDNS_Namespace, clang::Decl::IDNS_NonMemberOperator, clang::Decl::IDNS_Ordinary, clang::Decl::IDNS_Tag, clang::Decl::IDNS_Type, and clang::Result.

checkAndRemoveNonDriverDiags()

checkAndSanitizeDiags()

getBufferForFileHandlingRemapping()

static std::unique_ptr< llvm::MemoryBuffer > getBufferForFileHandlingRemapping ( const CompilerInvocation & Invocation, llvm::vfs::FileSystem * VFS, StringRef FilePath, bool isVolatile ) static

getDeclShowContexts()

static uint64_t getDeclShowContexts ( const NamedDecl * ND, const LangOptions & LangOpts, bool & IsNestedNameSpecifier ) static

Determine the set of code-completion contexts in which this declaration should be shown.

Definition at line 286 of file ASTUnit.cpp.

References clang::CodeCompletionContext::CCC_ClassOrStructTag, clang::CodeCompletionContext::CCC_ClassStructUnion, clang::CodeCompletionContext::CCC_EnumTag, clang::CodeCompletionContext::CCC_Expression, clang::CodeCompletionContext::CCC_Namespace, clang::CodeCompletionContext::CCC_ObjCCategoryName, clang::CodeCompletionContext::CCC_ObjCClassForwardDecl, clang::CodeCompletionContext::CCC_ObjCInterfaceName, clang::CodeCompletionContext::CCC_ObjCIvarList, clang::CodeCompletionContext::CCC_ObjCMessageReceiver, clang::CodeCompletionContext::CCC_ObjCProtocolName, clang::CodeCompletionContext::CCC_ParenthesizedExpression, clang::CodeCompletionContext::CCC_Statement, clang::CodeCompletionContext::CCC_TopLevel, clang::CodeCompletionContext::CCC_Type, clang::CodeCompletionContext::CCC_UnionTag, and clang::NamedDecl::getUnderlyingDecl().

isInMainFile()

isNonDriverDiag()

makeStandaloneDiagnostic()

Definition at line 1299 of file ASTUnit.cpp.

References clang::ASTUnit::StandaloneDiagnostic::Filename, clang::ASTUnit::StandaloneDiagnostic::FixIts, clang::StoredDiagnostic::getFixIts(), clang::StoredDiagnostic::getID(), clang::StoredDiagnostic::getLevel(), clang::StoredDiagnostic::getLocation(), clang::FullSourceLoc::getManager(), clang::StoredDiagnostic::getMessage(), clang::StoredDiagnostic::getRanges(), clang::ASTUnit::StandaloneDiagnostic::ID, clang::SourceLocation::isInvalid(), clang::ASTUnit::StandaloneDiagnostic::Level, clang::ASTUnit::StandaloneDiagnostic::LocOffset, makeStandaloneFixIt(), makeStandaloneRange(), clang::ASTUnit::StandaloneDiagnostic::Message, Range, clang::ASTUnit::StandaloneDiagnostic::Ranges, and SM.

makeStandaloneFixIt()

makeStandaloneRange()

moveOnNoError()

template

static bool moveOnNoError ( llvm::ErrorOr< T > Val, T & Output ) static

serializeUnit()

valueOrNull()

template

static std::unique_ptr< T > valueOrNull ( llvm::ErrorOr< std::unique_ptr< T > > Val) static

ActiveASTUnitObjects

std::atomic<unsigned> ActiveASTUnitObjects static

DefaultPreambleRebuildInterval

const unsigned DefaultPreambleRebuildInterval = 5

After failing to build a precompiled preamble (due to errors in the source that occurs in the preamble), the number of reparses during which we'll skip even trying to precompile the preamble.

Definition at line 234 of file ASTUnit.cpp.