[PATCH] D77499: [ASTMatchers] Matchers that take enumerations args provide hints with invalid arguments
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 5 07:59:54 PDT 2020
njames93 created this revision.
njames93 added a reviewer: klimek.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
njames93 edited the summary of this revision.
Herald added a subscriber: dexonsmith.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77499
Files:
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
clang/lib/ASTMatchers/Dynamic/Marshallers.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77499.255162.patch
Type: text/x-patch
Size: 8784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200405/47995280/attachment.bin>
More information about the cfe-commits
mailing list