[all-commits] [llvm/llvm-project] 427c1d: [ASTMatchers] Matchers that take enumerations args...

Nathan James via All-commits all-commits at lists.llvm.org
Mon Apr 6 12:00:35 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 427c1dc4f4248ec71e32a8f3832a4e6258446672
      https://github.com/llvm/llvm-project/commit/427c1dc4f4248ec71e32a8f3832a4e6258446672
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-04-06 (Mon, 06 Apr 2020)

  Changed paths:
    M clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
    M clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
    M clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
    A clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
    M clang/lib/ASTMatchers/Dynamic/Marshallers.h
    M clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp

  Log Message:
  -----------
  [ASTMatchers] Matchers that take enumerations args provide hints with invalid arguments

Summary:
This adds support for giving hints when using dynamic matchers with enum args. Take this query, I couldn't figure out why the matcher wasn't working:
(Turns out it needed to be "IntegralToBoolean", but thats another bug itself)
```
clang-query> match implicitCastExpr(hasCastKind("CK_IntegralToBoolean"))
1:1: Error parsing argument 1 for matcher implicitCastExpr.
1:18: Error building matcher hasCastKind.
1:30: Incorrect type for arg 1. (Expected = string) != (Actual = String)
```
With this patch the new behaviour looks like this:
```
clang-query> match implicitCastExpr(hasCastKind("CK_IntegralToBoolean"))
1:1: Error parsing argument 1 for matcher implicitCastExpr.
1:18: Error building matcher hasCastKind.
1:30: Unknown value 'CK_IntegralToBoolean' for arg 1; did you mean 'IntegralToBoolean'
```

There are no test cases for this yet as there simply isn't any infrastructure for testing errors reported when parsing args that I can see.

Reviewers: klimek, jdoerfert, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, dexonsmith, mgorny, cfe-commits

Tags: #clang

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




More information about the All-commits mailing list