summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-11-16 08:49:43 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-11-16 08:49:43 +0000
commit1c8383dccd4729f6e35982a82601f1985267e127 (patch)
tree958df6414688618bbf80555dca0ead09b8373673 /clang/lib
parent743682bb9f6646f5574a6b0e152db62ba33f9e9c (diff)
downloadbcm5719-llvm-1c8383dccd4729f6e35982a82601f1985267e127.tar.gz
bcm5719-llvm-1c8383dccd4729f6e35982a82601f1985267e127.zip
Fix PR8625 and correctly interpret member-calls to static members when
producing warnings. This feels really fragile, and I've not audited all other argument index-based warnings. I suspect we'll grow this bug on another warning eventually. It might be nice to adjust the argument indices when building up the attribute AST node, as we already have to remember about the 'this' argument within that code to produce correct errors. llvm-svn: 119340
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 83d7c0760ef..bce28c2c91d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1090,12 +1090,16 @@ Sema::CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
// of member functions is counted. However, it doesn't appear in our own
// lists, so decrement format_idx in that case.
if (isa<CXXMemberCallExpr>(TheCall)) {
- // Catch a format attribute mistakenly referring to the object argument.
- if (format_idx == 0)
- return;
- --format_idx;
- if(firstDataArg != 0)
- --firstDataArg;
+ const CXXMethodDecl *method_decl =
+ dyn_cast<CXXMethodDecl>(TheCall->getCalleeDecl());
+ if (method_decl && method_decl->isInstance()) {
+ // Catch a format attribute mistakenly referring to the object argument.
+ if (format_idx == 0)
+ return;
+ --format_idx;
+ if(firstDataArg != 0)
+ --firstDataArg;
+ }
}
// CHECK: printf/scanf-like function is called with no format string.
OpenPOWER on IntegriCloud