summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-08-01 20:39:36 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-08-01 20:39:36 +0000
commit1ba0a07e46c96e81c2f60dd8010ce592c2330119 (patch)
tree25ad4bb448b84827572802a3fcedc84e0ff2170b /clang/lib
parente2d6429493d748e24917f8217f7ddd4d29d21ba2 (diff)
downloadbcm5719-llvm-1ba0a07e46c96e81c2f60dd8010ce592c2330119.tar.gz
bcm5719-llvm-1ba0a07e46c96e81c2f60dd8010ce592c2330119.zip
Re-commit r214547 with tests fixed. Hopefully all the bots will be happy now.
Original message: Fix iterator invalidation issues that are breaking my modules buildbot's bootstrap. llvm-svn: 214555
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp13
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp8
2 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a14558f975a..55d47060ff9 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3305,9 +3305,16 @@ void CodeGenModule::EmitVersionIdentMetadata() {
}
void CodeGenModule::EmitTargetMetadata() {
- for (auto &I : MangledDeclNames) {
- const Decl *D = I.first.getDecl()->getMostRecentDecl();
- llvm::GlobalValue *GV = GetGlobalValue(I.second);
+ // Warning, new MangledDeclNames may be appended within this loop.
+ // We rely on MapVector insertions adding new elements to the end
+ // of the container.
+ // FIXME: Move this loop into the one target that needs it, and only
+ // loop over those declarations for which we couldn't emit the target
+ // metadata when we emitted the declaration.
+ for (unsigned I = 0; I != MangledDeclNames.size(); ++I) {
+ auto &Val = *(MangledDeclNames.begin() + I);
+ const Decl *D = Val.first.getDecl()->getMostRecentDecl();
+ llvm::GlobalValue *GV = GetGlobalValue(Val.second);
getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
}
}
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index c5d18d3286a..8c5e178fe28 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -94,9 +94,11 @@ namespace {
for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
Builder->EmitTopLevelDecl(*I);
- // Emit any deferred inline method definitions.
- for (CXXMethodDecl *MD : DeferredInlineMethodDefinitions)
- Builder->EmitTopLevelDecl(MD);
+ // Emit any deferred inline method definitions. Note that more deferred
+ // methods may be added during this loop, since ASTConsumer callbacks
+ // can be invoked if AST inspection results in declarations being added.
+ for (unsigned I = 0; I != DeferredInlineMethodDefinitions.size(); ++I)
+ Builder->EmitTopLevelDecl(DeferredInlineMethodDefinitions[I]);
DeferredInlineMethodDefinitions.clear();
return true;
OpenPOWER on IntegriCloud