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
18 changes: 12 additions & 6 deletions clang/include/clang/Analysis/ProgramPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ class ProgramPoint {

class BlockEntrance : public ProgramPoint {
public:
BlockEntrance(const CFGBlock *B, const LocationContext *L,
const ProgramPointTag *tag = nullptr)
: ProgramPoint(B, BlockEntranceKind, L, tag) {
assert(B && "BlockEntrance requires non-null block");
BlockEntrance(const CFGBlock *PrevBlock, const CFGBlock *CurrBlock,
const LocationContext *L, const ProgramPointTag *Tag = nullptr)
: ProgramPoint(CurrBlock, PrevBlock, BlockEntranceKind, L, Tag) {
assert(CurrBlock && "BlockEntrance requires non-null block");
}

const CFGBlock *getPreviousBlock() const {
return reinterpret_cast<const CFGBlock *>(getData2());
}

const CFGBlock *getBlock() const {
Expand Down Expand Up @@ -760,13 +764,15 @@ template <> struct DenseMapInfo<clang::ProgramPoint> {
static inline clang::ProgramPoint getEmptyKey() {
uintptr_t x =
reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
return clang::BlockEntrance(nullptr, reinterpret_cast<clang::CFGBlock *>(x),
nullptr);
}

static inline clang::ProgramPoint getTombstoneKey() {
uintptr_t x =
reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getTombstoneKey()) & ~0x7;
return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), nullptr);
return clang::BlockEntrance(nullptr, reinterpret_cast<clang::CFGBlock *>(x),
nullptr);
}

static unsigned getHashValue(const clang::ProgramPoint &Loc) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void CoreEngine::HandleBlockEdge(const BlockEdge &L, ExplodedNode *Pred) {

// Call into the ExprEngine to process entering the CFGBlock.
ExplodedNodeSet dstNodes;
BlockEntrance BE(Blk, Pred->getLocationContext());
BlockEntrance BE(L.getSrc(), L.getDst(), Pred->getLocationContext());
NodeBuilderWithSinks nodeBuilder(Pred, dstNodes, BuilderCtx, BE);
ExprEng.processCFGBlockEntrance(L, nodeBuilder, Pred);

Expand Down
11 changes: 6 additions & 5 deletions clang/test/Analysis/exploration_order/noexprcrash.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -analyzer-config exploration_strategy=unexplored_first %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -analyzer-config exploration_strategy=dfs %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify=common,ufirst -analyzer-config exploration_strategy=unexplored_first %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify=common,dfs -analyzer-config exploration_strategy=dfs %s

extern void clang_analyzer_eval(int);

typedef struct { char a; } b;
int c(b* input) {
int x = (input->a ?: input) ? 1 : 0; // expected-warning{{pointer/integer type mismatch}}
int x = (input->a ?: input) ? 1 : 0; // common-warning{{pointer/integer type mismatch}}
if (input->a) {
// FIXME: The value should actually be "TRUE",
// but is incorrect due to a bug.
clang_analyzer_eval(x); // expected-warning{{FALSE}}
// dfs-warning@+1 {{FALSE}} ufirst-warning@+1 {{TRUE}}
clang_analyzer_eval(x);
} else {
clang_analyzer_eval(x); // expected-warning{{TRUE}}
clang_analyzer_eval(x); // common-warning{{TRUE}}
}
return x;
}