summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-02-21 07:08:09 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-02-21 07:08:09 +0000
commitf50ef6ed9aec398aeb340808bdfbc012d30a9e73 (patch)
treedef9e118679c9420a5fa4757d88698adb0ee4488 /clang/lib/Sema/SemaDecl.cpp
parent56ec7895210b6b488d9915963927489085000278 (diff)
downloadbcm5719-llvm-f50ef6ed9aec398aeb340808bdfbc012d30a9e73.tar.gz
bcm5719-llvm-f50ef6ed9aec398aeb340808bdfbc012d30a9e73.zip
Make Decl::isOutOfLine() virtual, and use that to determine when definitions
are for out of line declarations more easily. This simplifies the logic and handles the case of out-of-line class definitions correctly. Fixes PR6107. llvm-svn: 96729
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 78bb2ae9b37..3d5f9523d9a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -436,14 +436,15 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
if (AddToContext)
CurContext->addDecl(D);
- // Out-of-line function and variable definitions should not be pushed into
- // scope.
- if ((isa<FunctionTemplateDecl>(D) &&
- cast<FunctionTemplateDecl>(D)->getTemplatedDecl()->isOutOfLine()) ||
- (isa<FunctionDecl>(D) &&
- (cast<FunctionDecl>(D)->isFunctionTemplateSpecialization() ||
- cast<FunctionDecl>(D)->isOutOfLine())) ||
- (isa<VarDecl>(D) && cast<VarDecl>(D)->isOutOfLine()))
+ // Out-of-line definitions shouldn't be pushed into scope in C++.
+ // Out-of-line variable and function definitions shouldn't even in C.
+ if ((getLangOptions().CPlusPlus || isa<VarDecl>(D) || isa<FunctionDecl>(D)) &&
+ D->isOutOfLine())
+ return;
+
+ // Template instantiations should also not be pushed into scope.
+ if (isa<FunctionDecl>(D) &&
+ cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
return;
// If this replaces anything in the current scope,
OpenPOWER on IntegriCloud