summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-08-29 22:57:52 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-08-29 22:57:52 +0000
commitcdf918fc7188236618ee7aade6a0e741148824df (patch)
tree75c8a0ad49681f2d4a16a0b032d1fb62724dfcb2
parenta050a8da032e56b7fe37c58bf73d5db5ab0ac5a0 (diff)
downloadbcm5719-llvm-cdf918fc7188236618ee7aade6a0e741148824df.tar.gz
bcm5719-llvm-cdf918fc7188236618ee7aade6a0e741148824df.zip
[analyzer] Document that pointer arithmetic is not represented by SymExprs.
Add assertions to verify that. llvm-svn: 340990
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h4
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h5
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index a82559238df..264f011c3cb 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/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<SymbolData>(s));
assert(s->getType()->isAnyPointerType() ||
s->getType()->isReferenceType() ||
s->getType()->isBlockPointerType());
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
index 07455196260..888ebc214fd 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ b/clang/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:
OpenPOWER on IntegriCloud