File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " ProTypeVarargCheck.h"
10
+ #include " ../utils/Matchers.h"
10
11
#include " clang/AST/ASTContext.h"
11
12
#include " clang/ASTMatchers/ASTMatchFinder.h"
12
13
#include " clang/ASTMatchers/ASTMatchers.h"
@@ -133,7 +134,9 @@ void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
133
134
134
135
Finder->addMatcher (
135
136
callExpr (callee (functionDecl (isVariadic (),
136
- unless (hasAnyName (AllowedVariadics)))))
137
+ unless (hasAnyName (AllowedVariadics)))),
138
+ unless (hasAncestor (expr (matchers::hasUnevaluatedContext ()))),
139
+ unless (hasAncestor (typeLoc ())))
137
140
.bind (" callvararg" ),
138
141
this );
139
142
Original file line number Diff line number Diff line change @@ -176,6 +176,10 @@ Changes in existing checks
176
176
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
177
177
ignore delegate constructors.
178
178
179
+ - Improved :doc: `cppcoreguidelines-pro-type-vararg
180
+ <clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check to ignore
181
+ false-positives in unevaluated context (e.g., ``decltype ``, ``sizeof ``, ...).
182
+
179
183
- Improved :doc: `llvm-namespace-comment
180
184
<clang-tidy/checks/llvm/namespace-comment>` check to provide fixes for
181
185
``inline `` namespaces in the same format as :program: `clang-format `.
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ This check flags all calls to c-style vararg functions and all use of
7
7
``va_arg ``.
8
8
9
9
To allow for SFINAE use of vararg functions, a call is not flagged if a literal
10
- 0 is passed as the only vararg argument.
10
+ 0 is passed as the only vararg argument or function is used in unevaluated
11
+ context.
11
12
12
13
Passing to varargs assumes the correct type will be read. This is fragile
13
14
because it cannot generally be enforced to be safe in the language and so relies
Original file line number Diff line number Diff line change @@ -66,3 +66,16 @@ void no_false_positive_desugar_va_list(char *in) {
66
66
char *tmp1 = in;
67
67
void *tmp2 = in;
68
68
}
69
+
70
+ namespace PR30542 {
71
+ struct X ;
72
+ template <typename T>
73
+ char IsNullConstant (X*);
74
+ template <typename T>
75
+ char (&IsNullConstant (...))[2];
76
+
77
+ static_assert (sizeof (IsNullConstant<int >(0 )) == 1, "");
78
+ static_assert (sizeof (IsNullConstant<int >(17 )) == 2, "");
79
+
80
+ using Type = decltype (IsNullConstant<int >(17 ));
81
+ }
You can’t perform that action at this time.
0 commit comments