Skip to content

Commit

Permalink
[clang][analyzer] Fix #embed crash (#107764)
Browse files Browse the repository at this point in the history
Fix #107724.

(cherry picked from commit d84d955)
  • Loading branch information
nicovank authored and tru committed Sep 10, 2024
1 parent 5e1a55e commit bb79e7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,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
Expand Down Expand Up @@ -2430,10 +2431,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;
}
}

Expand Down
12 changes: 12 additions & 0 deletions clang/test/Analysis/embed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_analyze_cc1 -std=c23 -analyzer-checker=core,debug.ExprInspection -verify %s

void clang_analyzer_dump_ptr(const unsigned char *ptr);
void clang_analyzer_dump(unsigned char val);

int main() {
const unsigned char SelfBytes[] = {
#embed "embed.c"
};
clang_analyzer_dump_ptr(SelfBytes); // expected-warning {{&Element{SelfBytes,0 S64b,unsigned char}}}
clang_analyzer_dump(SelfBytes[0]); // expected-warning {{Unknown}} FIXME: This should be the `/` character.
}

0 comments on commit bb79e7f

Please sign in to comment.