Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ class SMTConv {
if (APSIntBitwidth == 1 && Ty.isNull())
return {Int.extend(Ctx.getTypeSize(Ctx.BoolTy)),
getAPSIntType(Ctx, NewInt)};
else if (APSIntBitwidth == 1 && !Ty.isNull())
return {Int.extend(Ctx.getTypeSize(getAPSIntType(Ctx, Int))),
getAPSIntType(Ctx, NewInt)};
Comment on lines 598 to +603
Copy link
Contributor

@NagyDonat NagyDonat Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (APSIntBitwidth == 1 && Ty.isNull())
return {Int.extend(Ctx.getTypeSize(Ctx.BoolTy)),
getAPSIntType(Ctx, NewInt)};
else if (APSIntBitwidth == 1 && !Ty.isNull())
return {Int.extend(Ctx.getTypeSize(getAPSIntType(Ctx, Int))),
getAPSIntType(Ctx, NewInt)};
if (APSIntBitwidth == 1) {
if (Ty.isNull())
return {Int.extend(Ctx.getTypeSize(Ctx.BoolTy)),
getAPSIntType(Ctx, NewInt)};
return {Int.extend(Ctx.getTypeSize(getAPSIntType(Ctx, Int))),
getAPSIntType(Ctx, NewInt)};
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to not have redundant "else" after having a "return".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks, I edited my suggestion.

if (llvm::isPowerOf2_32(APSIntBitwidth) || Ty.isNull())
return {Int, Ty};
return {Int.extend(Ctx.getTypeSize(Ty)), Ty};
Expand Down
10 changes: 4 additions & 6 deletions clang/test/Analysis/PR37855.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -w -analyzer-config crosscheck-with-z3=true -verify %s
// REQUIRES: z3

// XFAIL: *

typedef struct o p;
struct o {
struct {
} s;
};

void q(*r, p2) { r < p2; }
void q(int *r, int p2) { r < p2; }

void k(l, node) {
void k(int l, int node) {
struct {
p *node;
} * n, *nodep, path[sizeof(void)];
path->node = l;
path->node = (p*) l;
for (n = path; node != l;) {
q(node, n->node);
q((int *)&node, (int)n->node);
nodep = n;
}
if (nodep) // expected-warning {{Branch condition evaluates to a garbage value}}
Expand Down
2 changes: 0 additions & 2 deletions clang/test/Analysis/z3-crosscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s
// REQUIRES: z3

// XFAIL: *

void clang_analyzer_dump(float);

int foo(int x)
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Support/Z3Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ class Z3Statistics final : public SMTSolverStatistics {
};
unsigned getUnsigned(StringRef Key) const override {
auto It = UnsignedValues.find(Key.str());
assert(It != UnsignedValues.end());
if (It == UnsignedValues.end())
return 0;
Comment on lines +935 to +936
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this assertion fail? I thought the "rlimit" must exist on the required Z3 versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vabridgers Could you investigate this question?

return It->second;
};

Expand Down
Loading