diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-26 04:38:44 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-26 04:38:44 +0000 |
commit | 137d6625eb61a41e776d89b39f3cb958d4a21140 (patch) | |
tree | dbfdb3289ee14286cabc0f0e1667c90d0743420e /lib/Sema/Sema.cpp | |
parent | 485458aa998c12e43bc9883b49060425d58b351d (diff) |
Fix a regression from the previous commit.
Template instantiation can set the canonical decl to used after subsequent
decls have been chained, so we have to check that too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index e444f3c357..4b82069a62 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -328,7 +328,11 @@ CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector. static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { - if (D->getMostRecentDecl()->isUsed()) + // Template instantiation can happen at the end of the translation unit + // and it sets the canonical (first) decl to used. Normal uses set the last + // decl at the time to used and subsequent decl inherit the flag. The net + // result is that we need to check both ends of the decl chain. + if (D->isUsed() || D->getMostRecentDecl()->isUsed()) return true; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |