Skip to content

Commit

Permalink
Merge pull request checkedc#1196 from Arunkumar1998BOM/main
Browse files Browse the repository at this point in the history
Fix for Issue checkedc#1195 

Reason for the error:

typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = clang::Expr; Y = const clang::Stmt; typename llvm::cast_retty<X, Y*>::ret_type = const clang::Expr*] caused an assertion:

Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Description of Fix:
I have a fix I believe involves the least changes, so as to disturb the main line as little as possible.

Regression CheckedC Testing:

Testing Time: 14.53s
  Unsupported:  3
  Passed     : 96

Regression testing:

Ran clang tests:
Failed Tests (3):
  Clang :: 3C/json_formatting.c
  Clang :: 3C/json_formatting_backslash.c
  Clang :: 3C/multiple_tu.c


Testing Time: 2095.93s
  Unsupported      :    75
  Passed           : 27663
  Expectedly Failed:    34
  Failed           :     3


The above 3 tests also failed for me on an "untouched" main-branch.
  • Loading branch information
dtarditi authored Dec 16, 2022
2 parents 9af6e1a + 4e830b0 commit ebf531a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5965,6 +5965,10 @@ const Expr *CFGBlock::getLastCondition() const {
if (isa<ObjCForCollectionStmt>(Cond) || isa<DeclStmt>(Cond))
return nullptr;

// Introduced as a fix for crash --> #1195
if (!isa<Expr>(Cond))
return nullptr;

// Only ObjCForCollectionStmt is known not to be a non-Expr terminator, hence
// the cast<>.
return cast<Expr>(Cond)->IgnoreParens();
Expand Down

0 comments on commit ebf531a

Please sign in to comment.