//===--- ParseAST.cpp - Provide the clang::ParseAST method ----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the clang::ParseAST method. // //===----------------------------------------------------------------------===// #include "clang/Parse/ParseAST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/ExternalASTSource.h" #include "clang/AST/Stmt.h" #include "clang/Parse/ParseDiagnostic.h" #include "clang/Parse/Parser.h" #include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Sema/EnterExpressionEvaluationContext.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaConsumer.h" #include "clang/Sema/TemplateInstCallback.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/TimeProfiler.h" #include <cstdio> #include <memory> usingnamespaceclang; namespace { /// Resets LLVM's pretty stack state so that stack traces are printed correctly /// when there are nested CrashRecoveryContexts and the inner one recovers from /// a crash. class ResetStackCleanup : public llvm::CrashRecoveryContextCleanupBase<ResetStackCleanup, const void> { … }; /// If a crash happens while the parser is active, an entry is printed for it. class PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry { … }; /// If a crash happens while the parser is active, print out a line indicating /// what the current token is. void PrettyStackTraceParserEntry::print(raw_ostream &OS) const { … } } // namespace //===----------------------------------------------------------------------===// // Public interface to the file //===----------------------------------------------------------------------===// /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as /// the file is parsed. This inserts the parsed decls into the translation unit /// held by Ctx. /// void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, ASTContext &Ctx, bool PrintStats, TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer, bool SkipFunctionBodies) { … } void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) { … }