clang API Documentation
#include "clang/Frontend/ASTUnit.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/Sema.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ASTWriter.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <atomic>
#include <cstdio>
#include <cstdlib>
Go to the source code of this file.
Classes | |
struct | clang::ASTUnit::ASTWriterData |
Namespaces | |
namespace | clang |
Typedefs | |
typedef llvm::DenseMap< const ASTUnit *, std::unique_ptr < OnDiskData > > | OnDiskDataMap |
typedef ContinuousRangeMap < unsigned, int, 2 > | SLocRemap |
Functions | |
static llvm::sys::SmartMutex < false > & | getOnDiskMutex () |
static void | cleanupOnDiskMapAtExit () |
static OnDiskDataMap & | getOnDiskDataMap () |
static OnDiskData & | getOnDiskData (const ASTUnit *AU) |
static void | erasePreambleFile (const ASTUnit *AU) |
static void | removeOnDiskEntry (const ASTUnit *AU) |
static void | setPreambleFile (const ASTUnit *AU, StringRef preambleFile) |
static const std::string & | getPreambleFile (const ASTUnit *AU) |
static unsigned | getDeclShowContexts (const NamedDecl *ND, const LangOptions &LangOpts, bool &IsNestedNameSpecifier) |
Determine the set of code-completion contexts in which this declaration should be shown. | |
static bool | isNonDriverDiag (const StoredDiagnostic &StoredDiag) |
static void | checkAndRemoveNonDriverDiags (SmallVectorImpl< StoredDiagnostic > &StoredDiags) |
static void | checkAndSanitizeDiags (SmallVectorImpl< StoredDiagnostic > &StoredDiagnostics, SourceManager &SM) |
static std::string | GetPreamblePCHPath () |
Simple function to retrieve a path for a preamble precompiled header. | |
bool | clang::operator== (const ASTUnit::PreambleFileHash &LHS, const ASTUnit::PreambleFileHash &RHS) |
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 ASTUnit::StandaloneDiagnostic | makeStandaloneDiagnostic (const LangOptions &LangOpts, const StoredDiagnostic &InDiag) |
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, bool hasErrors, raw_ostream &OS) |
static bool | PCHLocator (serialization::ModuleFile &M, void *UserData) |
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. |
typedef llvm::DenseMap<const ASTUnit *, std::unique_ptr<OnDiskData> > OnDiskDataMap |
Definition at line 109 of file ASTUnit.cpp.
typedef ContinuousRangeMap<unsigned, int, 2> SLocRemap |
Definition at line 2498 of file ASTUnit.cpp.
static void CalculateHiddenNames | ( | const CodeCompletionContext & | Context, |
CodeCompletionResult * | Results, | ||
unsigned | NumResults, | ||
ASTContext & | Ctx, | ||
llvm::StringSet< llvm::BumpPtrAllocator > & | HiddenNames | ||
) | [static] |
Helper function that computes which global names are hidden by the local code-completion results.
Definition at line 2115 of file ASTUnit.cpp.
References clang::CodeCompletionContext::CCC_ArrowMemberAccess, clang::CodeCompletionContext::CCC_ClassOrStructTag, clang::CodeCompletionContext::CCC_ClassStructUnion, clang::CodeCompletionContext::CCC_DotMemberAccess, clang::CodeCompletionContext::CCC_EnumTag, clang::CodeCompletionContext::CCC_Expression, clang::CodeCompletionContext::CCC_MacroName, clang::CodeCompletionContext::CCC_MacroNameUse, clang::CodeCompletionContext::CCC_Name, clang::CodeCompletionContext::CCC_Namespace, clang::CodeCompletionContext::CCC_NaturalLanguage, clang::CodeCompletionContext::CCC_ObjCCategoryName, 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_PotentiallyQualifiedName, clang::CodeCompletionContext::CCC_PreprocessorDirective, clang::CodeCompletionContext::CCC_PreprocessorExpression, clang::CodeCompletionContext::CCC_Recovery, clang::CodeCompletionContext::CCC_SelectorName, clang::CodeCompletionContext::CCC_Statement, clang::CodeCompletionContext::CCC_TopLevel, clang::CodeCompletionContext::CCC_Type, clang::CodeCompletionContext::CCC_TypeQualifiers, clang::CodeCompletionContext::CCC_UnionTag, clang::CodeCompletionResult::Declaration, clang::DeclarationName::getAsIdentifierInfo(), clang::DeclarationName::getAsString(), clang::NamedDecl::getDeclName(), clang::Decl::getIdentifierNamespace(), clang::CodeCompletionContext::getKind(), clang::ASTContext::getLangOpts(), clang::NamedDecl::getUnderlyingDecl(), clang::Decl::IDNS_Member, clang::Decl::IDNS_Namespace, clang::Decl::IDNS_NonMemberOperator, clang::Decl::IDNS_Ordinary, clang::Decl::IDNS_Tag, and clang::Decl::IDNS_Type.
static void checkAndRemoveNonDriverDiags | ( | SmallVectorImpl< StoredDiagnostic > & | StoredDiags | ) | [static] |
Definition at line 996 of file ASTUnit.cpp.
References isNonDriverDiag().
static void checkAndSanitizeDiags | ( | SmallVectorImpl< StoredDiagnostic > & | StoredDiagnostics, |
SourceManager & | SM | ||
) | [static] |
Definition at line 1004 of file ASTUnit.cpp.
static void cleanupOnDiskMapAtExit | ( | ) | [static] |
Definition at line 120 of file ASTUnit.cpp.
References getOnDiskDataMap(), and getOnDiskMutex().
Referenced by getOnDiskDataMap().
static void erasePreambleFile | ( | const ASTUnit * | AU | ) | [static] |
Definition at line 142 of file ASTUnit.cpp.
References getOnDiskData().
static unsigned 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 265 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_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, Contexts, clang::NamedDecl::getUnderlyingDecl(), and Record.
static OnDiskData& getOnDiskData | ( | const ASTUnit * | AU | ) | [static] |
Definition at line 131 of file ASTUnit.cpp.
References getOnDiskDataMap(), and getOnDiskMutex().
Referenced by clang::ASTUnit::addTemporaryFile(), erasePreambleFile(), getPreambleFile(), and setPreambleFile().
static OnDiskDataMap& getOnDiskDataMap | ( | ) | [static] |
Definition at line 110 of file ASTUnit.cpp.
References cleanupOnDiskMapAtExit().
Referenced by cleanupOnDiskMapAtExit(), getOnDiskData(), and removeOnDiskEntry().
static llvm::sys::SmartMutex<false>& getOnDiskMutex | ( | ) | [static] |
Definition at line 101 of file ASTUnit.cpp.
Referenced by cleanupOnDiskMapAtExit(), getOnDiskData(), and removeOnDiskEntry().
static const std::string& getPreambleFile | ( | const ASTUnit * | AU | ) | [static] |
Definition at line 162 of file ASTUnit.cpp.
References getOnDiskData().
Referenced by clang::ASTUnit::CodeComplete(), and clang::ASTUnit::Reparse().
static std::string GetPreamblePCHPath | ( | ) | [static] |
Simple function to retrieve a path for a preamble precompiled header.
Definition at line 1162 of file ASTUnit.cpp.
static bool isNonDriverDiag | ( | const StoredDiagnostic & | StoredDiag | ) | [static] |
Definition at line 991 of file ASTUnit.cpp.
References clang::StoredDiagnostic::getLocation(), and clang::SourceLocation::isValid().
Referenced by checkAndRemoveNonDriverDiags().
static ASTUnit::StandaloneDiagnostic makeStandaloneDiagnostic | ( | const LangOptions & | LangOpts, |
const StoredDiagnostic & | InDiag | ||
) | [static] |
Definition at line 1288 of file ASTUnit.cpp.
References clang::ASTUnit::StandaloneDiagnostic::Filename, clang::StoredDiagnostic::fixit_begin(), clang::StoredDiagnostic::fixit_end(), clang::ASTUnit::StandaloneDiagnostic::FixIts, clang::SourceManager::getFileLoc(), clang::SourceManager::getFilename(), clang::SourceManager::getFileOffset(), clang::StoredDiagnostic::getID(), clang::StoredDiagnostic::getLevel(), clang::StoredDiagnostic::getLocation(), clang::FullSourceLoc::getManager(), clang::StoredDiagnostic::getMessage(), clang::ASTUnit::StandaloneDiagnostic::ID, clang::SourceLocation::isInvalid(), clang::ASTUnit::StandaloneDiagnostic::Level, clang::ASTUnit::StandaloneDiagnostic::LocOffset, makeStandaloneFixIt(), makeStandaloneRange(), clang::ASTUnit::StandaloneDiagnostic::Message, clang::StoredDiagnostic::range_begin(), clang::StoredDiagnostic::range_end(), clang::ASTUnit::StandaloneDiagnostic::Ranges, and SM.
static ASTUnit::StandaloneFixIt makeStandaloneFixIt | ( | const SourceManager & | SM, |
const LangOptions & | LangOpts, | ||
const FixItHint & | InFix | ||
) | [static] |
Definition at line 1275 of file ASTUnit.cpp.
References clang::FixItHint::BeforePreviousInsertions, clang::ASTUnit::StandaloneFixIt::BeforePreviousInsertions, clang::FixItHint::CodeToInsert, clang::ASTUnit::StandaloneFixIt::CodeToInsert, clang::FixItHint::InsertFromRange, clang::ASTUnit::StandaloneFixIt::InsertFromRange, makeStandaloneRange(), clang::FixItHint::RemoveRange, and clang::ASTUnit::StandaloneFixIt::RemoveRange.
Referenced by makeStandaloneDiagnostic().
static std::pair<unsigned, unsigned> makeStandaloneRange | ( | CharSourceRange | Range, |
const SourceManager & | SM, | ||
const LangOptions & | LangOpts | ||
) | [static] |
Definition at line 1267 of file ASTUnit.cpp.
References clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), clang::SourceManager::getFileOffset(), and clang::Lexer::makeFileCharRange().
Referenced by makeStandaloneDiagnostic(), and makeStandaloneFixIt().
static bool PCHLocator | ( | serialization::ModuleFile & | M, |
void * | UserData | ||
) | [static] |
Definition at line 2785 of file ASTUnit.cpp.
References clang::serialization::ModuleFile::Kind, clang::serialization::MK_ExplicitModule, clang::serialization::MK_ImplicitModule, clang::serialization::MK_MainFile, clang::serialization::MK_PCH, and clang::serialization::MK_Preamble.
Referenced by clang::ASTUnit::getPCHFile().
static void removeOnDiskEntry | ( | const ASTUnit * | AU | ) | [static] |
Definition at line 146 of file ASTUnit.cpp.
References getOnDiskDataMap(), and getOnDiskMutex().
Referenced by clang::ASTUnit::~ASTUnit().
static bool serializeUnit | ( | ASTWriter & | Writer, |
SmallVectorImpl< char > & | Buffer, | ||
Sema & | S, | ||
bool | hasErrors, | ||
raw_ostream & | OS | ||
) | [static] |
Definition at line 2471 of file ASTUnit.cpp.
References clang::ASTWriter::WriteAST().
Referenced by clang::ASTUnit::serialize().
static void setPreambleFile | ( | const ASTUnit * | AU, |
StringRef | preambleFile | ||
) | [static] |
Definition at line 158 of file ASTUnit.cpp.
References getOnDiskData().
std::atomic<unsigned> ActiveASTUnitObjects [static] |
Tracks the number of ASTUnit objects that are currently active.
Used for debugging purposes only.
Definition at line 213 of file ASTUnit.cpp.
Referenced by clang::ASTUnit::~ASTUnit().
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 208 of file ASTUnit.cpp.