]> granicus.if.org Git - clang/commitdiff
Avoid walking all the declarations in the TU when a tag is declared in function
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Jan 2016 01:21:53 +0000 (01:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Jan 2016 01:21:53 +0000 (01:21 +0000)
prototype scope in a function definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256803 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index 2c5516a48d64a9c048b692c1e86a6c784fb5efc2..a41faa3880daa13e9c8e8e4ae4c5a1b2d6fd4da2 100644 (file)
@@ -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);
       }