[PATCH] D83966: Enable the test for hasArraySize() in all language modes

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 16 10:07:30 PDT 2020


gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In C++11 and later Clang generates an implicit conversion from int to
size_t in the AST.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83966

Files:
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -3219,13 +3219,13 @@
 }
 
 TEST_P(ASTMatchersTest, HasArraySize) {
-  if (GetParam().Language != Lang_CXX03) {
-    // FIXME: Fix this test to work in all C++ language modes.
+  if (!GetParam().isCXX()) {
     return;
   }
 
   EXPECT_TRUE(matches("struct MyClass {}; MyClass *p1 = new MyClass[10];",
-                      cxxNewExpr(hasArraySize(integerLiteral(equals(10))))));
+                      cxxNewExpr(hasArraySize(
+                          ignoringParenImpCasts(integerLiteral(equals(10)))))));
 }
 
 TEST_P(ASTMatchersTest, HasDefinition_MatchesStructDefinition) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83966.278530.patch
Type: text/x-patch
Size: 838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200716/827b4fff/attachment.bin>


More information about the cfe-commits mailing list