24 #include "llvm/Support/CrashRecoveryContext.h" 28 using namespace clang;
35 class ResetStackCleanup
36 :
public llvm::CrashRecoveryContextCleanupBase<ResetStackCleanup,
39 ResetStackCleanup(llvm::CrashRecoveryContext *Context,
const void *Top)
40 :
llvm::CrashRecoveryContextCleanupBase<ResetStackCleanup, const void>(
42 void recoverResources()
override {
43 llvm::RestorePrettyStackState(resource);
48 class PrettyStackTraceParserEntry :
public llvm::PrettyStackTraceEntry {
51 PrettyStackTraceParserEntry(
const Parser &p) : P(p) {}
52 void print(raw_ostream &OS)
const override;
57 void PrettyStackTraceParserEntry::print(raw_ostream &OS)
const {
60 OS <<
"<eof> parser at end of file\n";
65 OS <<
"<unknown> parser at unknown location\n";
72 OS <<
": at annotation token\n";
81 OS <<
": unknown current parser token\n";
84 OS <<
": current parser token '" << StringRef(Spelling, Length) <<
"'\n";
102 bool SkipFunctionBodies) {
104 std::unique_ptr<Sema> S(
105 new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer));
108 llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
110 ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
121 bool OldCollectStats = PrintStats;
126 std::unique_ptr<Parser> ParseOP(
130 llvm::CrashRecoveryContextCleanupRegistrar<const void, ResetStackCleanup>
131 CleanupPrettyStack(llvm::SavePrettyStackState());
132 PrettyStackTraceParserEntry CrashInfo(P);
135 llvm::CrashRecoveryContextCleanupRegistrar<Parser>
136 CleanupParser(ParseOP.get());
163 llvm::errs() <<
"\nSTATISTICS:\n";
Defines the clang::ASTContext interface.
SmallVectorImpl< Decl * > & WeakTopLevelDecls()
WeakTopLevelDeclDecls - access to #pragma weak-generated Decls.
void Initialize()
Initialize - Warm up the parser.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
Decl - This represents one declaration (or definition), e.g.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
virtual void PrintStats()
PrintStats - If desired, print any statistics.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void print(raw_ostream &OS, const SourceManager &SM) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Token - This structure provides full information about a lexed token.
void PrintStats() const
Print out statistics about the semantic analysis.
Sema - This implements semantic analysis and AST building for C.
Sema & getActions() const
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc...
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
virtual void HandleTranslationUnit(ASTContext &Ctx)
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
Preprocessor & getPreprocessor() const
SourceManager & getSourceManager() const
Abstract interface for external sources of AST nodes.
ASTContext & getASTContext() const
void ParseAST(Preprocessor &pp, ASTConsumer *C, ASTContext &Ctx, bool PrintStats=false, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr, bool SkipFunctionBodies=false)
Parse the entire file specified, notifying the ASTConsumer as the file is parsed. ...
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
bool ParseTopLevelDecl(DeclGroupPtrTy &Result)
ParseTopLevelDecl - Parse one top-level declaration.
ASTConsumer & getASTConsumer() const
Abstract interface for a consumer of code-completion information.
Dataflow Directional Tag Classes.
virtual void StartTranslationUnit(ASTConsumer *Consumer)
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
unsigned getLength() const
TranslationUnitKind
Describes the kind of translation unit being processed.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
static void EnableStatistics()
This class handles loading and caching of source files into memory.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result)
Parse the first top-level declaration in a translation unit.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
static void EnableStatistics()