From: Artem Dergachev Date: Wed, 29 Aug 2018 22:57:52 +0000 (+0000) Subject: [analyzer] Document that pointer arithmetic is not represented by SymExprs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd078dd963454a4f87a96c950d07ef00b30ff8ec;p=clang [analyzer] Document that pointer arithmetic is not represented by SymExprs. Add assertions to verify that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340990 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h index a82559238d..264f011c3c 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -763,7 +763,9 @@ class SymbolicRegion : public SubRegion { SymbolicRegion(const SymbolRef s, const MemSpaceRegion *sreg) : SubRegion(sreg, SymbolicRegionKind), sym(s) { - assert(s); + // Because pointer arithmetic is represented by ElementRegion layers, + // the base symbol here should not contain any arithmetic. + assert(s && isa(s)); assert(s->getType()->isAnyPointerType() || s->getType()->isReferenceType() || s->getType()->isBlockPointerType()); diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h index 0745519626..888ebc214f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h @@ -309,7 +309,10 @@ protected: BinarySymExpr(Kind k, BinaryOperator::Opcode op, QualType t) : SymExpr(k), Op(op), T(t) { assert(classof(this)); - assert(isValidTypeForSymbol(t)); + // Binary expressions are results of arithmetic. Pointer arithmetic is not + // handled by binary expressions, but it is instead handled by applying + // sub-regions to regions. + assert(isValidTypeForSymbol(t) && !Loc::isLocType(t)); } public: