Skip to content

Commit d84d955

Browse files
authored
[clang][analyzer] Fix #embed crash (#107764)
Fix #107724.
1 parent 09c00b6 commit d84d955

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
19381938
case Stmt::CXXRewrittenBinaryOperatorClass:
19391939
case Stmt::RequiresExprClass:
19401940
case Expr::CXXParenListInitExprClass:
1941+
case Stmt::EmbedExprClass:
19411942
// Fall through.
19421943

19431944
// Cases we intentionally don't evaluate, since they don't need
@@ -2440,10 +2441,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
24402441
Bldr.addNodes(Dst);
24412442
break;
24422443
}
2443-
2444-
case Stmt::EmbedExprClass:
2445-
llvm::report_fatal_error("Support for EmbedExpr is not implemented.");
2446-
break;
24472444
}
24482445
}
24492446

clang/test/Analysis/embed.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s
2+
3+
void clang_analyzer_dump_ptr(const unsigned char *ptr);
4+
void clang_analyzer_dump(unsigned char val);
5+
6+
int main() {
7+
const unsigned char SelfBytes[] = {
8+
#embed "embed.c"
9+
};
10+
clang_analyzer_dump_ptr(SelfBytes); // expected-warning {{&Element{SelfBytes,0 S64b,unsigned char}}}
11+
clang_analyzer_dump(SelfBytes[0]); // expected-warning {{Unknown}} FIXME: This should be the `/` character.
12+
}

0 commit comments

Comments
 (0)