On Wed, Nov 18, 2015 at 12:44 PM, Bruno Cardoso Lopes
<bruno.card...@gmail.com> wrote:
> Hi Aaron,
>
> This commit is failing tests due to assertions in the tests:
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/13216

This was reverted in r253475 while I investigate.

~Aaron

>
> Example:
>
> Note: Google Test filter = ParserTest.CompletionNamedValues
> [==========] Running 1 test from 1 test case.
> [----------] Global test environment set-up.
> [----------] 1 test from ParserTest
> [ RUN      ] ParserTest.CompletionNamedValues
> Assertion failed: (Constructors.find(MatcherName) ==
> Constructors.end()), function registerMatcher, file
> /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/lib/ASTMatchers/Dynamic/Registry.cpp,
> line 49.
> 0  DynamicASTMatchersTests  0x0000000103a9418b
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
> 1  DynamicASTMatchersTests  0x0000000103a93286
> llvm::sys::RunSignalHandlers() + 70
> 2  DynamicASTMatchersTests  0x0000000103a94a05 SignalHandler(int) + 645
> 3  libsystem_platform.dylib 0x00007fff965faf1a _sigtramp + 26
> 4  DynamicASTMatchersTests  0x0000000103cb6d6f nuls + 80511
> 5  DynamicASTMatchersTests  0x0000000103a946d6 abort + 22
> 6  DynamicASTMatchersTests  0x0000000103a946b1 __assert_rtn + 81
> 7  DynamicASTMatchersTests  0x000000010353f63c
> clang::ast_matchers::dynamic::(anonymous
> namespace)::RegistryMaps::RegistryMaps() + 50668
> 8  DynamicASTMatchersTests  0x0000000103532f3b void*
> llvm::object_creator<clang::ast_matchers::dynamic::(anonymous
> namespace)::RegistryMaps>() + 27
> 9  DynamicASTMatchersTests  0x0000000103a87050
> llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void
> (*)(void*)) const + 160
> 10 DynamicASTMatchersTests  0x0000000103531838
> clang::ast_matchers::dynamic::Registry::lookupMatcherCtor(llvm::StringRef)
> + 72
> 11 DynamicASTMatchersTests  0x000000010352bc74
>
>
> Thanks,
>
> On Wed, Nov 18, 2015 at 9:05 AM, Aaron Ballman via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>> Author: aaronballman
>> Date: Wed Nov 18 11:05:39 2015
>> New Revision: 253473
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253473&view=rev
>> Log:
>> Adding AST matchers for VarDecl storage durations. Can now determine whether 
>> a VarDecl has automatic, static, or thread storage duration. This also 
>> updates the documentation for matchers, which appear to be missing some 
>> previous additions.
>>
>> Modified:
>>     cfe/trunk/docs/LibASTMatchersReference.html
>>     cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>>     cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>>     cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>>
>> Modified: cfe/trunk/docs/LibASTMatchersReference.html
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=253473&r1=253472&r2=253473&view=diff
>> ==============================================================================
>> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
>> +++ cfe/trunk/docs/LibASTMatchersReference.html Wed Nov 18 11:05:39 2015
>> @@ -1774,6 +1774,21 @@ cxxMethodDecl(isConst()) matches A::foo(
>>  </pre></td></tr>
>>
>>
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html";>CXXMethodDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('isCopyAssignmentOperator0')"><a 
>> name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr>
>> +<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches 
>> if the given method declaration declares a copy assignment
>> +operator.
>> +
>> +Given
>> +struct A {
>> +  A &amp;operator=(const A &amp;);
>> +  A &amp;operator=(A &amp;&amp;);
>> +};
>> +
>> +cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
>> +the second one.
>> +</pre></td></tr>
>> +
>> +
>>  <tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html";>CXXMethodDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('isFinal1')"><a 
>> name="isFinal1Anchor">isFinal</a></td><td></td></tr>
>>  <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given 
>> method or class declaration is final.
>>
>> @@ -2749,6 +2764,20 @@ Example matches a || b (matcher = binary
>>  </pre></td></tr>
>>
>>
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('hasAutomaticStorageDuration0')"><a 
>> name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr>
>> +<tr><td colspan="4" class="doc" 
>> id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that 
>> has automatic storage duration.
>> +
>> +Example matches x, but not y, z, or a.
>> +(matcher = varDecl(hasAutomaticStorageDuration())
>> +void f() {
>> +  int x;
>> +  static int y;
>> +  thread_local int z;
>> +}
>> +int a;
>> +</pre></td></tr>
>> +
>> +
>>  <tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('hasGlobalStorage0')"><a 
>> name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr>
>>  <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a 
>> variable declaration that does not have local storage.
>>
>> @@ -2774,6 +2803,34 @@ int z;
>>  </pre></td></tr>
>>
>>
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('hasStaticStorageDuration0')"><a 
>> name="hasStaticStorageDuration0Anchor">hasStaticStorageDuration</a></td><td></td></tr>
>> +<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches 
>> a variable declaration that has static storage duration.
>> +
>> +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;
>> +</pre></td></tr>
>> +
>> +
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('hasThreadStorageDuration0')"><a 
>> name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr>
>> +<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches 
>> a variable declaration that has thread storage duration.
>> +
>> +Example matches z, but not x, z, or a.
>> +(matcher = varDecl(hasThreadStorageDuration())
>> +void f() {
>> +  int x;
>> +  static int y;
>> +  thread_local int z;
>> +}
>> +int a;
>> +</pre></td></tr>
>> +
>> +
>>  <tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html";>VarDecl</a>&gt;</td><td
>>  class="name" onclick="toggle('isConstexpr0')"><a 
>> name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr>
>>  <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr 
>> variable and function declarations.
>>
>> @@ -3040,6 +3097,22 @@ arraySubscriptExpression(hasIndex(intege
>>  </pre></td></tr>
>>
>>
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html";>ArraySubscriptExpr</a>&gt;</td><td
>>  class="name" onclick="toggle('hasLHS1')"><a 
>> name="hasLHS1Anchor">hasLHS</a></td><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html";>Expr</a>&gt; 
>> InnerMatcher</td></tr>
>> +<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand 
>> side of binary operator expressions.
>> +
>> +Example matches a (matcher = binaryOperator(hasLHS()))
>> +  a || b
>> +</pre></td></tr>
>> +
>> +
>> +<tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html";>ArraySubscriptExpr</a>&gt;</td><td
>>  class="name" onclick="toggle('hasRHS1')"><a 
>> name="hasRHS1Anchor">hasRHS</a></td><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html";>Expr</a>&gt; 
>> InnerMatcher</td></tr>
>> +<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand 
>> side of binary operator expressions.
>> +
>> +Example matches b (matcher = binaryOperator(hasRHS()))
>> +  a || b
>> +</pre></td></tr>
>> +
>> +
>>  <tr><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html";>ArrayTypeLoc</a>&gt;</td><td
>>  class="name" onclick="toggle('hasElementTypeLoc0')"><a 
>> name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher&lt<a 
>> href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html";>TypeLoc</a>&gt;</td></tr>
>>  <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays 
>> and C99 complex types that have a specific element
>>  type.
>>
>> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=253473&r1=253472&r2=253473&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
>> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Nov 18 11:05:39 
>> 2015
>> @@ -2544,6 +2544,54 @@ AST_MATCHER(VarDecl, hasGlobalStorage) {
>>    return Node.hasGlobalStorage();
>>  }
>>
>> +/// \brief Matches a variable declaration that has automatic storage 
>> duration.
>> +///
>> +/// Example matches x, but not y, z, or a.
>> +/// (matcher = varDecl(hasAutomaticStorageDuration())
>> +/// \code
>> +/// void f() {
>> +///   int x;
>> +///   static int y;
>> +///   thread_local int z;
>> +/// }
>> +/// int a;
>> +/// \endcode
>> +AST_MATCHER(VarDecl, hasAutomaticStorageDuration) {
>> +  return Node.getStorageDuration() == SD_Automatic;
>> +}
>> +
>> +/// \brief Matches a variable declaration that has static storage duration.
>> +///
>> +/// 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;
>> +/// \endcode
>> +AST_MATCHER(VarDecl, hasStaticStorageDuration) {
>> +  return Node.getStorageDuration() == SD_Static;
>> +}
>> +
>> +/// \brief Matches a variable declaration that has thread storage duration.
>> +///
>> +/// Example matches z, but not x, z, or a.
>> +/// (matcher = varDecl(hasThreadStorageDuration())
>> +/// \code
>> +/// void f() {
>> +///   int x;
>> +///   static int y;
>> +///   thread_local int z;
>> +/// }
>> +/// int a;
>> +/// \endcode
>> +AST_MATCHER(VarDecl, hasThreadStorageDuration) {
>> +  return Node.getStorageDuration() == SD_Thread;
>> +}
>> +
>>  /// \brief Matches a variable declaration that is an exception variable from
>>  /// a C++ catch block, or an Objective-C \@catch statement.
>>  ///
>>
>> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=253473&r1=253472&r2=253473&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
>> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Nov 18 11:05:39 2015
>> @@ -194,6 +194,7 @@ RegistryMaps::RegistryMaps() {
>>    REGISTER_MATCHER(hasArgument);
>>    REGISTER_MATCHER(hasArgumentOfType);
>>    REGISTER_MATCHER(hasAttr);
>> +  REGISTER_MATCHER(hasAutomaticStorageDuration);
>>    REGISTER_MATCHER(hasBase);
>>    REGISTER_MATCHER(hasBody);
>>    REGISTER_MATCHER(hasCanonicalType);
>> @@ -238,9 +239,11 @@ RegistryMaps::RegistryMaps() {
>>    REGISTER_MATCHER(hasSize);
>>    REGISTER_MATCHER(hasSizeExpr);
>>    REGISTER_MATCHER(hasSourceExpression);
>> +  REGISTER_MATCHER(hasThreadStorageDuration);
>>    REGISTER_MATCHER(hasTargetDecl);
>>    REGISTER_MATCHER(hasTemplateArgument);
>>    REGISTER_MATCHER(hasThen);
>> +  REGISTER_MATCHER(hasThreadStorageDuration);
>>    REGISTER_MATCHER(hasTrueExpression);
>>    REGISTER_MATCHER(hasTypeLoc);
>>    REGISTER_MATCHER(hasUnaryOperand);
>>
>> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=253473&r1=253472&r2=253473&view=diff
>> ==============================================================================
>> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
>> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Wed Nov 18 11:05:39 
>> 2015
>> @@ -1355,6 +1355,29 @@ TEST(Matcher, VarDecl_Storage) {
>>    EXPECT_TRUE(matches("void f() { static int X; }", M));
>>  }
>>
>> +TEST(Matcher, VarDecl_StorageDuration) {
>> +  std::string T =
>> +      "void f() { int x; static int y; thread_local int z; } int a;";
>> +
>> +  EXPECT_TRUE(matches(T, varDecl(hasName("x"), 
>> hasAutomaticStorageDuration())));
>> +  EXPECT_TRUE(
>> +      notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration())));
>> +  EXPECT_TRUE(
>> +      notMatches(T, varDecl(hasName("z"), hasAutomaticStorageDuration())));
>> +  EXPECT_TRUE(
>> +      notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration())));
>> +
>> +  EXPECT_TRUE(matches(T, varDecl(hasName("y"), 
>> hasStaticStorageDuration())));
>> +  EXPECT_TRUE(matches(T, varDecl(hasName("a"), 
>> hasStaticStorageDuration())));
>> +  EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), 
>> hasStaticStorageDuration())));
>> +  EXPECT_TRUE(notMatches(T, varDecl(hasName("z"), 
>> hasStaticStorageDuration())));
>> +
>> +  EXPECT_TRUE(matches(T, varDecl(hasName("z"), 
>> hasThreadStorageDuration())));
>> +  EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), 
>> hasThreadStorageDuration())));
>> +  EXPECT_TRUE(notMatches(T, varDecl(hasName("y"), 
>> hasThreadStorageDuration())));
>> +  EXPECT_TRUE(notMatches(T, varDecl(hasName("a"), 
>> hasThreadStorageDuration())));
>> +}
>> +
>>  TEST(Matcher, FindsVarDeclInFunctionParameter) {
>>    EXPECT_TRUE(matches(
>>        "void f(int i) {}",
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to