From f50ef6ed9aec398aeb340808bdfbc012d30a9e73 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 21 Feb 2010 07:08:09 +0000 Subject: 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 --- clang/lib/Sema/SemaDecl.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') 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(D) && - cast(D)->getTemplatedDecl()->isOutOfLine()) || - (isa(D) && - (cast(D)->isFunctionTemplateSpecialization() || - cast(D)->isOutOfLine())) || - (isa(D) && cast(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(D) || isa(D)) && + D->isOutOfLine()) + return; + + // Template instantiations should also not be pushed into scope. + if (isa(D) && + cast(D)->isFunctionTemplateSpecialization()) return; // If this replaces anything in the current scope, -- cgit v1.2.3