aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-10 23:38:47 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-10 23:38:47 +0000
commit4a6835e650ff24e19ce08a3bd347c0ad186777fd (patch)
tree38e236ecf687032588886d20b1e4748e43e1f48d /lib/CodeGen/CodeGenModule.h
parent75212ee91313bc1b6dd826d9b173541bc4016539 (diff)
Add stricter GlobalDecl constructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r--lib/CodeGen/CodeGenModule.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 607f2a172c..d5b0bfa6a8 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -70,23 +70,31 @@ namespace CodeGen {
/// GlobalDecl - represents a global declaration. This can either be a
/// CXXConstructorDecl and the constructor type (Base, Complete).
/// a CXXDestructorDecl and the destructor type (Base, Complete) or
-// a regular VarDecl or a FunctionDecl.
+/// a VarDecl, a FunctionDecl or a BlockDecl.
class GlobalDecl {
- llvm::PointerIntPair<const ValueDecl*, 2> Value;
+ llvm::PointerIntPair<const Decl*, 2> Value;
+ void init(const Decl *D) {
+ assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!");
+ assert(!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!");
+ assert(isa<VarDecl>(D) || isa<FunctionDecl>(D)
+ && "Invalid decl type passed to GlobalDecl ctor!");
+
+ Value.setPointer(D);
+ }
+
public:
GlobalDecl() {}
- explicit GlobalDecl(const ValueDecl *VD) : Value(VD, 0) {
- assert(!isa<CXXConstructorDecl>(VD) && "Use other ctor with ctor decls!");
- assert(!isa<CXXDestructorDecl>(VD) && "Use other ctor with dtor decls!");
- }
+ GlobalDecl(const VarDecl *D) { init(D);}
+ GlobalDecl(const FunctionDecl *D) { init(D); }
+
GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
: Value(D, Type) {}
GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type)
: Value(D, Type) {}
- const ValueDecl *getDecl() const { return Value.getPointer(); }
+ const Decl *getDecl() const { return Value.getPointer(); }
CXXCtorType getCtorType() const {
assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!");