courbet updated this revision to Diff 489796.
courbet added a comment.

Regenerate doc


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141925/new/

https://reviews.llvm.org/D141925

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1439,6 +1439,20 @@
   EXPECT_TRUE(notMatches("int X;", M));
 }
 
+TEST_P(ASTMatchersTest, IsDirectInit) {
+  auto M = varDecl(isDirectInit());
+  EXPECT_TRUE(notMatches("int i1 = 3;", M));
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(matches("int i2(3);", M));
+  if (!GetParam().isCXX11OrLater()) {
+    return;
+  }
+  EXPECT_TRUE(matches("int i3{3};", M));
+  EXPECT_TRUE(notMatches("int i4;", M));
+}
+
 TEST_P(ASTMatchersTest, StorageDuration) {
   StringRef T =
       "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4114,6 +4114,22 @@
           InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// \brief Matches a variable initializer that is a direct-initializer.
+///
+/// Example matches i2 and i2, but not i1 or i4
+/// (matcher = varDecl(isStaticLocal()))
+/// \code
+/// void f() {
+///   int i1 = 3;
+///   int i2(3);
+///   int i3{3};
+///   int i4;
+/// }
+/// \endcode
+AST_MATCHER(VarDecl, isDirectInit) {
+  return Node.isDirectInit();
+}
+
 /// \brief Matches a static variable with local scope.
 ///
 /// Example matches y (matcher = varDecl(isStaticLocal()))
Index: clang/docs/LibASTMatchersReference.html
===================================================================
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5446,6 +5446,20 @@
 </pre></td></tr>
 
 
+<tr><td>Matcher&lt;<a 
href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
 class="name" onclick="toggle('isDirectInit0')"><a 
name="isDirectInit0Anchor">isDirectInit</a></td><td></td></tr>
+<tr><td colspan="4" class="doc" id="isDirectInit0"><pre>Matches a variable 
initializer that is a direct-initializer.
+
+Example matches i2 and i2, but not i1 or i4
+(matcher = varDecl(isStaticLocal()))
+void f() {
+  int i1 = 3;
+  int i2(3);
+  int i3{3};
+  int i4;
+}
+</pre></td></tr>
+
+
 <tr><td>Matcher&lt;<a 
href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
 class="name" onclick="toggle('isExceptionVariable0')"><a 
name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr>
 <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a 
variable declaration that is an exception variable from
 a C++ catch block, or an Objective-C statement.


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1439,6 +1439,20 @@
   EXPECT_TRUE(notMatches("int X;", M));
 }
 
+TEST_P(ASTMatchersTest, IsDirectInit) {
+  auto M = varDecl(isDirectInit());
+  EXPECT_TRUE(notMatches("int i1 = 3;", M));
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(matches("int i2(3);", M));
+  if (!GetParam().isCXX11OrLater()) {
+    return;
+  }
+  EXPECT_TRUE(matches("int i3{3};", M));
+  EXPECT_TRUE(notMatches("int i4;", M));
+}
+
 TEST_P(ASTMatchersTest, StorageDuration) {
   StringRef T =
       "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4114,6 +4114,22 @@
           InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// \brief Matches a variable initializer that is a direct-initializer.
+///
+/// Example matches i2 and i2, but not i1 or i4
+/// (matcher = varDecl(isStaticLocal()))
+/// \code
+/// void f() {
+///   int i1 = 3;
+///   int i2(3);
+///   int i3{3};
+///   int i4;
+/// }
+/// \endcode
+AST_MATCHER(VarDecl, isDirectInit) {
+  return Node.isDirectInit();
+}
+
 /// \brief Matches a static variable with local scope.
 ///
 /// Example matches y (matcher = varDecl(isStaticLocal()))
Index: clang/docs/LibASTMatchersReference.html
===================================================================
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5446,6 +5446,20 @@
 </pre></td></tr>
 
 
+<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td class="name" onclick="toggle('isDirectInit0')"><a name="isDirectInit0Anchor">isDirectInit</a></td><td></td></tr>
+<tr><td colspan="4" class="doc" id="isDirectInit0"><pre>Matches a variable initializer that is a direct-initializer.
+
+Example matches i2 and i2, but not i1 or i4
+(matcher = varDecl(isStaticLocal()))
+void f() {
+  int i1 = 3;
+  int i2(3);
+  int i3{3};
+  int i4;
+}
+</pre></td></tr>
+
+
 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr>
 <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
 a C++ catch block, or an Objective-C statement.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to