Trying to match integerLiteral(-1) will silently fail, because clang only represents positive integer literals.
- Update the documentation to explain how to match negative integers.
- Add a unit test.
Paths
| Differential D35196
[ASTMatchers][NFC] integerLiteral(): Mention negative integers in documentation. ClosedPublic Authored by courbet on Jul 10 2017, 4:53 AM.
Details Summary Trying to match integerLiteral(-1) will silently fail, because clang only represents positive integer literals.
Diff Detail Event Timeline
courbet marked 4 inline comments as done. Comment Actions
Comment Actions LGTM, thank you!
This revision is now accepted and ready to land.Jul 11 2017, 5:39 AM Closed by commit rL307663: [ASTMatchers][NFC] integerLiteral(): Mention negative integers in (authored by courbet). · Explain WhyJul 11 2017, 8:45 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 105971 docs/LibASTMatchersReference.html
include/clang/ASTMatchers/ASTMatchers.h
unittests/ASTMatchers/ASTMatchersNodeTest.cpp
|
I'm not keen on this explanation -- the reason you cannot match a negative integer is because the source languages treat the integer literal as positive and you apply the unary negation operator to the integer literal. Basically, from the lexer's perspective, the integer literal does not have a - sign; that is an expression.