|
This patch refactors the pointer arithmetic checking into a single place in SemaExpr.cpp. It provides two interfaces, one for checking a single pointer operand, one for checking both operands of a binary operator. The second interface goes to some lengths to DTRT for a mixture of good and bad operands on the LHS or RHS.
It also cleans up several aspects of the accompanying diagnostics to be more clearly worded, and provide more information when diagnosing (for example) both the LHS and RHS of a binary operator. It also makes the types shown be consistently shown as the pointee types instead of pointer types.
There is still a fair amount of cleanup I'd like to do here, potentially either simplifying some code, hooking up more clients to the code, and/or lifting more common checking into these routines. This should also help pave the way for a more principled place to perform warnings such as the NULL-pointer arithmetic warnings.
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+175 lines, -152 lines) |
Patch |
|
M |
include/clang/Basic/DiagnosticSemaKinds.td
|
View
|
|
2 chunks |
+9 lines, -5 lines |
0 comments
|
Download
|
|
M |
lib/Sema/SemaExpr.cpp
|
View
|
|
8 chunks |
+145 lines, -126 lines |
0 comments
|
Download
|
|
M |
test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
test/Sema/incomplete-decl.c
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
test/Sema/pointer-addition.c
|
View
|
|
1 chunk |
+13 lines, -13 lines |
0 comments
|
Download
|
|
M |
test/Sema/pointer-subtract-compat.c
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
test/Sema/typecheck-binop.c
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
test/SemaCXX/null_in_arithmetic_ops.cpp
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
test/SemaObjC/sizeof-interface.m
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|