summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-11-12 04:10:23 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-11-12 04:10:23 +0000
commit538fb98685522bb7234c693f12e82b8893e290ff (patch)
tree6f7055ac59dde57c6fb6ccc4f1109248c500bae4
parent778dd4a0b20cc176e441527734b1e3ccfd25e47a (diff)
downloadclang-538fb98685522bb7234c693f12e82b8893e290ff.tar.gz
clang-538fb98685522bb7234c693f12e82b8893e290ff.tar.bz2
clang-538fb98685522bb7234c693f12e82b8893e290ff.tar.xz
In Sema::MergeVarDecl we handle merging of storage classes and visibility
attributes. In cases where the merged declaration is fully equivalent to the two original ones, some of the code was getLVForDecl was duplicated. Cases that are still handled in getLVForDecl are things like __private_extern__ int N; int N; For which we cannot produce a single merged decl with all the information. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167703 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/Decl.cpp31
1 files changed, 6 insertions, 25 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 6a51edf7b9..7b13755979 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -341,25 +341,9 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D,
if (Var->getStorageClass() == SC_PrivateExtern)
LV.mergeVisibility(HiddenVisibility, true);
- if (!Context.getLangOpts().CPlusPlus &&
- (Var->getStorageClass() == SC_Extern ||
- Var->getStorageClass() == SC_PrivateExtern)) {
-
- // C99 6.2.2p4:
- // For an identifier declared with the storage-class specifier
- // extern in a scope in which a prior declaration of that
- // identifier is visible, if the prior declaration specifies
- // internal or external linkage, the linkage of the identifier
- // at the later declaration is the same as the linkage
- // specified at the prior declaration. If no prior declaration
- // is visible, or if the prior declaration specifies no
- // linkage, then the identifier has external linkage.
- if (const VarDecl *PrevVar = Var->getPreviousDecl()) {
- LinkageInfo PrevLV = getLVForDecl(PrevVar, OnlyTemplate);
- if (PrevLV.linkage()) LV.setLinkage(PrevLV.linkage());
- LV.mergeVisibility(PrevLV);
- }
- }
+ // Note that Sema::MergeVarDecl already takes care of implementing
+ // C99 6.2.2p4 and propagating the visibility attribute, so we don't have
+ // to do it here.
// - a function, unless it has internal linkage; or
} else if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
@@ -841,13 +825,10 @@ static LinkageInfo getLVForDecl(const NamedDecl *D, bool OnlyTemplate) {
if (llvm::Optional<Visibility> Vis = Var->getExplicitVisibility())
LV.mergeVisibility(*Vis, true);
}
-
- if (const VarDecl *Prev = Var->getPreviousDecl()) {
- LinkageInfo PrevLV = getLVForDecl(Prev, OnlyTemplate);
- if (PrevLV.linkage()) LV.setLinkage(PrevLV.linkage());
- LV.mergeVisibility(PrevLV);
- }
+ // Note that Sema::MergeVarDecl already takes care of implementing
+ // C99 6.2.2p4 and propagating the visibility attribute, so we don't
+ // have to do it here.
return LV;
}
}