File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ static Token getTokenAtLoc(SourceLocation Loc,
36
36
return Tok;
37
37
}
38
38
39
+ namespace {
40
+ AST_MATCHER (FunctionDecl, isUserDefineLiteral) {
41
+ return Node.getLiteralIdentifier () != nullptr ;
42
+ }
43
+ } // namespace
44
+
39
45
namespace tidy ::google::runtime {
40
46
41
47
IntegerTypesCheck::IntegerTypesCheck (StringRef Name, ClangTidyContext *Context)
@@ -56,11 +62,14 @@ void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) {
56
62
// http://google.github.io/styleguide/cppguide.html#64-bit_Portability
57
63
// "Where possible, avoid passing arguments of types specified by
58
64
// bitwidth typedefs to printf-based APIs."
59
- Finder->addMatcher (typeLoc (loc (isInteger ()),
60
- unless (hasAncestor (callExpr (
61
- callee (functionDecl (hasAttr (attr::Format)))))))
62
- .bind (" tl" ),
63
- this );
65
+ Finder->addMatcher (
66
+ typeLoc (loc (isInteger ()),
67
+ unless (anyOf (hasAncestor (callExpr (
68
+ callee (functionDecl (hasAttr (attr::Format))))),
69
+ hasParent (parmVarDecl (hasAncestor (
70
+ functionDecl (isUserDefineLiteral ())))))))
71
+ .bind (" tl" ),
72
+ this );
64
73
IdentTable = std::make_unique<IdentifierTable>(getLangOpts ());
65
74
}
66
75
Original file line number Diff line number Diff line change @@ -381,6 +381,9 @@ Changes in existing checks
381
381
<clang-tidy/checks/google/readability-casting>` check to ignore constructor
382
382
calls disguised as functional casts.
383
383
384
+ - Improved :doc: `google-runtime-int <clang-tidy/checks/google/runtime-int >`
385
+ check to ignore false positives on user defined-literals.
386
+
384
387
- Improved :doc: `llvm-namespace-comment
385
388
<clang-tidy/checks/llvm/namespace-comment>` check to provide fixes for
386
389
``inline `` namespaces in the same format as :program: `clang-format `.
Original file line number Diff line number Diff line change @@ -59,11 +59,13 @@ void qux() {
59
59
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16'
60
60
}
61
61
62
- // FIXME: This shouldn't warn, as UD-literal operators require one of a handful
63
- // of types as an argument.
64
62
struct some_value {};
65
- constexpr some_value operator " " _some_literal(unsigned long long int i);
66
- // CHECK-MESSAGES: [[@LINE-1]]:47: warning: consider replacing 'unsigned long long'
63
+ constexpr some_value operator " " _some_literal(unsigned long long int i)
64
+ {
65
+ short j;
66
+ // CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16'
67
+ return some_value ();
68
+ }
67
69
68
70
struct A { A& operator =(const A&); };
69
71
class B { A a[0 ]; };
You can’t perform that action at this time.
0 commit comments