|
9 | 9 |
|
10 | 10 | #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h" |
11 | 11 |
|
12 | | -#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h" |
13 | | -#include "phasar/DataFlow/IfdsIde/FlowFunctions.h" |
14 | 12 | #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h" |
15 | | -#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" |
16 | 13 | #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFlowFunctions.h" |
17 | 14 | #include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h" |
18 | 15 | #include "phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/TypeStateDescriptions/TypeStateDescription.h" |
|
21 | 18 | #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" |
22 | 19 | #include "phasar/Utils/Logger.h" |
23 | 20 |
|
24 | | -#include "llvm/ADT/DenseMap.h" |
25 | 21 | #include "llvm/Demangle/Demangle.h" |
26 | | -#include "llvm/IR/AbstractCallSite.h" |
| 22 | +#include "llvm/IR/DebugInfoMetadata.h" |
27 | 23 | #include "llvm/IR/Function.h" |
28 | 24 | #include "llvm/IR/Instruction.h" |
| 25 | +#include "llvm/IR/Instructions.h" |
| 26 | +#include "llvm/IR/Metadata.h" |
29 | 27 | #include "llvm/IR/Value.h" |
30 | 28 | #include "llvm/Support/Casting.h" |
31 | 29 | #include "llvm/Support/ErrorHandling.h" |
32 | 30 | #include "llvm/Support/raw_ostream.h" |
33 | 31 |
|
34 | | -#include <algorithm> |
35 | 32 | #include <utility> |
36 | 33 |
|
37 | 34 | namespace psr::detail { |
@@ -284,59 +281,23 @@ auto IDETypeStateAnalysisBase::getLocalAliasesAndAllocas( |
284 | 281 | return AliasAndAllocas; |
285 | 282 | } |
286 | 283 |
|
287 | | -bool IDETypeStateAnalysisBase::hasMatchingTypeName(const llvm::Type *Ty) { |
288 | | - if (const auto *StructTy = llvm::dyn_cast<llvm::StructType>(Ty); |
289 | | - StructTy && StructTy->hasName()) { |
290 | | - return isTypeNameOfInterest(StructTy->getName()); |
| 284 | +bool IDETypeStateAnalysisBase::hasMatchingTypeName(const llvm::DIType *DITy) { |
| 285 | + if (llvm::isa<llvm::DICompositeType>(DITy) && !DITy->getName().empty()) { |
| 286 | + return isTypeNameOfInterest(DITy->getName()); |
291 | 287 | } |
292 | | - // primitive type |
293 | | - std::string Str; |
294 | | - llvm::raw_string_ostream S(Str); |
295 | | - S << *Ty; |
296 | | - S.flush(); |
297 | | - return isTypeNameOfInterest(Str); |
| 288 | + |
| 289 | + return true; // Conservatively return true |
298 | 290 | } |
299 | 291 |
|
300 | 292 | bool IDETypeStateAnalysisBase::hasMatchingType(d_t V) { |
301 | | - // General case |
302 | | - if (V->getType()->isPointerTy() && !V->getType()->isOpaquePointerTy()) { |
303 | | - if (hasMatchingTypeName(V->getType()->getNonOpaquePointerElementType())) { |
304 | | - return true; |
305 | | - } |
306 | | - // fallthrough |
307 | | - } |
308 | | - if (const auto *Alloca = llvm::dyn_cast<llvm::AllocaInst>(V)) { |
309 | | - if (Alloca->getAllocatedType()->isPointerTy()) { |
310 | | - if (Alloca->getAllocatedType()->isOpaquePointerTy() || |
311 | | - hasMatchingTypeName( |
312 | | - Alloca->getAllocatedType()->getNonOpaquePointerElementType())) { |
313 | | - return true; |
314 | | - } |
315 | | - } |
316 | | - return false; |
317 | | - } |
318 | | - if (const auto *Load = llvm::dyn_cast<llvm::LoadInst>(V)) { |
319 | | - if (Load->getType()->isPointerTy()) { |
320 | | - if (Load->getType()->isOpaquePointerTy() || |
321 | | - hasMatchingTypeName( |
322 | | - Load->getType()->getNonOpaquePointerElementType())) { |
323 | | - return true; |
324 | | - } |
| 293 | + if (const auto *VarTy = getVarTypeFromIR(V)) { |
| 294 | + if (const auto *BaseTy = stripPointerTypes(VarTy)) { |
| 295 | + return hasMatchingTypeName(BaseTy); |
325 | 296 | } |
326 | | - return false; |
327 | | - } |
328 | | - if (const auto *Store = llvm::dyn_cast<llvm::StoreInst>(V)) { |
329 | | - if (Store->getValueOperand()->getType()->isPointerTy()) { |
330 | | - if (Store->getValueOperand()->getType()->isOpaquePointerTy() || |
331 | | - hasMatchingTypeName(Store->getValueOperand() |
332 | | - ->getType() |
333 | | - ->getNonOpaquePointerElementType())) { |
334 | | - return true; |
335 | | - } |
336 | | - } |
337 | | - return false; |
| 297 | + |
| 298 | + return isTypeNameOfInterest(VarTy->getName()); |
338 | 299 | } |
339 | | - return false; |
340 | | -} |
341 | 300 |
|
| 301 | + return true; |
| 302 | +} |
342 | 303 | } // namespace psr::detail |
0 commit comments