diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-08 19:43:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-08 19:43:34 +0000 |
commit | b9725cfb0a50731930a6331beb70f361b4d52a29 (patch) | |
tree | d5b325c55bff6ec06d00be7fbae9af927ae14fa3 /lib/Sema/Sema.cpp | |
parent | cb4d690820295d93c1cea6c13fb4409b8c1db2cf (diff) |
Mark all subsequent decls used.
In the source
static void f();
static void f();
template<typename T>
static void g() {
f();
}
static void f() {
}
void h() {
g<int>();
}
the call to f refers to the second decl, but it is only marked used at the end
of the translation unit during instantiation, after the third f decl has been
linked in.
With this patch we mark all subsequent decls used, so that it is easy to check
if a symbol is used or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 66861ae663..8f9e1a9a0f 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -328,11 +328,7 @@ CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) { /// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector. static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { - // 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()) + if (D->getMostRecentDecl()->isUsed()) return true; if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |