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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119340 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 83d7c07..bce28c2 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -1090,12 +1090,16 @@
   // 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.