Avoid walking all the declarations in the TU when a tag is declared in function

prototype scope in a function definition.

llvm-svn: 256803
This commit is contained in:
Richard Smith 2016-01-05 01:21:53 +00:00
parent a694a0b141
commit 40b14d4893
1 changed files with 2 additions and 6 deletions

View 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);
}