[llvm] [IPO] Fix warnings in FunctionImport.h (PR #112861)

Karl-Johan Karlsson via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 02:24:03 PDT 2024


https://github.com/karka228 created https://github.com/llvm/llvm-project/pull/112861

Fix gcc 13.3 warnings like:
FunctionImport.h:273:33: warning: member 'llvm::FunctionImporter::ImportListsTy::ImportIDs' is used uninitialized [-Wuninitialized]

>From cb58648b30b0d50ee71b48644441e4fc9d3b5ef3 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson <karl-johan.karlsson at ericsson.com>
Date: Thu, 17 Oct 2024 07:56:06 +0200
Subject: [PATCH] [IPO] Fix warnings in FunctionImport.h

Fix gcc 13.3 warnings like:
FunctionImport.h:273:33: warning: member 'llvm::FunctionImporter::ImportListsTy::ImportIDs' is used uninitialized [-Wuninitialized]
---
 llvm/include/llvm/Transforms/IPO/FunctionImport.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index 3623f9194d4d13..9cf3898d380318 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -270,8 +270,9 @@ class FunctionImporter {
   // A map from destination modules to lists of imports.
   class ImportListsTy {
   public:
-    ImportListsTy() : EmptyList(ImportIDs) {}
-    ImportListsTy(size_t Size) : EmptyList(ImportIDs), ListsImpl(Size) {}
+    ImportListsTy() : ImportIDs(), EmptyList(ImportIDs) {}
+    ImportListsTy(size_t Size)
+        : ImportIDs(), EmptyList(ImportIDs), ListsImpl(Size) {}
 
     ImportMapTy &operator[](StringRef DestMod) {
       return ListsImpl.try_emplace(DestMod, ImportIDs).first->second;
@@ -291,9 +292,9 @@ class FunctionImporter {
     const_iterator end() const { return ListsImpl.end(); }
 
   private:
+    ImportIDTable ImportIDs;
     ImportMapTy EmptyList;
     DenseMap<StringRef, ImportMapTy> ListsImpl;
-    ImportIDTable ImportIDs;
   };
 
   /// The set contains an entry for every global value that the module exports.



More information about the llvm-commits mailing list