[clang] [RISCV] Fix collectNonISAExtFeature returning negative extension features (PR #76962)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 15:42:00 PST 2024


================
@@ -237,22 +237,15 @@ ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const {
 
 static std::vector<std::string>
 collectNonISAExtFeature(ArrayRef<std::string> FeaturesNeedOverride, int XLen) {
-  auto ParseResult =
-      llvm::RISCVISAInfo::parseFeatures(XLen, FeaturesNeedOverride);
-
-  if (!ParseResult) {
-    consumeError(ParseResult.takeError());
-    return std::vector<std::string>();
-  }
-
-  std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector();
-
   std::vector<std::string> NonISAExtFeatureVec;
 
+  auto IsNonISAExtFeature = [](const std::string &Feature) {
+    assert(Feature.size() > 1 && (Feature[0] == '+' || Feature[0] == '-'));
+    std::string Ext = Feature.substr(1); // drop the +/-
----------------
topperc wrote:

`StringRef Ext = StringRef(Feature).drop_front()` we don't need to allocate a new std::string

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


More information about the cfe-commits mailing list