r371226 - [NFCI] Unbreak buildbots

David Bolvansky via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 09:30:44 PDT 2019


Author: xbolva00
Date: Fri Sep  6 09:30:44 2019
New Revision: 371226

URL: http://llvm.org/viewvc/llvm-project?rev=371226&view=rev
Log:
[NFCI] Unbreak buildbots

Removed:
    cfe/trunk/test/Sema/div-sizeof-array.cpp
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371226&r1=371225&r2=371226&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep  6 09:30:44 2019
@@ -3391,10 +3391,6 @@ def note_pointer_declared_here : Note<
 def warn_division_sizeof_ptr : Warning<
   "'%0' will return the size of the pointer, not the array itself">,
   InGroup<DiagGroup<"sizeof-pointer-div">>;
-def warn_division_sizeof_array : Warning<
-  "expresion will return the incorrect number of elements in the array; the array "
-  "element type is %0, not %1">,
-  InGroup<DiagGroup<"sizeof-array-div">>;
 
 def note_function_warning_silence : Note<
     "prefix with the address-of operator to silence this warning">;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=371226&r1=371225&r2=371226&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep  6 09:30:44 2019
@@ -9154,29 +9154,17 @@ static void DiagnoseDivisionSizeofPointe
   else
     RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
 
-  if (LHSTy->isPointerType() && !RHSTy->isPointerType()) {
-    if (LHSTy->getPointeeType().getCanonicalType().getUnqualifiedType() !=
-        RHSTy.getCanonicalType().getUnqualifiedType())
-      return;
+  if (!LHSTy->isPointerType() || RHSTy->isPointerType())
+    return;
+  if (LHSTy->getPointeeType().getCanonicalType().getUnqualifiedType() !=
+      RHSTy.getCanonicalType().getUnqualifiedType())
+    return;
 
-    S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << LHS->getSourceRange();
-    if (const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
-      if (const ValueDecl *LHSArgDecl = DRE->getDecl())
-        S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
-            << LHSArgDecl;
-    }
-  } else if (isa<ArrayType>(LHSTy) && !RHSTy->isArrayType()) {
-    QualType ArrayElemTy = cast<ArrayType>(LHSTy)->getElementType();
-    if (isa<ArrayType>(ArrayElemTy) ||
-        ArrayElemTy.getCanonicalType().getUnqualifiedType() ==
-            RHSTy.getCanonicalType().getUnqualifiedType())
-      return;
-    S.Diag(Loc, diag::warn_division_sizeof_array) << ArrayElemTy << RHSTy;
-    if (const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
-      if (const ValueDecl *LHSArgDecl = DRE->getDecl())
-        S.Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
-            << LHSArgDecl;
-    }
+  S.Diag(Loc, diag::warn_division_sizeof_ptr) << LHS << LHS->getSourceRange();
+  if (const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
+    if (const ValueDecl *LHSArgDecl = DRE->getDecl())
+      S.Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
+          << LHSArgDecl;
   }
 }
 

Removed: cfe/trunk/test/Sema/div-sizeof-array.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/div-sizeof-array.cpp?rev=371225&view=auto
==============================================================================
--- cfe/trunk/test/Sema/div-sizeof-array.cpp (original)
+++ cfe/trunk/test/Sema/div-sizeof-array.cpp (removed)
@@ -1,26 +0,0 @@
-// RUN: %clang_cc1 %s -verify -Wsizeof-array-div -fsyntax-only
-
-template <typename Ty, int N>
-int f(Ty (&Array)[N]) {
-  return sizeof(Array) / sizeof(Ty); // Should not warn
-}
-
-typedef int int32;
-
-void test(void) {
-  int arr[12]; // expected-note 2 {{array 'arr' declared here}}
-  unsigned long long arr2[4]; // expected-note {{array 'arr2' declared here}}
-  int *p = &arr[0];
-  int a1 = sizeof(arr) / sizeof(*arr);
-  int a2 = sizeof arr / sizeof p;       // expected-warning {{expresion will return the incorrect number of elements in the array; the array element type is 'int', not 'int *'}}
-  int a4 = sizeof arr2 / sizeof p;      // expected-warning {{expresion will return the incorrect number of elements in the array; the array element type is 'unsigned long long', not 'int *'}}
-  int a5 = sizeof(arr) / sizeof(short); // expected-warning {{expresion will return the incorrect number of elements in the array; the array element type is 'int', not 'short'}}
-  int a6 = sizeof(arr) / sizeof(int32);
-  const char arr3[2] = "A";
-  int a7 = sizeof(arr3) / sizeof(char);
-
-  int arr4[10][12];
-  int b1 = sizeof(arr4) / sizeof(arr2[12]);
-  int b2 = sizeof(arr4) / sizeof(int *);
-  int b3 = sizeof(arr4) / sizeof(short *);
-}




More information about the cfe-commits mailing list