return LV;
}
+
+ if (!Var->isStaticLocal())
+ return LinkageInfo::none();
}
- if (!isa<TagDecl>(D))
+ ASTContext &Context = D->getASTContext();
+ if (!Context.getLangOpts().CPlusPlus)
return LinkageInfo::none();
const FunctionDecl *FD = getOutermostFunctionContext(D);
// 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)) {
}
}
// 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))
}
void *test() { return foo<int>::bar(); }
}
+
+namespace test17 {
+ // CHECK-DAG: @_ZZN6test173fooILi42EEEPivE3bar = weak_odr
+ // CHECK-DAG: define weak_odr i32* @_ZN6test173fooILi42EEEPiv(
+ template<int I>
+ int *foo() {
+ static int bar;
+ return &bar;
+ }
+ template int *foo<42>();
+}