Reduce abuse of default values in the GlobalAlias constructor.
[oota-llvm.git] / lib / Bitcode / Reader / BitcodeReader.cpp
index 14546c0fe4cd20cb73ca3517e75981faf56f8127..478103f982f539e841dac701c4ae6c7a999aedb8 100644 (file)
@@ -1700,8 +1700,11 @@ error_code BitcodeReader::GlobalCleanup() {
   // Look for global variables which need to be renamed.
   for (Module::global_iterator
          GI = TheModule->global_begin(), GE = TheModule->global_end();
-       GI != GE; ++GI)
-    UpgradeGlobalVariable(GI);
+       GI != GE;) {
+    GlobalVariable *GV = GI++;
+    UpgradeGlobalVariable(GV);
+  }
+
   // Force deallocation of memory for these vectors to favor the client that
   // want lazy deserialization.
   std::vector<std::pair<GlobalVariable*, unsigned> >().swap(GlobalInits);
@@ -2001,8 +2004,8 @@ error_code BitcodeReader::ParseModule(bool Resume) {
         return Error(InvalidTypeForValue);
 
       auto *NewGA =
-          new GlobalAlias(PTy->getElementType(), GetDecodedLinkage(Record[2]),
-                          "", nullptr, TheModule, PTy->getAddressSpace());
+          new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
+                          GetDecodedLinkage(Record[2]), "", TheModule);
       // Old bitcode files didn't have visibility field.
       // Local linkage must have default visibility.
       if (Record.size() > 3 && !NewGA->hasLocalLinkage())