[clang] b6073ee - Enable the test for hasArraySize() AST matcher in all language modes

Dmitri Gribenko via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 01:24:06 PDT 2020


Author: Dmitri Gribenko
Date: 2020-07-20T10:23:00+02:00
New Revision: b6073ee9ae842d1999fd7798a0aac0f8427d6aea

URL: https://github.com/llvm/llvm-project/commit/b6073ee9ae842d1999fd7798a0aac0f8427d6aea
DIFF: https://github.com/llvm/llvm-project/commit/b6073ee9ae842d1999fd7798a0aac0f8427d6aea.diff

LOG: Enable the test for hasArraySize() AST matcher in all language modes

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

Reviewers: ymandel, hokein

Reviewed By: hokein

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83966

Added: 
    

Modified: 
    clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 36e92c632c03..4bd50191e163 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -3219,13 +3219,13 @@ TEST_P(ASTMatchersTest, IsArray) {
 }
 
 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) {


        


More information about the cfe-commits mailing list