From: Richard Smith Date: Tue, 5 Jan 2016 01:21:53 +0000 (+0000) Subject: Avoid walking all the declarations in the TU when a tag is declared in function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=051b623bcb1fed8fe099b6d09163c62c2dea0ae5;p=clang Avoid walking all the declarations in the TU when a tag is declared in function prototype scope in a function definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256803 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2c5516a48d..a41faa3880 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -10911,12 +10911,8 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, // from the translation unit and reattach to the current context. if (D->getLexicalDeclContext() == Context.getTranslationUnitDecl()) { // Is the decl actually in the context? - for (const auto *DI : Context.getTranslationUnitDecl()->decls()) { - if (DI == D) { - Context.getTranslationUnitDecl()->removeDecl(D); - break; - } - } + if (Context.getTranslationUnitDecl()->containsDecl(D)) + Context.getTranslationUnitDecl()->removeDecl(D); // Either way, reassign the lexical decl context to our FunctionDecl. D->setLexicalDeclContext(CurContext); }