lijiansong / clang-llvm-tutorial

clang & llvm examples, e.g. AST Interpreter, Function Pointer Analysis, Value Range Analysis, Data-Flow Analysis, Andersen Pointer Analysis, LLVM Backend...
Do What The F*ck You Want To Public License
263 stars 55 forks source link

Handle getCondition() method of BranchInst #3

Open BowenZhang-UST opened 1 year ago

BowenZhang-UST commented 1 year ago

Commit

Latest Main

Location

Description

At Line 234, the condition of the BranchInst is dynamically casted into ICmpInst. However, the condition is not always ICmpInst. For example, it could be a CastInst which casts an i32 into an i1. In this case, the variable cmpInst would be null and a NPD will happen at line 236.

image

At Line 1092, the situation is similar.

Proposed Fix

guard this dyn_cast with a if

wang-shijie commented 1 year ago

已到,i will reply it later