[PATCH] D53719: [clang-tidy] UppercaseLiteralSuffixCheck: bugfix: don't cripple substNonTypeTemplateParmExpr
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 25 11:18:09 PDT 2018
lebedev.ri created this revision.
lebedev.ri added reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun.
lebedev.ri added a project: clang-tools-extra.
Herald added subscribers: chrib, rnkovacs, kristof.beyls.
The previous, clearly broken output:
/tmp/test.cpp:4:17: warning: integer literal has suffix 'lignment', which is not uppercase [hicpp-uppercase-literal-suffix]
static_assert(alignment, "");
^~~~~~~~~
LIGNMENT
https://godbolt.org/z/iyWIrX
Is there some more general way this should be avoided?
Too bad i haven't thought of this/triggered this while developing :/
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53719
Files:
clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
Index: test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
===================================================================
--- test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
@@ -243,3 +243,11 @@
void user_defined_literals() {
1_ull;
}
+
+template <unsigned alignment>
+void template_test() {
+ static_assert(alignment, "");
+}
+void actual_template_test() {
+ template_test<4>();
+}
Index: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===================================================================
--- clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -198,7 +198,8 @@
Finder->addMatcher(
stmt(allOf(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name),
floatLiteral().bind(FloatingLiteralCheck::Name)),
- unless(hasParent(userDefinedLiteral())))),
+ unless(anyOf(hasParent(userDefinedLiteral()),
+ hasParent(substNonTypeTemplateParmExpr()))))),
this);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53719.171145.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181025/cef32bdc/attachment.bin>
More information about the cfe-commits
mailing list