[llvm] 74fcb6a - [TargetParser] Fix warnings

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 23:57:59 PDT 2024


Author: Kazu Hirata
Date: 2024-07-24T23:57:53-07:00
New Revision: 74fcb6aafddd56df1bd6d6841b2e0f289f8e54b0

URL: https://github.com/llvm/llvm-project/commit/74fcb6aafddd56df1bd6d6841b2e0f289f8e54b0
DIFF: https://github.com/llvm/llvm-project/commit/74fcb6aafddd56df1bd6d6841b2e0f289f8e54b0.diff

LOG: [TargetParser] Fix warnings

This patch fixes:

  llvm/include/llvm/TargetParser/PPCTargetParser.def:109:9: error:
  suggest braces around initialization of subobject
  [-Werror,-Wmissing-braces]

  llvm/lib/TargetParser/PPCTargetParser.cpp:96:16: error: address of
  stack memory associated with local variable 'CPU' returned
  [-Werror,-Wreturn-stack-address]

Added: 
    

Modified: 
    llvm/lib/TargetParser/PPCTargetParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TargetParser/PPCTargetParser.cpp b/llvm/lib/TargetParser/PPCTargetParser.cpp
index 06a18f54affd8..c773c326f1841 100644
--- a/llvm/lib/TargetParser/PPCTargetParser.cpp
+++ b/llvm/lib/TargetParser/PPCTargetParser.cpp
@@ -26,7 +26,7 @@ struct CPUInfo {
 constexpr CPUInfo PPCCPUInfo[] = {
 #define PPC_CPU(Name, Linux_SUPPORT_METHOD, LinuxID, AIX_SUPPORT_METHOD,       \
                 AIXID)                                                         \
-  Name,
+  {Name},
 #include "llvm/TargetParser/PPCTargetParser.def"
 };
 
@@ -91,7 +91,7 @@ bool isValidCPU(StringRef CPU) {
 StringRef getNormalizedPPCTargetCPU(const Triple &T, StringRef CPUName) {
   if (!CPUName.empty()) {
     if (CPUName == "native") {
-      std::string CPU = std::string(sys::getHostCPUName());
+      StringRef CPU = sys::getHostCPUName();
       if (!CPU.empty() && CPU != "generic")
         return CPU;
     }


        


More information about the llvm-commits mailing list