Skip to content

Commit bc9f4ed

Browse files
[LTO] Fix used before intialised warning (#143705)
For whatever reason I can't reproduce this locally but I can on Compiler Explorer (https://godbolt.org/z/nfv4b83q6) and on our flang gcc bot (https://lab.llvm.org/buildbot/#/builders/130/builds/13683/steps/5/logs/stdio). In file included from ../llvm-project/llvm/include/llvm/LTO/LTO.h:33, from ../llvm-project/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:29: ../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h: In constructor ‘llvm::FunctionImporter::ImportListsTy::ImportListsTy()’: ../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h:275:33: warning: member ‘llvm::FunctionImporter::ImportListsTy::ImportIDs’ is used uninitialized [-Wuninitialized] 275 | ImportListsTy() : EmptyList(ImportIDs) {} | ^~~~~~~~~ ../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h: In constructor ‘llvm::FunctionImporter::ImportListsTy::ImportListsTy(size_t)’: ../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h:276:44: warning: member ‘llvm::FunctionImporter::ImportListsTy::ImportIDs’ is used uninitialized [-Wuninitialized] 276 | ImportListsTy(size_t Size) : EmptyList(ImportIDs), ListsImpl(Size) {} | ^~~~~~~~~ ImportIDs was being used during construction of EmptyList, before ImportIDs itself had been constructed.
1 parent adfea33 commit bc9f4ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/include/llvm/Transforms/IPO/FunctionImport.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ class FunctionImporter {
272272
// A map from destination modules to lists of imports.
273273
class ImportListsTy {
274274
public:
275-
ImportListsTy() : EmptyList(ImportIDs) {}
276-
ImportListsTy(size_t Size) : EmptyList(ImportIDs), ListsImpl(Size) {}
275+
ImportListsTy() : ImportIDs(), EmptyList(ImportIDs) {}
276+
ImportListsTy(size_t Size)
277+
: ImportIDs(), EmptyList(ImportIDs), ListsImpl(Size) {}
277278

278279
ImportMapTy &operator[](StringRef DestMod) {
279280
return ListsImpl.try_emplace(DestMod, ImportIDs).first->second;
@@ -293,9 +294,9 @@ class FunctionImporter {
293294
const_iterator end() const { return ListsImpl.end(); }
294295

295296
private:
297+
ImportIDTable ImportIDs;
296298
ImportMapTy EmptyList;
297299
DenseMap<StringRef, ImportMapTy> ListsImpl;
298-
ImportIDTable ImportIDs;
299300
};
300301

301302
/// The set contains an entry for every global value that the module exports.

0 commit comments

Comments
 (0)