]> granicus.if.org Git - clang/commitdiff
[analyzer] Document that pointer arithmetic is not represented by SymExprs.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 29 Aug 2018 22:57:52 +0000 (22:57 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 29 Aug 2018 22:57:52 +0000 (22:57 +0000)
Add assertions to verify that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340990 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h

index a82559238df599d563ccf5dcab7e105143873ec0..264f011c3cbe2a637cf5049e143bbc575ac19bd1 100644 (file)
@@ -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<SymbolData>(s));
     assert(s->getType()->isAnyPointerType() ||
            s->getType()->isReferenceType() ||
            s->getType()->isBlockPointerType());
index 07455196260746147a018dab62a3ac4b0a0aee83..888ebc214fd4c6293415e029b3e6f74e2cd6f228 100644 (file)
@@ -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: