aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorAndrey Bokhanko <andreybokhanko@gmail.com>2016-01-14 10:41:16 +0000
committerAndrey Bokhanko <andreybokhanko@gmail.com>2016-01-14 10:41:16 +0000
commit7aa88ce70c95d4dd27e7245cb624a46835b9fe0c (patch)
treee254998732d2cb7e0519508bac7960b07dafc249 /clang/lib/CodeGen/CodeGenModule.h
parent28f4fbe4803b98cb9f736fe213a25f68e6e2bfe2 (diff)
downloadllvm-7aa88ce70c95d4dd27e7245cb624a46835b9fe0c.zip
llvm-7aa88ce70c95d4dd27e7245cb624a46835b9fe0c.tar.gz
llvm-7aa88ce70c95d4dd27e7245cb624a46835b9fe0c.tar.bz2
PR25910: clang allows two var definitions with the same mangled name
Proper diagnostic and resolution of mangled names' conflicts in variables. When there is a declaration and a definition using the same name but different types, we emit what is in the definition. When there are two conflicting definitions, we issue an error. Differential Revision: http://reviews.llvm.org/D15686 llvm-svn: 257754
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index fdb4d78..c7b8258 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -696,11 +696,14 @@ public:
unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace);
/// Return the llvm::Constant for the address of the given global variable.
- /// If Ty is non-null and if the global doesn't exist, then it will be greated
+ /// If Ty is non-null and if the global doesn't exist, then it will be created
/// with the specified type instead of whatever the normal requested type
- /// would be.
+ /// would be. If IsForDefinition is true, it is guranteed that an actual
+ /// global with type Ty will be returned, not conversion of a variable with
+ /// the same mangled name but some other type.
llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
- llvm::Type *Ty = nullptr);
+ llvm::Type *Ty = nullptr,
+ bool IsForDefinition = false);
/// Return the address of the given function. If Ty is non-null, then this
/// function will use the specified type if it has to create it.
@@ -1136,7 +1139,8 @@ private:
llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
llvm::PointerType *PTy,
- const VarDecl *D);
+ const VarDecl *D,
+ bool IsForDefinition = false);
void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
@@ -1147,7 +1151,7 @@ private:
void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
- void EmitGlobalVarDefinition(const VarDecl *D);
+ void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
void EmitAliasDefinition(GlobalDecl GD);
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
void EmitObjCIvarInitializations(ObjCImplementationDecl *D);