summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorVassil Vassilev <v.g.vassilev@gmail.com>2016-04-28 14:13:28 +0000
committerVassil Vassilev <v.g.vassilev@gmail.com>2016-04-28 14:13:28 +0000
commit928c8254a9cfee98bd13c754723963bd8865c1b5 (patch)
tree4a7e73a1d0a68ea26ad3baeef70b02ea1adfc686 /clang/lib/AST/DeclBase.cpp
parent32617995732d88d245d98bdc0a6a02331f68b321 (diff)
downloadbcm5719-llvm-928c8254a9cfee98bd13c754723963bd8865c1b5.tar.gz
bcm5719-llvm-928c8254a9cfee98bd13c754723963bd8865c1b5.zip
Reland r267691 fixing PR27535.
llvm-svn: 267882
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index aec3b7cd3bd..dd0bab811eb 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -340,25 +340,29 @@ unsigned Decl::getMaxAlignment() const {
return Align;
}
-bool Decl::isUsed(bool CheckUsedAttr) const {
- if (Used)
+bool Decl::isUsed(bool CheckUsedAttr) const {
+ const Decl *CanonD = getCanonicalDecl();
+ if (CanonD->Used)
return true;
-
+
// Check for used attribute.
- if (CheckUsedAttr && hasAttr<UsedAttr>())
+ // Ask the most recent decl, since attributes accumulate in the redecl chain.
+ if (CheckUsedAttr && getMostRecentDecl()->hasAttr<UsedAttr>())
return true;
- return false;
+ // The information may have not been deserialized yet. Force deserialization
+ // to complete the needed information.
+ return getMostRecentDecl()->getCanonicalDecl()->Used;
}
void Decl::markUsed(ASTContext &C) {
- if (Used)
+ if (isUsed(false))
return;
if (C.getASTMutationListener())
C.getASTMutationListener()->DeclarationMarkedUsed(this);
- Used = true;
+ setIsUsed();
}
bool Decl::isReferenced() const {
OpenPOWER on IntegriCloud