This is reasonable because people know what they are doing when they
intentionally dereference the pointer.
So now we only emit warning when a pointer variable is use literally.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86673
91177308-0d34-0410-b5e6-
96231b3b80d8
QualType T = E->getTypeOfArgument();
if (T->isPointerType()) {
- SourceRange R = E->getArgumentExpr()->getSourceRange();
+
+ // Many false positives have the form 'sizeof *p'. This is reasonable
+ // because people know what they are doing when they intentionally
+ // dereference the pointer.
+ Expr *ArgEx = E->getArgumentExpr();
+ if (!isa<DeclRefExpr>(ArgEx))
+ return;
+
+ SourceRange R = ArgEx->getSourceRange();
BR.EmitBasicReport("Potential unintended use of sizeof() on pointer type",
"Logic",
"The code calls sizeof() on a pointer type. "