Skip to content

Commit d5ffc1e

Browse files
author
Balazs Benics
committed
[analyzer][NFC] Tighten some of the SValBuilder return types
This is purely a cosmetic change. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D125463
1 parent e52e1da commit d5ffc1e

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class SValBuilder {
106106
/// \param CastTy -- QualType, which `V` shall be cast to.
107107
/// \return SVal with simplified cast expression.
108108
/// \note: Currently only support integral casts.
109-
SVal simplifySymbolCast(nonloc::SymbolVal V, QualType CastTy);
109+
nonloc::SymbolVal simplifySymbolCast(nonloc::SymbolVal V, QualType CastTy);
110110

111111
public:
112112
SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context,
@@ -340,17 +340,19 @@ class SValBuilder {
340340
return nonloc::LocAsInteger(BasicVals.getPersistentSValWithData(loc, bits));
341341
}
342342

343-
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
344-
const llvm::APSInt& rhs, QualType type);
343+
nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
344+
const llvm::APSInt &rhs, QualType type);
345345

346-
NonLoc makeNonLoc(const llvm::APSInt& rhs, BinaryOperator::Opcode op,
347-
const SymExpr *lhs, QualType type);
346+
nonloc::SymbolVal makeNonLoc(const llvm::APSInt &rhs,
347+
BinaryOperator::Opcode op, const SymExpr *lhs,
348+
QualType type);
348349

349-
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
350-
const SymExpr *rhs, QualType type);
350+
nonloc::SymbolVal makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
351+
const SymExpr *rhs, QualType type);
351352

352353
/// Create a NonLoc value for cast.
353-
NonLoc makeNonLoc(const SymExpr *operand, QualType fromTy, QualType toTy);
354+
nonloc::SymbolVal makeNonLoc(const SymExpr *operand, QualType fromTy,
355+
QualType toTy);
354356

355357
nonloc::ConcreteInt makeTruthVal(bool b, QualType type) {
356358
return nonloc::ConcreteInt(BasicVals.getTruthValue(b, type));
@@ -363,7 +365,7 @@ class SValBuilder {
363365
/// Create NULL pointer, with proper pointer bit-width for given address
364366
/// space.
365367
/// \param type pointer type.
366-
Loc makeNullWithType(QualType type) {
368+
loc::ConcreteInt makeNullWithType(QualType type) {
367369
// We cannot use the `isAnyPointerType()`.
368370
assert((type->isPointerType() || type->isObjCObjectPointerType() ||
369371
type->isBlockPointerType() || type->isNullPtrType() ||
@@ -379,19 +381,19 @@ class SValBuilder {
379381
return loc::ConcreteInt(BasicVals.getZeroWithTypeSize(type));
380382
}
381383

382-
Loc makeLoc(SymbolRef sym) {
384+
loc::MemRegionVal makeLoc(SymbolRef sym) {
383385
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
384386
}
385387

386-
Loc makeLoc(const MemRegion* region) {
388+
loc::MemRegionVal makeLoc(const MemRegion *region) {
387389
return loc::MemRegionVal(region);
388390
}
389391

390-
Loc makeLoc(const AddrLabelExpr *expr) {
392+
loc::GotoLabel makeLoc(const AddrLabelExpr *expr) {
391393
return loc::GotoLabel(expr->getLabel());
392394
}
393395

394-
Loc makeLoc(const llvm::APSInt& integer) {
396+
loc::ConcreteInt makeLoc(const llvm::APSInt &integer) {
395397
return loc::ConcreteInt(BasicVals.getValue(integer));
396398
}
397399

@@ -402,7 +404,7 @@ class SValBuilder {
402404
/// Make an SVal that represents the given symbol. This follows the convention
403405
/// of representing Loc-type symbols (symbolic pointers and references)
404406
/// as Loc values wrapping the symbol rather than as plain symbol values.
405-
SVal makeSymbolVal(SymbolRef Sym) {
407+
DefinedSVal makeSymbolVal(SymbolRef Sym) {
406408
if (Loc::isLocType(Sym->getType()))
407409
return makeLoc(Sym);
408410
return nonloc::SymbolVal(Sym);

clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ DefinedOrUnknownSVal SValBuilder::makeZeroVal(QualType type) {
7474
return UnknownVal();
7575
}
7676

77-
NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
78-
const llvm::APSInt& rhs, QualType type) {
77+
nonloc::SymbolVal SValBuilder::makeNonLoc(const SymExpr *lhs,
78+
BinaryOperator::Opcode op,
79+
const llvm::APSInt &rhs,
80+
QualType type) {
7981
// The Environment ensures we always get a persistent APSInt in
8082
// BasicValueFactory, so we don't need to get the APSInt from
8183
// BasicValueFactory again.
@@ -84,23 +86,24 @@ NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
8486
return nonloc::SymbolVal(SymMgr.getSymIntExpr(lhs, op, rhs, type));
8587
}
8688

87-
NonLoc SValBuilder::makeNonLoc(const llvm::APSInt& lhs,
88-
BinaryOperator::Opcode op, const SymExpr *rhs,
89-
QualType type) {
89+
nonloc::SymbolVal SValBuilder::makeNonLoc(const llvm::APSInt &lhs,
90+
BinaryOperator::Opcode op,
91+
const SymExpr *rhs, QualType type) {
9092
assert(rhs);
9193
assert(!Loc::isLocType(type));
9294
return nonloc::SymbolVal(SymMgr.getIntSymExpr(lhs, op, rhs, type));
9395
}
9496

95-
NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
96-
const SymExpr *rhs, QualType type) {
97+
nonloc::SymbolVal SValBuilder::makeNonLoc(const SymExpr *lhs,
98+
BinaryOperator::Opcode op,
99+
const SymExpr *rhs, QualType type) {
97100
assert(lhs && rhs);
98101
assert(!Loc::isLocType(type));
99102
return nonloc::SymbolVal(SymMgr.getSymSymExpr(lhs, op, rhs, type));
100103
}
101104

102-
NonLoc SValBuilder::makeNonLoc(const SymExpr *operand,
103-
QualType fromTy, QualType toTy) {
105+
nonloc::SymbolVal SValBuilder::makeNonLoc(const SymExpr *operand,
106+
QualType fromTy, QualType toTy) {
104107
assert(operand);
105108
assert(!Loc::isLocType(toTy));
106109
return nonloc::SymbolVal(SymMgr.getCastSymbol(operand, fromTy, toTy));
@@ -563,8 +566,7 @@ SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val,
563566
std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
564567
if (!IsNotTruncated && IsTruncated) {
565568
// Symbol is truncated so we evaluate it as a cast.
566-
NonLoc CastVal = makeNonLoc(se, originalTy, castTy);
567-
return CastVal;
569+
return makeNonLoc(se, originalTy, castTy);
568570
}
569571
return evalCast(val, castTy, originalTy);
570572
}
@@ -1009,7 +1011,7 @@ SVal SValBuilder::evalCastSubKind(nonloc::PointerToMember V, QualType CastTy,
10091011
return V;
10101012
}
10111013

1012-
SVal clang::ento::SValBuilder::simplifySymbolCast(nonloc::SymbolVal V,
1014+
nonloc::SymbolVal SValBuilder::simplifySymbolCast(nonloc::SymbolVal V,
10131015
QualType CastTy) {
10141016
// We use seven conditions to recognize a simplification case.
10151017
// For the clarity let `CastTy` be `C`, SE->getType() - `T`, root type - `R`,

0 commit comments

Comments
 (0)