[clang] [clang][analyzer] Fix #embed crash (PR #107764)
Nicolas van Kempen via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 8 08:54:47 PDT 2024
https://github.com/nicovank created https://github.com/llvm/llvm-project/pull/107764
Fix #107724.
>From a43b9b74ac253c0072498007cf56ed57d8255143 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen <nvankemp at gmail.com>
Date: Sun, 8 Sep 2024 11:52:28 -0400
Subject: [PATCH] [clang][analyzer] Fix #embed crash
Fix #107724.
---
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 5 +----
clang/test/Analysis/embed.c | 9 +++++++++
2 files changed, 10 insertions(+), 4 deletions(-)
create mode 100644 clang/test/Analysis/embed.c
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 315d85319a85a9..fdabba46992b08 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1938,6 +1938,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXRewrittenBinaryOperatorClass:
case Stmt::RequiresExprClass:
case Expr::CXXParenListInitExprClass:
+ case Stmt::EmbedExprClass:
// Fall through.
// Cases we intentionally don't evaluate, since they don't need
@@ -2440,10 +2441,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
Bldr.addNodes(Dst);
break;
}
-
- case Stmt::EmbedExprClass:
- llvm::report_fatal_error("Support for EmbedExpr is not implemented.");
- break;
}
}
diff --git a/clang/test/Analysis/embed.c b/clang/test/Analysis/embed.c
new file mode 100644
index 00000000000000..7201bb30386fb7
--- /dev/null
+++ b/clang/test/Analysis/embed.c
@@ -0,0 +1,9 @@
+// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+int main() {
+ const unsigned char SelfBytes[] = {
+ #embed "embed.c"
+ };
+}
More information about the cfe-commits
mailing list