diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-02-21 07:08:09 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-02-21 07:08:09 +0000 |
commit | f50ef6ed9aec398aeb340808bdfbc012d30a9e73 (patch) | |
tree | def9e118679c9420a5fa4757d88698adb0ee4488 /clang/lib/Sema/SemaDecl.cpp | |
parent | 56ec7895210b6b488d9915963927489085000278 (diff) | |
download | bcm5719-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.cpp | 17 |
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, |