25 #include "llvm/Support/CrashRecoveryContext.h"
29 using namespace clang;
34 class PrettyStackTraceParserEntry :
public llvm::PrettyStackTraceEntry {
37 PrettyStackTraceParserEntry(
const Parser &
p) :
P(p) {}
38 void print(raw_ostream &OS)
const override;
43 void PrettyStackTraceParserEntry::print(raw_ostream &OS)
const {
44 const Token &Tok =
P.getCurToken();
46 OS <<
"<eof> parser at end of file\n";
51 OS <<
"<unknown> parser at unknown location\n";
58 OS <<
": at annotation token\n";
67 OS <<
": unknown current parser token\n";
70 OS <<
": current parser token '" << StringRef(Spelling, Length) <<
"'\n";
88 bool SkipFunctionBodies) {
90 std::unique_ptr<Sema>
S(
91 new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer));
94 llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
96 ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
103 Stmt::EnableStatistics();
107 bool OldCollectStats = PrintStats;
112 std::unique_ptr<Parser> ParseOP(
116 PrettyStackTraceParserEntry CrashInfo(P);
119 llvm::CrashRecoveryContextCleanupRegistrar<Parser>
120 CleanupParser(ParseOP.get());
136 P.
Diag(diag::ext_empty_translation_unit);
155 llvm::errs() <<
"\nSTATISTICS:\n";
SourceManager & getSourceManager() const
Defines the clang::ASTContext interface.
SmallVectorImpl< Decl * > & WeakTopLevelDecls()
WeakTopLevelDeclDecls - access to #pragma weak-generated Decls.
const LangOptions & getLangOpts() const
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.
virtual void PrintStats()
PrintStats - If desired, print any statistics.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Sema - This implements semantic analysis and AST building for C.
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc...
virtual void HandleTranslationUnit(ASTContext &Ctx)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Abstract interface for external sources of AST nodes.
void print(raw_ostream &OS, const SourceManager &SM) const
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
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. ...
ASTConsumer & getASTConsumer() const
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
bool is(tok::TokenKind K) const
bool ParseTopLevelDecl(DeclGroupPtrTy &Result)
Abstract interface for a consumer of code-completion information.
Sema & getActions() const
static __inline__ uint32_t volatile uint32_t * p
virtual void StartTranslationUnit(ASTConsumer *Consumer)
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
TranslationUnitKind
Describes the kind of translation unit being processed.
void PrintStats() const
Print out statistics about the semantic analysis.
unsigned getLength() const
virtual bool HandleTopLevelDecl(DeclGroupRef D)
static void EnableStatistics()
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
This class handles loading and caching of source files into memory.
Preprocessor & getPreprocessor() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.