return AsDecl->isImplicit();
}
- if (Node.get<EnumConstantDecl>() != nullptr)
+ if (Node.get<EnumConstantDecl>())
return true;
return llvm::any_of(Result.Context->getParents(Node),
if (isUsedToInitializeAConstant(Result, Parent))
return true;
- // Ignore this instance, because this match reports the location
- // where the template is defined, not where it is instantiated.
+ // Ignore this instance, because this matches an
+ // expanded class enumeration value.
+ if (Parent.get<CStyleCastExpr>() &&
+ llvm::any_of(
+ Result.Context->getParents(Parent),
+ [](const DynTypedNode &GrandParent) {
+ return GrandParent.get<SubstNonTypeTemplateParmExpr>() !=
+ nullptr;
+ }))
+ return true;
+
+ // Ignore this instance, because this match reports the
+ // location where the template is defined, not where it
+ // is instantiated.
if (Parent.get<SubstNonTypeTemplateParmExpr>())
return true;
The check now supports the ``IgnoreBitFieldsWidths`` option to suppress
the warning for numbers used to specify bit field widths.
+ The check was updated to eliminate some false positives (such as using
+ class enumeration as non-type template parameters, or the synthetically
+ computed lengh of a static user string literal.)
+
- New :doc:`readability-make-member-function-const
<clang-tidy/checks/readability-make-member-function-const>` check.
const int anotherConstant;
};
-int ValueArray[] = {3, 5};
+int ValueArray[] = {3, 5, 0, 0, 0};
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
const geometry::Rectangle<double> mandelbrotCanvas{geometry::Point<double>{-2.5, -1}, geometry::Dimension<double>{3.5, 2}};
-// Simulate the macro magic in Google Test internal headers
+// Simulate the macro magic in Google Test internal headers.
class AssertionHelper {
public:
AssertionHelper(const char *Message, int LineNumber) : Message(Message), LineNumber(LineNumber) {}
ASSERTION_HELPER("here and now");
}
-// prove that integer literals introduced by the compiler are accepted silently
+// Prove that integer literals introduced by the compiler are accepted silently.
extern int ConsumeString(const char *Input);
const char *SomeStrings[] = {"alpha", "beta", "gamma"};
return Total;
}
+
+// Prove that using enumerations values don't produce warnings.
+enum class Letter : unsigned {
+ A, B, C, D, E, F, G, H, I, J
+};
+
+template<Letter x> struct holder { Letter letter = x; };
+template<Letter x> struct wrapper { using h_type = holder<x>; };
+
+template struct wrapper<Letter::A>;
+template struct wrapper<Letter::J>;