================ @@ -569,34 +569,39 @@ static bool checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall, // * When compiling for SVE only, the caller must be in non-streaming mode. // * When compiling for both SVE and SME, the caller can be in either mode. if (BuiltinType == SemaARM::VerifyRuntimeMode) { - llvm::StringMap<bool> CallerFeatureMapWithoutSVE; - S.Context.getFunctionFeatureMap(CallerFeatureMapWithoutSVE, FD); - CallerFeatureMapWithoutSVE["sve"] = false; + llvm::StringMap<bool> CallerFeatures; + S.Context.getFunctionFeatureMap(CallerFeatures, FD); // Avoid emitting diagnostics for a function that can never compile. - if (FnType == SemaARM::ArmStreaming && !CallerFeatureMapWithoutSVE["sme"]) + if (FnType == SemaARM::ArmStreaming && !CallerFeatures["sme"]) return false; - llvm::StringMap<bool> CallerFeatureMapWithoutSME; - S.Context.getFunctionFeatureMap(CallerFeatureMapWithoutSME, FD); - CallerFeatureMapWithoutSME["sme"] = false; + const auto FindTopLevelPipe = [](const char *S) { + unsigned Depth = 0; + unsigned I = 0, E = strlen(S); + for (; I < E; ++I) { + if (S[I] == '|' && Depth == 0) + break; + if (S[I] == '(') + ++Depth; + else if (S[I] == ')') + --Depth; + } + return I; + }; + + const char *RequiredFeatures = + S.Context.BuiltinInfo.getRequiredFeatures(BuiltinID); + unsigned PipeIdx = FindTopLevelPipe(RequiredFeatures); + assert(PipeIdx != 0 && PipeIdx != strlen(RequiredFeatures) && + "Expected feature string of the form 'SVE-EXPR|SME-EXPR'"); + StringRef NonStreamingBuiltinGuard = StringRef(RequiredFeatures, PipeIdx); + StringRef StreamingBuiltinGuard = StringRef(RequiredFeatures + PipeIdx + 1); ---------------- paulwalker-arm wrote:
This code comes from https://github.com/llvm/llvm-project/pull/145941, which I've now added you to. I'm not too familiar with `std::regex` so please forgive my ignorance but it seems to only support simple cases and specifically cannot handle nested brackets? The example given would fail when supplied with `sve(sve2|sve-hh)|sme(sve2|sme2)`? https://github.com/llvm/llvm-project/pull/147086 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits