aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorPavel Iliin <Pavel.Iliin@arm.com>2024-03-01 10:12:19 +0000
committerGitHub <noreply@github.com>2024-03-01 10:12:19 +0000
commit185b1df1b1f7bd88ff0159bc51d5ddaeca27106a (patch)
tree27111cf7acc892d44fb805d26a3a2a86792f4e03 /clang/lib/Sema/SemaChecking.cpp
parent195744cca7fd7f1b33971e0f2cf07b8ae47f16b5 (diff)
downloadllvm-185b1df1b1f7bd88ff0159bc51d5ddaeca27106a.zip
llvm-185b1df1b1f7bd88ff0159bc51d5ddaeca27106a.tar.gz
llvm-185b1df1b1f7bd88ff0159bc51d5ddaeca27106a.tar.bz2
[X86][AArch64][PowerPC] __builtin_cpu_supports accepts unknown options. (#83515)
The patch fixes https://github.com/llvm/llvm-project/issues/83407 modifing __builtin_cpu_supports behaviour so that it returns false if unsupported features names provided in parameter and issue a warning. __builtin_cpu_supports is target independent, but currently supported by X86, AArch64 and PowerPC only.
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 690bdaa..7be2b31 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2180,9 +2180,11 @@ static bool SemaBuiltinCpu(Sema &S, const TargetInfo &TI, CallExpr *TheCall,
// Check the contents of the string.
StringRef Feature = cast<StringLiteral>(Arg)->getString();
- if (IsCPUSupports && !TheTI->validateCpuSupports(Feature))
- return S.Diag(TheCall->getBeginLoc(), diag::err_invalid_cpu_supports)
- << Arg->getSourceRange();
+ if (IsCPUSupports && !TheTI->validateCpuSupports(Feature)) {
+ S.Diag(TheCall->getBeginLoc(), diag::warn_invalid_cpu_supports)
+ << Arg->getSourceRange();
+ return false;
+ }
if (!IsCPUSupports && !TheTI->validateCpuIs(Feature))
return S.Diag(TheCall->getBeginLoc(), diag::err_invalid_cpu_is)
<< Arg->getSourceRange();