[ASTMatchers] Matchers that take enumerations args provide hints with invalid arguments
authorNathan James <n.james93@hotmail.co.uk>
Sun, 5 Apr 2020 14:33:34 +0000 (15:33 +0100)
committerNathan James <n.james93@hotmail.co.uk>
Mon, 6 Apr 2020 19:00:30 +0000 (20:00 +0100)
commit427c1dc4f4248ec71e32a8f3832a4e6258446672
tree8fda2d75f8feda20bca8fd54c504c1814d82b8c9
parent53b7abdd238c89346e5516928af675e5ca973124
[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
clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp [new file with mode: 0644]
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp