Re: [PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

2016-09-27 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL282474: [ASTMatcher] Clarify isStaticStorageClass and 
hasStaticStorageDuration… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D24928?vs=72608=72610#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24928

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

Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -669,7 +669,7 @@
 
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
-"void f() { int x; static int y; } int a;";
+"void f() { int x; static int y; } int a;static int b;extern int c;";
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration(;
   EXPECT_TRUE(
@@ -679,6 +679,8 @@
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration(;
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("b"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("c"), hasStaticStorageDuration(;
   EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasStaticStorageDuration(;
 
   // FIXME: It is really hard to test with thread_local itself because not all
@@ -853,6 +855,7 @@
   matches("static void f() {}", functionDecl(isStaticStorageClass(;
   EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
 }
 
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -2611,12 +2611,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 functionDecl(isStaticStorageClass())
   matches the function declaration f.
 varDecl(isStaticStorageClass())
@@ -3394,15 +3396,19 @@
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclhasStaticStorageDuration
 Matches a variable declaration that has static storage duration.
+It includes the variable declared at namespace scope and those declared
+with "static" and "extern" storage class specifiers.
 
-Example matches y and a, but not x or z.
-(matcher = varDecl(hasStaticStorageDuration())
 void f() {
   int x;
   static int y;
   thread_local int z;
 }
 int a;
+static int b;
+extern int c;
+varDecl(hasStaticStorageDuration())
+  matches the function declaration y, a, b and c.
 
 
 
@@ -3488,12 +3494,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 functionDecl(isStaticStorageClass())
   matches the function declaration f.
 varDecl(isStaticStorageClass())
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -2943,16 +2943,20 @@
 }
 
 /// \brief Matches a variable declaration that has static storage duration.
+/// It includes the variable declared at namespace scope and those declared
+/// with "static" and "extern" storage class specifiers.
 ///
-/// Example matches y and a, but not x or z.
-/// (matcher = varDecl(hasStaticStorageDuration())
 /// \code
 /// void f() {
 ///   int x;
 ///   static int y;
 ///   thread_local int z;
 /// }
 /// int a;
+/// static int b;
+/// extern int c;
+/// varDecl(hasStaticStorageDuration())
+///   matches the function declaration y, a, b and c.
 /// \endcode
 AST_MATCHER(VarDecl, hasStaticStorageDuration) {
   return Node.getStorageDuration() == SD_Static;
@@ -3388,13 +3392,15 @@
   return Node.isExternC();
 }
 
-/// \brief Matches 

Re: [PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

2016-09-27 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 72608.
hokein added a comment.

Address review comments


https://reviews.llvm.org/D24928

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

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -669,7 +669,7 @@
 
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
-"void f() { int x; static int y; } int a;";
+"void f() { int x; static int y; } int a;static int b;extern int c;";
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration(;
   EXPECT_TRUE(
@@ -679,6 +679,8 @@
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration(;
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("b"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("c"), hasStaticStorageDuration(;
   EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasStaticStorageDuration(;
 
   // FIXME: It is really hard to test with thread_local itself because not all
@@ -853,6 +855,7 @@
   matches("static void f() {}", functionDecl(isStaticStorageClass(;
   EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2942,16 +2942,20 @@
 }
 
 /// \brief Matches a variable declaration that has static storage duration.
+/// It includes the variable declared at namespace scope and those declared
+/// with "static" and "extern" storage class specifiers.
 ///
-/// Example matches y and a, but not x or z.
-/// (matcher = varDecl(hasStaticStorageDuration())
 /// \code
 /// void f() {
 ///   int x;
 ///   static int y;
 ///   thread_local int z;
 /// }
 /// int a;
+/// static int b;
+/// extern int c;
+/// varDecl(hasStaticStorageDuration())
+///   matches the function declaration y, a, b and c.
 /// \endcode
 AST_MATCHER(VarDecl, hasStaticStorageDuration) {
   return Node.getStorageDuration() == SD_Static;
@@ -3387,13 +3391,15 @@
   return Node.isExternC();
 }
 
-/// \brief Matches variable/function declarations that have static storage class
-/// (with "static" key word) written in the source.
+/// \brief Matches variable/function declarations that have "static" storage
+/// class specifier ("static" keyword) written in the source.
 ///
 /// Given:
 /// \code
 ///   static void f() {}
 ///   static int i = 0;
+///   extern int j;
+///   int k;
 /// \endcode
 /// functionDecl(isStaticStorageClass())
 ///   matches the function declaration f.
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2611,12 +2611,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 functionDecl(isStaticStorageClass())
   matches the function declaration f.
 varDecl(isStaticStorageClass())
@@ -3394,15 +3396,19 @@
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclhasStaticStorageDuration
 Matches a variable declaration that has static storage duration.
+It includes the variable declared at namespace scope and those declared
+with "static" and "extern" storage class specifiers.
 
-Example matches y and a, but not x or z.
-(matcher = varDecl(hasStaticStorageDuration())
 void f() {
   int x;
   static int y;
   thread_local int z;
 }
 int a;
+static int b;
+extern int c;
+varDecl(hasStaticStorageDuration())
+  matches the function declaration y, a, b and c.
 
 
 
@@ -3488,12 +3494,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 

Re: [PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

2016-09-26 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the clarifications!



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3395
@@ -3392,1 +3394,3 @@
+/// \brief Matches variable/function declarations that have "static" storage
+/// class specifier ("static" key word) written in the source.
 ///

Might as well correct "key word" to be "keyword" instead, as a drive-by fix.


https://reviews.llvm.org/D24928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24928: [ASTMatcher] Clarify isStaticStorageClass and hasStaticStorageDuration documents.

2016-09-26 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: aaron.ballman.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D24928

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

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -669,7 +669,7 @@
 
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
-"void f() { int x; static int y; } int a;";
+"void f() { int x; static int y; } int a;static int b;extern int c;";
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration(;
   EXPECT_TRUE(
@@ -679,6 +679,8 @@
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration(;
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("b"), hasStaticStorageDuration(;
+  EXPECT_TRUE(matches(T, varDecl(hasName("c"), hasStaticStorageDuration(;
   EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasStaticStorageDuration(;
 
   // FIXME: It is really hard to test with thread_local itself because not all
@@ -853,6 +855,7 @@
   matches("static void f() {}", functionDecl(isStaticStorageClass(;
   EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2942,16 +2942,20 @@
 }
 
 /// \brief Matches a variable declaration that has static storage duration.
+/// It includes the variable declared at namespace scope and those declared
+/// with "static" and "extern" storage class specifiers.
 ///
-/// Example matches y and a, but not x or z.
-/// (matcher = varDecl(hasStaticStorageDuration())
 /// \code
 /// void f() {
 ///   int x;
 ///   static int y;
 ///   thread_local int z;
 /// }
 /// int a;
+/// static int b;
+/// extern int c;
+/// varDecl(isStaticStorageClass())
+///   matches the function declaration y, a, b and c.
 /// \endcode
 AST_MATCHER(VarDecl, hasStaticStorageDuration) {
   return Node.getStorageDuration() == SD_Static;
@@ -3387,13 +3391,15 @@
   return Node.isExternC();
 }
 
-/// \brief Matches variable/function declarations that have static storage class
-/// (with "static" key word) written in the source.
+/// \brief Matches variable/function declarations that have "static" storage
+/// class specifier ("static" key word) written in the source.
 ///
 /// Given:
 /// \code
 ///   static void f() {}
 ///   static int i = 0;
+///   extern int j;
+///   int k;
 /// \endcode
 /// functionDecl(isStaticStorageClass())
 ///   matches the function declaration f.
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2611,12 +2611,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" key word) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;
+  extern int j;
+  int k;
 functionDecl(isStaticStorageClass())
   matches the function declaration f.
 varDecl(isStaticStorageClass())
@@ -3394,15 +3396,19 @@
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclhasStaticStorageDuration
 Matches a variable declaration that has static storage duration.
+It includes the variable declared at namespace scope and those declared
+with "static" and "extern" storage class specifiers.
 
-Example matches y and a, but not x or z.
-(matcher = varDecl(hasStaticStorageDuration())
 void f() {
   int x;
   static int y;
   thread_local int z;
 }
 int a;
+static int b;
+extern int c;
+varDecl(isStaticStorageClass())
+  matches the function declaration y, a, b and c.
 
 
 
@@ -3488,12 +3494,14 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticStorageClass
-Matches variablefunction declarations that have static storage class
-(with "static" key word) written in the source.
+Matches variablefunction declarations that have "static" storage
+class specifier ("static" key word) written in the source.
 
 Given:
   static void f() {}
   static int i = 0;