From 2d34629f474b71d65adbb4e9e5f31ea00f64a4ec Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 13 Jul 2018 21:29:31 +0000 Subject: [PATCH] Make BuiltinType constructor private, and befriend ASTContext. This reflects the fact that only ASTContext should ever create an instance of BuiltinType, and matches what we do for all the other Type subclasses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337048 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Type.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index b21d9f4127..9e024c12ff 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -2253,7 +2253,9 @@ public: #include "clang/AST/BuiltinTypes.def" }; -public: +private: + friend class ASTContext; // ASTContext creates these. + BuiltinType(Kind K) : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent), /*InstantiationDependent=*/(K == Dependent), @@ -2262,6 +2264,7 @@ public: BuiltinTypeBits.Kind = K; } +public: Kind getKind() const { return static_cast(BuiltinTypeBits.Kind); } StringRef getName(const PrintingPolicy &Policy) const; -- 2.40.0