X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FLLVMContextImpl.cpp;h=4c2791f0a8d531aeb1bd36dd673df16eee5ecd39;hb=2a2fcc1a0ec4a115bbe76c185f7cd64e77b61e7c;hp=61fb7f37d49d0ff5a8ca28078a5b2e017e08aa82;hpb=c2c50cdcdc19a1bca993c06d13d8cdca87083ce4;p=oota-llvm.git diff --git a/lib/IR/LLVMContextImpl.cpp b/lib/IR/LLVMContextImpl.cpp index 61fb7f37d49..4c2791f0a8d 100644 --- a/lib/IR/LLVMContextImpl.cpp +++ b/lib/IR/LLVMContextImpl.cpp @@ -13,13 +13,14 @@ #include "LLVMContextImpl.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Attributes.h" -#include "llvm/Module.h" +#include "llvm/IR/Attributes.h" +#include "llvm/IR/DiagnosticInfo.h" +#include "llvm/IR/Module.h" #include using namespace llvm; LLVMContextImpl::LLVMContextImpl(LLVMContext &C) - : TheTrueVal(0), TheFalseVal(0), + : TheTrueVal(nullptr), TheFalseVal(nullptr), VoidTy(C, Type::VoidTyID), LabelTy(C, Type::LabelTyID), HalfTy(C, Type::HalfTyID), @@ -35,8 +36,12 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C) Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64) { - DiagHandler = 0; - DiagContext = 0; + InlineAsmDiagHandler = nullptr; + InlineAsmDiagContext = nullptr; + DiagnosticHandler = nullptr; + DiagnosticContext = nullptr; + YieldCallback = nullptr; + YieldOpaqueHandle = nullptr; NamedStructTypesUniqueID = 0; } @@ -44,8 +49,7 @@ namespace { struct DropReferences { // Takes the value_type of a ConstantUniqueMap's internal map, whose 'second' // is a Constant*. - template - void operator()(const PairT &P) { + template void operator()(const PairT &P) { P.second->dropAllReferences(); } }; @@ -62,12 +66,11 @@ struct DropFirst { } LLVMContextImpl::~LLVMContextImpl() { - // NOTE: We need to delete the contents of OwnedModules, but we have to - // duplicate it into a temporary vector, because the destructor of Module - // will try to remove itself from OwnedModules set. This would cause - // iterator invalidation if we iterated on the set directly. - std::vector Modules(OwnedModules.begin(), OwnedModules.end()); - DeleteContainerPointers(Modules); + // NOTE: We need to delete the contents of OwnedModules, but Module's dtor + // will call LLVMContextImpl::removeModule, thus invalidating iterators into + // the container. Avoid iterators during this operation: + while (!OwnedModules.empty()) + delete *OwnedModules.begin(); // Free the constants. This is important to do here to ensure that they are // freed before the LeakDetector is torn down. @@ -109,6 +112,13 @@ LLVMContextImpl::~LLVMContextImpl() { delete &*Elem; } + // Destroy attribute node lists. + for (FoldingSetIterator I = AttrsSetNodes.begin(), + E = AttrsSetNodes.end(); I != E; ) { + FoldingSetIterator Elem = I++; + delete &*Elem; + } + // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet // and the NonUniquedMDNodes sets, so copy the values out first. SmallVector MDNodes;