From: Reid Kleckner Date: Thu, 27 Feb 2020 22:16:47 +0000 (-0800) Subject: Avoid ASTContext.h -> TargetInfo.h dep X-Git-Tag: llvmorg-12-init~13425 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c2a6567bb12559cfc091bca2b25ae907cbd4e0f;p=platform%2Fupstream%2Fllvm.git Avoid ASTContext.h -> TargetInfo.h dep This has been done before in 2008: ab13857072 But these things regress easily. Move some things out of line. Saves 316 includes + transitive stuff: 316 - ../clang/include/clang/Basic/TargetOptions.h 316 - ../clang/include/clang/Basic/TargetInfo.h 316 - ../clang/include/clang/Basic/TargetCXXABI.h 316 - ../clang/include/clang/Basic/OpenCLOptions.h 316 - ../clang/include/clang/Basic/OpenCLExtensions.def 302 - ../llvm/include/llvm/Target/TargetOptions.h 302 - ../llvm/include/llvm/Support/CodeGen.h 302 - ../llvm/include/llvm/MC/MCTargetOptions.h 302 - ../llvm/include/llvm/ADT/FloatingPointMode.h 302 - ../clang/include/clang/Basic/XRayInstr.h 302 - ../clang/include/clang/Basic/DebugInfoOptions.h 302 - ../clang/include/clang/Basic/CodeGenOptions.h 302 - ../clang/include/clang/Basic/CodeGenOptions.def 257 - ../llvm/include/llvm/Support/Regex.h 79 - ../llvm/include/llvm/ADT/SmallSet.h 68 - MSVCSTL/include/set 66 - ../llvm/include/llvm/ADT/SmallPtrSet.h 62 - ../llvm/include/llvm/ADT/StringSwitch.h --- diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 2640c66..92e5921 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -39,7 +39,6 @@ #include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "clang/Basic/TargetInfo.h" #include "clang/Basic/XRayLists.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" @@ -74,6 +73,7 @@ namespace llvm { struct fltSemantics; +template class SmallPtrSet; } // namespace llvm @@ -131,7 +131,6 @@ class VarTemplateDecl; class VTableContextBase; struct BlockVarCopyInit; - namespace Builtin { class Context; @@ -139,6 +138,7 @@ class Context; } // namespace Builtin enum BuiltinTemplateKind : int; +enum OpenCLTypeKind : uint8_t; namespace comments { @@ -1205,7 +1205,7 @@ public: QualType getBlockDescriptorExtendedType() const; /// Map an AST Type to an OpenCLTypeKind enum value. - TargetInfo::OpenCLTypeKind getOpenCLTypeKind(const Type *T) const; + OpenCLTypeKind getOpenCLTypeKind(const Type *T) const; /// Get address space for OpenCL type. LangAS getOpenCLTypeAddrSpace(const Type *T) const; @@ -1635,23 +1635,9 @@ public: return NSCopyingName; } - CanQualType getNSUIntegerType() const { - assert(Target && "Expected target to be initialized"); - const llvm::Triple &T = Target->getTriple(); - // Windows is LLP64 rather than LP64 - if (T.isOSWindows() && T.isArch64Bit()) - return UnsignedLongLongTy; - return UnsignedLongTy; - } + CanQualType getNSUIntegerType() const; - CanQualType getNSIntegerType() const { - assert(Target && "Expected target to be initialized"); - const llvm::Triple &T = Target->getTriple(); - // Windows is LLP64 rather than LP64 - if (T.isOSWindows() && T.isArch64Bit()) - return LongLongTy; - return LongTy; - } + CanQualType getNSIntegerType() const; /// Retrieve the identifier 'bool'. IdentifierInfo *getBoolName() const { @@ -2129,9 +2115,7 @@ public: /// Return the alignment (in bytes) of the thrown exception object. This is /// only meaningful for targets that allocate C++ exceptions in a system /// runtime, such as those using the Itanium C++ ABI. - CharUnits getExnObjectAlignment() const { - return toCharUnitsFromBits(Target->getExnObjectAlignment()); - } + CharUnits getExnObjectAlignment() const; /// Get or compute information about the layout of the specified /// record (struct/union/class) \p D, which indicates its size and field diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index cb5aabd..80581ea 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -159,6 +159,18 @@ protected: unsigned ZeroLengthBitfieldBoundary; }; +/// OpenCL type kinds. +enum OpenCLTypeKind : uint8_t { + OCLTK_Default, + OCLTK_ClkEvent, + OCLTK_Event, + OCLTK_Image, + OCLTK_Pipe, + OCLTK_Queue, + OCLTK_ReserveID, + OCLTK_Sampler, +}; + /// Exposes information about the current target. /// class TargetInfo : public virtual TransferrableTargetInfo, @@ -1347,17 +1359,6 @@ public: return getTargetOpts().SupportedOpenCLOptions; } - enum OpenCLTypeKind { - OCLTK_Default, - OCLTK_ClkEvent, - OCLTK_Event, - OCLTK_Image, - OCLTK_Pipe, - OCLTK_Queue, - OCLTK_ReserveID, - OCLTK_Sampler, - }; - /// Get address space for OpenCL type. virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const; diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h index 1712501..294a45b 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTCONSTRAINTMANAGER_H #include "clang/Basic/JsonSupport.h" +#include "clang/Basic/TargetInfo.h" #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h" diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b816f3b..bc4f2b4 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1730,6 +1730,10 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const { return toCharUnitsFromBits(Align); } +CharUnits ASTContext::getExnObjectAlignment() const { + return toCharUnitsFromBits(Target->getExnObjectAlignment()); +} + // getTypeInfoDataSizeInChars - Return the size of a type, in // chars. If the type is a record, its data size is returned. This is // the size of the memcpy that's performed when assigning this type @@ -6226,39 +6230,39 @@ QualType ASTContext::getBlockDescriptorExtendedType() const { return getTagDeclType(BlockDescriptorExtendedType); } -TargetInfo::OpenCLTypeKind ASTContext::getOpenCLTypeKind(const Type *T) const { +OpenCLTypeKind ASTContext::getOpenCLTypeKind(const Type *T) const { const auto *BT = dyn_cast(T); if (!BT) { if (isa(T)) - return TargetInfo::OCLTK_Pipe; + return OCLTK_Pipe; - return TargetInfo::OCLTK_Default; + return OCLTK_Default; } switch (BT->getKind()) { #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ case BuiltinType::Id: \ - return TargetInfo::OCLTK_Image; + return OCLTK_Image; #include "clang/Basic/OpenCLImageTypes.def" case BuiltinType::OCLClkEvent: - return TargetInfo::OCLTK_ClkEvent; + return OCLTK_ClkEvent; case BuiltinType::OCLEvent: - return TargetInfo::OCLTK_Event; + return OCLTK_Event; case BuiltinType::OCLQueue: - return TargetInfo::OCLTK_Queue; + return OCLTK_Queue; case BuiltinType::OCLReserveID: - return TargetInfo::OCLTK_ReserveID; + return OCLTK_ReserveID; case BuiltinType::OCLSampler: - return TargetInfo::OCLTK_Sampler; + return OCLTK_Sampler; default: - return TargetInfo::OCLTK_Default; + return OCLTK_Default; } } @@ -6331,6 +6335,24 @@ bool ASTContext::getByrefLifetime(QualType Ty, return true; } +CanQualType ASTContext::getNSUIntegerType() const { + assert(Target && "Expected target to be initialized"); + const llvm::Triple &T = Target->getTriple(); + // Windows is LLP64 rather than LP64 + if (T.isOSWindows() && T.isArch64Bit()) + return UnsignedLongLongTy; + return UnsignedLongTy; +} + +CanQualType ASTContext::getNSIntegerType() const { + assert(Target && "Expected target to be initialized"); + const llvm::Triple &T = Target->getTriple(); + // Windows is LLP64 rather than LP64 + if (T.isOSWindows() && T.isArch64Bit()) + return LongLongTy; + return LongTy; +} + TypedefDecl *ASTContext::getObjCInstanceTypeDecl() { if (!ObjCInstanceTypeDecl) ObjCInstanceTypeDecl = diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 1d0e34f..716f285 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -21,6 +21,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" #include "clang/AST/StmtVisitor.h" +#include "clang/Basic/TargetInfo.h" #include "llvm/ADT/Optional.h" namespace clang { diff --git a/clang/lib/AST/Interp/Context.cpp b/clang/lib/AST/Interp/Context.cpp index e7f9ba0..3bfcdfc 100644 --- a/clang/lib/AST/Interp/Context.cpp +++ b/clang/lib/AST/Interp/Context.cpp @@ -17,6 +17,7 @@ #include "PrimType.h" #include "Program.h" #include "clang/AST/Expr.h" +#include "clang/Basic/TargetInfo.h" using namespace clang; using namespace clang::interp; diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 48a3938..ff8cea4 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -26,6 +26,7 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/Module.h" #include "clang/Basic/SanitizerBlacklist.h" +#include "clang/Basic/TargetInfo.h" #include "clang/Basic/XRayLists.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" diff --git a/clang/lib/CodeGen/PatternInit.cpp b/clang/lib/CodeGen/PatternInit.cpp index 3410c7f..71c8b94 100644 --- a/clang/lib/CodeGen/PatternInit.cpp +++ b/clang/lib/CodeGen/PatternInit.cpp @@ -8,6 +8,7 @@ #include "PatternInit.h" #include "CodeGenModule.h" +#include "clang/Basic/TargetInfo.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Type.h" diff --git a/clang/unittests/CodeGen/TBAAMetadataTest.cpp b/clang/unittests/CodeGen/TBAAMetadataTest.cpp index 9726838..c2a21bf 100644 --- a/clang/unittests/CodeGen/TBAAMetadataTest.cpp +++ b/clang/unittests/CodeGen/TBAAMetadataTest.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/ModuleBuilder.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Parse/ParseAST.h" diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index b3cc9d6..8c88992 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "clang/AST/ASTContext.h" +#include "clang/Basic/TargetInfo.h" #include "Cocoa.h" diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 50b5f2e2..d6b7abc 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -62,6 +62,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" +#include "clang/Basic/TargetInfo.h" #include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h" diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 5f9bf5d..8484318 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -15,6 +15,8 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/StringLexer.h" +#include "clang/Basic/TargetInfo.h" + #include using namespace lldb_private; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 8864c60..75e749f 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -23,6 +23,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTFwd.h" #include "clang/AST/TemplateBase.h" +#include "clang/Basic/TargetInfo.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h"