diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-01-05 01:21:53 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-01-05 01:21:53 +0000 |
commit | 40b14d489385ab5cec3291041be22162b7e920d6 (patch) | |
tree | c6608fdc0a939862756cce9e7d9aab24c1c5ce14 /clang/lib/Sema/SemaDecl.cpp | |
parent | a694a0b14101a02cd40e756911c4e5d603f0d6ed (diff) | |
download | bcm5719-llvm-40b14d489385ab5cec3291041be22162b7e920d6.tar.gz bcm5719-llvm-40b14d489385ab5cec3291041be22162b7e920d6.zip |
Avoid walking all the declarations in the TU when a tag is declared in function
prototype scope in a function definition.
llvm-svn: 256803
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2c5516a48d6..a41faa3880d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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); } |