[clang] [Clang][RISCV] Recognize unsupport target feature by supporting... (PR #106495)

Piyou Chen via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 29 00:07:27 PDT 2024


================
@@ -391,7 +391,14 @@ void RISCVTargetInfo::fillValidTuneCPUList(
 
 static void handleFullArchString(StringRef FullArchStr,
                                  std::vector<std::string> &Features) {
-  Features.push_back("__RISCV_TargetAttrNeedOverride");
+
+  // Should be full arch string.
+  if (!FullArchStr.starts_with("rv")) {
+    Features.push_back(FullArchStr.str());
----------------
BeMg wrote:

Sorry for the imprecise comment. The behavior is as follows: when the input FullArchStr is invalid, it is simply passed to the next stage. The `checkTargetAttr` function will handle the invalid arch string and emit the corresponding warning.

For example, `int __attribute__((target("arch=zba")))`.

I think the comment could be rewrite as `reject the invalid FullArchStr`. 

https://github.com/llvm/llvm-project/pull/106495


More information about the cfe-commits mailing list