diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -688,9 +688,9 @@ return &create(); } - if (Type->isReferenceType()) { + if (Type->isReferenceType() || Type->isPointerType()) { CreatedValuesCount++; - QualType PointeeType = Type->castAs()->getPointeeType(); + QualType PointeeType = Type->getPointeeType(); auto &PointeeLoc = createStorageLocation(PointeeType); if (Visited.insert(PointeeType.getCanonicalType()).second) { @@ -702,24 +702,10 @@ setValue(PointeeLoc, *PointeeVal); } - return &create(PointeeLoc); - } - - if (Type->isPointerType()) { - CreatedValuesCount++; - QualType PointeeType = Type->castAs()->getPointeeType(); - auto &PointeeLoc = createStorageLocation(PointeeType); - - if (Visited.insert(PointeeType.getCanonicalType()).second) { - Value *PointeeVal = createValueUnlessSelfReferential( - PointeeType, Visited, Depth, CreatedValuesCount); - Visited.erase(PointeeType.getCanonicalType()); - - if (PointeeVal != nullptr) - setValue(PointeeLoc, *PointeeVal); - } - - return &create(PointeeLoc); + if (Type->isReferenceType()) + return &create(PointeeLoc); + else + return &create(PointeeLoc); } if (Type->isStructureOrClassType() || Type->isUnionType()) {