summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-12-06 16:10:28 -0800
committerReid Kleckner <rnk@google.com>2019-12-18 13:47:00 -0800
commit71f9c30b5348bbb2b41d4ffa6c7688dec8e0074a (patch)
tree8509f516b05a52fd29a2cdbd11234f59cedb19dd
parent5789e83dedb97588ad75cca36d01ba6c5142d6d3 (diff)
downloadbcm5719-llvm-71f9c30b5348bbb2b41d4ffa6c7688dec8e0074a.tar.gz
bcm5719-llvm-71f9c30b5348bbb2b41d4ffa6c7688dec8e0074a.zip
Move TypeSourceInfo to Type.h
TypeSourceInfo is a thin wrapper around TypeLocs. Notionally, the best place for it to live would be TypeLoc.h, but Decl.h requires it to be complete, so it needs to be lower in the dependency graph. Type.h seems like the next best place. By itself, this change has no impact on build time, because it doesn't remove a single dependency edge from a .cpp file to a .h file, but it is an incremental step towards making the AST headers less interdependent. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D71427
-rw-r--r--clang/include/clang/AST/Decl.h27
-rw-r--r--clang/include/clang/AST/Type.h27
-rw-r--r--clang/include/clang/AST/TypeLoc.h8
-rw-r--r--clang/lib/AST/TypeLoc.cpp6
4 files changed, 35 insertions, 33 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 90e8d19b17f..de1cfe94000 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -78,33 +78,6 @@ class TypeLoc;
class UnresolvedSetImpl;
class VarTemplateDecl;
-/// A container of type source information.
-///
-/// A client can read the relevant info using TypeLoc wrappers, e.g:
-/// @code
-/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
-/// TL.getBeginLoc().print(OS, SrcMgr);
-/// @endcode
-class alignas(8) TypeSourceInfo {
- // Contains a memory block after the class, used for type source information,
- // allocated by ASTContext.
- friend class ASTContext;
-
- QualType Ty;
-
- TypeSourceInfo(QualType ty) : Ty(ty) {}
-
-public:
- /// Return the type wrapped by this type source info.
- QualType getType() const { return Ty; }
-
- /// Return the TypeLoc wrapper for the type source info.
- TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
-
- /// Override the type stored in this TypeSourceInfo. Use with caution!
- void overrideType(QualType T) { Ty = T; }
-};
-
/// The top declaration context.
class TranslationUnitDecl : public Decl, public DeclContext {
ASTContext &Ctx;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 942564756c9..f5955c45faf 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6179,6 +6179,33 @@ public:
QualType apply(const ASTContext &Context, const Type* T) const;
};
+/// A container of type source information.
+///
+/// A client can read the relevant info using TypeLoc wrappers, e.g:
+/// @code
+/// TypeLoc TL = TypeSourceInfo->getTypeLoc();
+/// TL.getBeginLoc().print(OS, SrcMgr);
+/// @endcode
+class alignas(8) TypeSourceInfo {
+ // Contains a memory block after the class, used for type source information,
+ // allocated by ASTContext.
+ friend class ASTContext;
+
+ QualType Ty;
+
+ TypeSourceInfo(QualType ty) : Ty(ty) {}
+
+public:
+ /// Return the type wrapped by this type source info.
+ QualType getType() const { return Ty; }
+
+ /// Return the TypeLoc wrapper for the type source info.
+ TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
+
+ /// Override the type stored in this TypeSourceInfo. Use with caution!
+ void overrideType(QualType T) { Ty = T; }
+};
+
// Inline function definitions.
inline SplitQualType SplitQualType::getSingleStepDesugaredType() const {
diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h
index 618e462d097..c3baaa3e417 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -14,7 +14,6 @@
#ifndef LLVM_CLANG_AST_TYPELOC_H
#define LLVM_CLANG_AST_TYPELOC_H
-#include "clang/AST/Decl.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/Type.h"
@@ -39,6 +38,7 @@ class Expr;
class ObjCInterfaceDecl;
class ObjCProtocolDecl;
class ObjCTypeParamDecl;
+class ParmVarDecl;
class TemplateTypeParmDecl;
class UnqualTypeLoc;
class UnresolvedUsingTypenameDecl;
@@ -704,11 +704,7 @@ public:
TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
/// True if the tag was defined in this type specifier.
- bool isDefinition() const {
- TagDecl *D = getDecl();
- return D->isCompleteDefinition() &&
- (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
- }
+ bool isDefinition() const;
};
/// Wrapper for source info for record types.
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index d6c992f9ab0..6e67ca8e0af 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -294,6 +294,12 @@ bool TypeSpecTypeLoc::isKind(const TypeLoc &TL) {
return TSTChecker().Visit(TL);
}
+bool TagTypeLoc::isDefinition() const {
+ TagDecl *D = getDecl();
+ return D->isCompleteDefinition() &&
+ (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
+}
+
// Reimplemented to account for GNU/C++ extension
// typeof unary-expression
// where there are no parentheses.
OpenPOWER on IntegriCloud