[PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name
Andrey Bokhanko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 5 04:41:31 PST 2016
andreybokhanko added inline comments.
================
Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1243
@@ -1235,9 +1234,11 @@
// different type.
- // FIXME: Support for variables is not implemented yet.
- if (isa<FunctionDecl>(D.getDecl()))
- GV = cast<llvm::GlobalValue>(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
- else
- if (!GV)
- GV = GetGlobalValue(getMangledName(D));
+ llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+ llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(GVC);
+
+ // In case of different address spaces, we may still get a cast, even with
+ // IsForDefinition equal to true. Query mangled names table to get
+ // GlobalValue.
+ if (!GV)
+ GV = GetGlobalValue(getMangledName(D));
// Check to see if we've already emitted this. This is necessary
----------------
You are right -- I missed this case. Fixed.
Patch updated.
http://reviews.llvm.org/D15686
More information about the cfe-commits
mailing list