Avoid including Builtins.h in Preprocessor.h

Builtins are rarely if ever accessed via the Preprocessor. They are
typically found on the ASTContext, so there should be no performance
penalty to using a pointer indirection to store the builtin context.
This commit is contained in:
Reid Kleckner 2019-11-15 16:36:00 -08:00
parent 4d23764ddd
commit 979da9a4c3
14 changed files with 23 additions and 9 deletions

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "MacroRepeatedSideEffectsCheck.h" #include "MacroRepeatedSideEffectsCheck.h"
#include "clang/Basic/Builtins.h"
#include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/MacroArgs.h" #include "clang/Lex/MacroArgs.h"
#include "clang/Lex/PPCallbacks.h" #include "clang/Lex/PPCallbacks.h"

View File

@ -16,6 +16,7 @@
#include "index/Merge.h" #include "index/Merge.h"
#include "index/SymbolOrigin.h" #include "index/SymbolOrigin.h"
#include "index/dex/Dex.h" #include "index/dex/Dex.h"
#include "clang/AST/ASTContext.h"
#include "clang/Index/IndexingAction.h" #include "clang/Index/IndexingAction.h"
#include "clang/Index/IndexingOptions.h" #include "clang/Index/IndexingOptions.h"
#include "clang/Lex/MacroInfo.h" #include "clang/Lex/MacroInfo.h"

View File

@ -25,6 +25,7 @@
#include <memory> #include <memory>
namespace clang { namespace clang {
class ASTContext;
namespace clangd { namespace clangd {
class ParsedAST; class ParsedAST;

View File

@ -25,8 +25,6 @@
namespace clang { namespace clang {
class TargetInfo; class TargetInfo;
class IdentifierTable; class IdentifierTable;
class ASTContext;
class QualType;
class LangOptions; class LangOptions;
enum LanguageID { enum LanguageID {

View File

@ -14,7 +14,6 @@
#ifndef LLVM_CLANG_LEX_PREPROCESSOR_H #ifndef LLVM_CLANG_LEX_PREPROCESSOR_H
#define LLVM_CLANG_LEX_PREPROCESSOR_H #define LLVM_CLANG_LEX_PREPROCESSOR_H
#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h" #include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h" #include "clang/Basic/LLVM.h"
@ -81,6 +80,10 @@ class PreprocessorOptions;
class ScratchBuffer; class ScratchBuffer;
class TargetInfo; class TargetInfo;
namespace Builtin {
class Context;
}
/// Stores token information for comparing actual tokens with /// Stores token information for comparing actual tokens with
/// predefined values. Only handles simple tokens and identifiers. /// predefined values. Only handles simple tokens and identifiers.
class TokenValue { class TokenValue {
@ -239,7 +242,7 @@ class Preprocessor {
SelectorTable Selectors; SelectorTable Selectors;
/// Information about builtins. /// Information about builtins.
Builtin::Context BuiltinInfo; std::unique_ptr<Builtin::Context> BuiltinInfo;
/// Tracks all of the pragmas that the client registered /// Tracks all of the pragmas that the client registered
/// with this preprocessor. /// with this preprocessor.
@ -911,7 +914,7 @@ public:
IdentifierTable &getIdentifierTable() { return Identifiers; } IdentifierTable &getIdentifierTable() { return Identifiers; }
const IdentifierTable &getIdentifierTable() const { return Identifiers; } const IdentifierTable &getIdentifierTable() const { return Identifiers; }
SelectorTable &getSelectorTable() { return Selectors; } SelectorTable &getSelectorTable() { return Selectors; }
Builtin::Context &getBuiltinInfo() { return BuiltinInfo; } Builtin::Context &getBuiltinInfo() { return *BuiltinInfo; }
llvm::BumpPtrAllocator &getPreprocessorAllocator() { return BP; } llvm::BumpPtrAllocator &getPreprocessorAllocator() { return BP; }
void setExternalSource(ExternalPreprocessorSource *Source) { void setExternalSource(ExternalPreprocessorSource *Source) {

View File

@ -19,6 +19,7 @@
#include "clang/AST/StmtCXX.h" #include "clang/AST/StmtCXX.h"
#include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h" #include "clang/Analysis/CFG.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManager.h"
#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"

View File

@ -11,6 +11,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInstance.h"

View File

@ -10,6 +10,7 @@
#include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h" #include "clang/AST/ASTContext.h"
#include "clang/AST/DeclGroup.h" #include "clang/AST/DeclGroup.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/LangStandard.h" #include "clang/Basic/LangStandard.h"
#include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInstance.h"

View File

@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/Basic/Attributes.h" #include "clang/Basic/Attributes.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FileManager.h" #include "clang/Basic/FileManager.h"
#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h" #include "clang/Basic/LLVM.h"
@ -35,9 +36,9 @@
#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/None.h" #include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"

View File

@ -25,6 +25,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FileManager.h" #include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemStatCache.h" #include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/IdentifierTable.h"
@ -53,9 +54,9 @@
#include "llvm/ADT/APInt.h" #include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Capacity.h" #include "llvm/Support/Capacity.h"
@ -202,7 +203,8 @@ void Preprocessor::Initialize(const TargetInfo &Target,
this->AuxTarget = AuxTarget; this->AuxTarget = AuxTarget;
// Initialize information about built-ins. // Initialize information about built-ins.
BuiltinInfo.InitializeTarget(Target, AuxTarget); BuiltinInfo = std::make_unique<Builtin::Context>();
BuiltinInfo->InitializeTarget(Target, AuxTarget);
HeaderInfo.setTarget(Target); HeaderInfo.setTarget(Target);
// Populate the identifier table with info about keywords for the current language. // Populate the identifier table with info about keywords for the current language.

View File

@ -18,6 +18,7 @@
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h" #include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtCXX.h" #include "clang/AST/StmtCXX.h"
#include "clang/Basic/Builtins.h"
#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Initialization.h" #include "clang/Sema/Initialization.h"
#include "clang/Sema/Overload.h" #include "clang/Sema/Overload.h"

View File

@ -25,6 +25,7 @@
#include "clang/AST/ExprOpenMP.h" #include "clang/AST/ExprOpenMP.h"
#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TypeLoc.h" #include "clang/AST/TypeLoc.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FixedPoint.h" #include "clang/Basic/FixedPoint.h"
#include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManager.h"

View File

@ -10,13 +10,13 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/Sema/SemaInternal.h"
#include "clang/AST/ASTContext.h" #include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h" #include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprObjC.h" #include "clang/AST/ExprObjC.h"
#include "clang/AST/StmtVisitor.h" #include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeLoc.h" #include "clang/AST/TypeLoc.h"
#include "clang/Analysis/DomainSpecific/CocoaConventions.h" #include "clang/Analysis/DomainSpecific/CocoaConventions.h"
#include "clang/Basic/Builtins.h"
#include "clang/Edit/Commit.h" #include "clang/Edit/Commit.h"
#include "clang/Edit/Rewriters.h" #include "clang/Edit/Rewriters.h"
#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Preprocessor.h"
@ -24,6 +24,7 @@
#include "clang/Sema/Lookup.h" #include "clang/Sema/Lookup.h"
#include "clang/Sema/Scope.h" #include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h" #include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ConvertUTF.h"

View File

@ -10,6 +10,7 @@
#include "clang/AST/ASTDiagnostic.h" #include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ExternalASTSource.h" #include "clang/AST/ExternalASTSource.h"
#include "clang/AST/PrettyPrinter.h" #include "clang/AST/PrettyPrinter.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetInfo.h"