[cfe-commits] r150869 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaOverload.cpp test/SemaCXX/attr-sentinel.cpp

Eli Friedman eli.friedman at gmail.com
Fri Feb 17 20:48:30 PST 2012


Author: efriedma
Date: Fri Feb 17 22:48:30 2012
New Revision: 150869

URL: http://llvm.org/viewvc/llvm-project?rev=150869&view=rev
Log:
Add a bunch of missing calls to DiagnoseSentinelCalls.  <rdar://problem/10885993>.

This should probably be refactored... but it isn't completely obvious what refactoring is best.


Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/attr-sentinel.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=150869&r1=150868&r2=150869&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 17 22:48:30 2012
@@ -8973,6 +8973,11 @@
                                         Proto, 0, Args, NumArgs, AllArgs, 
                                         CallType);
   ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
+
+  DiagnoseSentinelCalls(Constructor, Loc, AllArgs.data(), AllArgs.size());
+
+  // FIXME: Missing call to CheckFunctionCall or equivalent
+
   return Invalid;
 }
 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=150869&r1=150868&r2=150869&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Feb 17 22:48:30 2012
@@ -1228,6 +1228,11 @@
     NumPlaceArgs = AllPlaceArgs.size();
     if (NumPlaceArgs > 0)
       PlaceArgs = &AllPlaceArgs[0];
+
+    DiagnoseSentinelCalls(OperatorNew, PlacementLParen,
+                          PlaceArgs, NumPlaceArgs);
+
+    // FIXME: Missing call to CheckFunctionCall or equivalent
   }
 
   // Warn if the type is over-aligned and is being allocated by global operator

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=150869&r1=150868&r2=150869&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Feb 17 22:48:30 2012
@@ -10398,6 +10398,8 @@
                               RParenLoc))
     return ExprError();
 
+  DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
+
   if (CheckFunctionCall(Method, TheCall))
     return ExprError();
 
@@ -10701,6 +10703,8 @@
 
   if (IsError) return true;
 
+  DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
+
   if (CheckFunctionCall(Method, TheCall))
     return true;
 

Modified: cfe/trunk/test/SemaCXX/attr-sentinel.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-sentinel.cpp?rev=150869&r1=150868&r2=150869&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-sentinel.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-sentinel.cpp Fri Feb 17 22:48:30 2012
@@ -1,6 +1,23 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
 void f(int, ...) __attribute__((sentinel));
 
 void g() {
   f(1, 2, __null);
 }
+
+typedef __typeof__(sizeof(int)) size_t;
+
+struct S {
+  S(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+  void a(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+  void* operator new(size_t,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+  void operator()(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+};
+
+void class_test() {
+  S s(1,2,3); // expected-warning {{missing sentinel in function call}}
+  S* s2 = new (1,2,3) S(1, __null); // expected-warning {{missing sentinel in function call}}
+  s2->a(1,2,3); // expected-warning {{missing sentinel in function call}}
+  s(1,2,3); // expected-warning {{missing sentinel in function call}}
+}





More information about the cfe-commits mailing list