Cleanup linkage computation for static locals.
With this patch we assign VisibleNoLinkage to static locals in inline functions.
This lets us simplify CodeGen a bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184114 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index cb15748..614eaab 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -126,10 +126,8 @@
// If the function definition has some sort of weak linkage, its
// static variables should also be weak so that they get properly
- // uniqued. We can't do this in C, though, because there's no
- // standard way to agree on which variables are the same (i.e.
- // there's no mangling).
- if (getLangOpts().CPlusPlus) {
+ // uniqued.
+ if (D.isExternallyVisible()) {
const Decl *D = CurCodeDecl;
while (true) {
if (isa<BlockDecl>(D)) {
@@ -143,7 +141,7 @@
}
}
// FIXME: Do we really only care about FunctionDecls here?
- if (D && isa<FunctionDecl>(D)) {
+ if (isa<FunctionDecl>(D)) {
llvm::GlobalValue::LinkageTypes ParentLinkage =
CGM.getFunctionLinkage(cast<FunctionDecl>(D));
if (llvm::GlobalValue::isWeakForLinker(ParentLinkage))