[clang] [Clang] add support for handling assume attributes (PR #101063)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 29 11:56:14 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 13996378d81c8fa9a364aeaafd7382abbc1db83a 97de745341dfc17e7ad9c595d239346a9114a4c6 --extensions cpp -- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
index 1a4eb88fb6..8ab8b97d8e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -83,23 +83,23 @@ bool BuiltinFunctionChecker::evalCall(const CallEvent &Call,
const Expr *CE = Call.getOriginExpr();
if (const auto *AttrStmt = dyn_cast<AttributedStmt>(CE)) {
- for (const Attr *I : AttrStmt->getAttrs()) {
- if (const auto *AssumeAttr = dyn_cast<CXXAssumeAttr>(I)) {
- const Expr *AssumeExpr = AssumeAttr->getAssumption();
- SVal Arg = C.getSVal(AssumeExpr);
- if (Arg.isUndef())
- return true;
-
- state = state->assume(Arg.castAs<DefinedOrUnknownSVal>(), true);
- if (!state) {
- C.generateSink(C.getState(), C.getPredecessor());
- return true;
- }
-
- C.addTransition(state);
- return true;
- }
+ for (const Attr *I : AttrStmt->getAttrs()) {
+ if (const auto *AssumeAttr = dyn_cast<CXXAssumeAttr>(I)) {
+ const Expr *AssumeExpr = AssumeAttr->getAssumption();
+ SVal Arg = C.getSVal(AssumeExpr);
+ if (Arg.isUndef())
+ return true;
+
+ state = state->assume(Arg.castAs<DefinedOrUnknownSVal>(), true);
+ if (!state) {
+ C.generateSink(C.getState(), C.getPredecessor());
+ return true;
+ }
+
+ C.addTransition(state);
+ return true;
}
+ }
}
if (isBuiltinLikeFunction(Call)) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/101063
More information about the cfe-commits
mailing list