[PATCH] D139720: [clang][PPC] Checking Unknown Values Passed to -mcpu

Jamie Schmeiser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 12 05:50:13 PST 2022


jamieschmeiser requested changes to this revision.
jamieschmeiser added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:54
+    auto TargetCPUName = llvm::StringSwitch<llvm::StringRef>(CPUName)
+                             .Case("common", "generic")
+                             .Case("440fp", "440")
----------------
This seems strange.  If the option is "generic", it calls getPPCGenericTargetCPU(), but if it is "common", it returns "generic."  I think you may want to also call getPPCGenericTargetCPU() here.  There should probably also be an assume where this returns that it didn't return "generic" if that is the intended result.  Also, there should also be tests for what happens when "generic" and "common" are specified.


================
Comment at: clang/lib/Driver/ToolChains/Arch/PPC.cpp:77
+                             .Default(CPUName);
+    return TargetCPUName.str();
   }
----------------
Why did you change the type from const char *?  Couldn't you use CPUName->data() in the default instead?  With your change, I think it may need to create StringRefs around all of the choices and then just get the string from them.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139720/new/

https://reviews.llvm.org/D139720



More information about the cfe-commits mailing list