lebedev.ri updated this revision to Diff 142627.
lebedev.ri added a comment.
- Don't mis-spell the name of the flag.
FIXME: So do we want it to be `-Wtests`, `-Wtest`, or we really want it to be
`-wtest` ?
Repository:
rC Clang
https://reviews.llvm.org/D45685
Files:
docs/ReleaseNotes.rst
docs/UsersManual.rst
include/clang/AST/ASTDiagnostic.h
include/clang/AST/CommentDiagnostic.h
include/clang/Basic/Diagnostic.h
include/clang/Basic/Diagnostic.td
include/clang/Basic/DiagnosticIDs.h
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/CrossTU/CrossTUDiagnostic.h
include/clang/Driver/DriverDiagnostic.h
include/clang/Frontend/FrontendDiagnostic.h
include/clang/Lex/LexDiagnostic.h
include/clang/Parse/ParseDiagnostic.h
include/clang/Sema/SemaDiagnostic.h
include/clang/Serialization/SerializationDiagnostic.h
include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
lib/Basic/DiagnosticIDs.cpp
lib/Basic/Warnings.cpp
lib/Sema/SemaExpr.cpp
test/Sema/warn-self-assign-builtin-warn-tests.c
test/SemaCXX/warn-self-assign-builtin-warn-tests.cpp
test/SemaCXX/warn-self-assign-field-builtin-warn-tests.cpp
test/SemaCXX/warn-self-assign-field-overloaded-warn-tests.cpp
test/SemaCXX/warn-self-assign-overloaded-warn-tests.cpp
tools/diagtool/DiagnosticNames.cpp
utils/TableGen/ClangDiagnosticsEmitter.cpp
Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===================================================================
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -552,6 +552,11 @@
else
OS << ", false";
+ if (R.getValueAsBit("HideInTests"))
+ OS << ", true";
+ else
+ OS << ", false";
+
// Category number.
OS << ", " << CategoryIDs.getID(getDiagnosticCategory(&R, DGParentMap));
OS << ")\n";
Index: tools/diagtool/DiagnosticNames.cpp
===================================================================
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -28,9 +28,9 @@
// FIXME: Is it worth having two tables, especially when this one can get
// out of sync easily?
static const DiagnosticRecord BuiltinDiagnosticsByID[] = {
-#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP, \
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) \
- { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
+#define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ {#ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t)},
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticCrossTUKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
Index: test/SemaCXX/warn-self-assign-overloaded-warn-tests.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/warn-self-assign-overloaded-warn-tests.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wno-tests -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wtests -verify -DSILENCE %s
+
+struct S {};
+
+void f() {
+ S a;
+#ifndef SILENCE
+ a = a; // expected-warning{{explicitly assigning}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+}
Index: test/SemaCXX/warn-self-assign-field-overloaded-warn-tests.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/warn-self-assign-field-overloaded-warn-tests.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -Wno-tests -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -Wtests -verify %s
+
+struct S {};
+
+struct C {
+ S a;
+
+ void f() {
+#ifndef SILENCE
+ a = a; // expected-warning{{assigning field to itself}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+ }
+};
Index: test/SemaCXX/warn-self-assign-field-builtin-warn-tests.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/warn-self-assign-field-builtin-warn-tests.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -Wno-tests -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign-field -Wtests -verify %s
+
+struct C {
+ int a;
+
+ void f() {
+#ifndef SILENCE
+ a = a; // expected-warning{{assigning field to itself}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+ }
+};
Index: test/SemaCXX/warn-self-assign-builtin-warn-tests.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/warn-self-assign-builtin-warn-tests.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wno-tests -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wtests -verify %s
+
+void f() {
+ int a;
+#ifndef SILENCE
+ a = a; // expected-warning{{explicitly assigning}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+}
Index: test/Sema/warn-self-assign-builtin-warn-tests.c
===================================================================
--- /dev/null
+++ test/Sema/warn-self-assign-builtin-warn-tests.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wno-tests -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -Wtests -verify %s
+
+void var() {
+ int a;
+#ifndef SILENCE
+ a = a; // expected-warning{{explicitly assigning}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+}
+
+struct S {};
+
+void str() {
+ struct S a;
+#ifndef SILENCE
+ a = a; // expected-warning{{explicitly assigning}}
+#else
+ // expected-no-diagnostics
+ a = a;
+#endif
+}
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11497,7 +11497,7 @@
/// DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
/// This warning suppressed in the event of macro expansions.
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr,
- SourceLocation OpLoc) {
+ SourceLocation OpLoc, bool IsBuiltin) {
if (S.inTemplateInstantiation())
return;
if (S.isUnevaluatedContext())
@@ -11524,9 +11524,10 @@
if (RefTy->getPointeeType().isVolatileQualified())
return;
- S.Diag(OpLoc, diag::warn_self_assignment)
- << LHSDeclRef->getType()
- << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
+ S.Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
+ : diag::warn_self_assignment_overloaded)
+ << LHSDeclRef->getType() << LHSExpr->getSourceRange()
+ << RHSExpr->getSourceRange();
}
/// Check if a bitwise-& is performed on an Objective-C pointer. This
@@ -11719,7 +11720,7 @@
OK = LHS.get()->getObjectKind();
}
if (!ResultTy.isNull()) {
- DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc);
+ DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc, true);
DiagnoseSelfMove(LHS.get(), RHS.get(), OpLoc);
}
RecordModifiableNonNullParam(*this, LHS.get());
@@ -11817,7 +11818,7 @@
break;
case BO_AndAssign:
case BO_OrAssign: // fallthrough
- DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc);
+ DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc, true);
LLVM_FALLTHROUGH;
case BO_XorAssign:
CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
@@ -12124,7 +12125,7 @@
case BO_AndAssign:
case BO_OrAssign:
case BO_XorAssign:
- DiagnoseSelfAssignment(S, LHS, RHS, OpLoc);
+ DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
break;
default:
Index: lib/Basic/Warnings.cpp
===================================================================
--- lib/Basic/Warnings.cpp
+++ lib/Basic/Warnings.cpp
@@ -45,6 +45,7 @@
const DiagnosticOptions &Opts,
bool ReportDiags) {
Diags.setSuppressSystemWarnings(true); // Default to -Wno-system-headers
+ Diags.setTailorForTests(false); // Default to -Wno-tests
Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
Diags.setShowOverloads(Opts.getShowOverloads());
@@ -114,7 +115,15 @@
Diags.setSuppressSystemWarnings(!isPositive);
continue;
}
-
+
+ // -Wtests is a special case, not driven by the option table.
+ // It cannot be controlled with -Werror.
+ if (Opt == "tests") {
+ if (SetDiagnostic)
+ Diags.setTailorForTests(isPositive);
+ continue;
+ }
+
// -Weverything is a special case as well. It implicitly enables all
// warnings, including ones not explicitly in a warning group.
if (Opt == "everything") {
Index: lib/Basic/DiagnosticIDs.cpp
===================================================================
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -43,6 +43,7 @@
unsigned SFINAE : 2;
unsigned WarnNoWerror : 1;
unsigned WarnShowInSystemHeader : 1;
+ unsigned WarnHideInTests : 1;
unsigned Category : 6;
uint16_t OptionGroupIndex;
@@ -96,12 +97,10 @@
static const StaticDiagInfoRec StaticDiagInfo[] = {
#define DIAG(ENUM, CLASS, DEFAULT_SEVERITY, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, CATEGORY) \
- { \
- diag::ENUM, DEFAULT_SEVERITY, CLASS, DiagnosticIDs::SFINAE, NOWERROR, \
- SHOWINSYSHEADER, CATEGORY, GROUP, STR_SIZE(DESC, uint16_t), DESC \
- } \
- ,
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ {diag::ENUM, DEFAULT_SEVERITY, CLASS, DiagnosticIDs::SFINAE, \
+ NOWERROR, SHOWINSYSHEADER, HIDEINTESTS, CATEGORY, \
+ GROUP, STR_SIZE(DESC, uint16_t), DESC},
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
#include "clang/Basic/DiagnosticFrontendKinds.inc"
@@ -489,6 +488,12 @@
Diag.getSourceManager().getExpansionLoc(Loc)))
return diag::Severity::Ignored;
+ // Don't show some diagnostics when -Wtests is passed.
+ bool HideInTests =
+ GetDiagInfo(DiagID) && GetDiagInfo(DiagID)->WarnHideInTests;
+ if (State->TailorForTests && HideInTests && Loc.isValid())
+ return diag::Severity::Ignored;
+
return Result;
}
Index: include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
===================================================================
--- include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
+++ include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
@@ -17,7 +17,7 @@
namespace diag {
enum {
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, CATEGORY) \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
ENUM,
#define REFACTORINGSTART
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
Index: include/clang/Serialization/SerializationDiagnostic.h
===================================================================
--- include/clang/Serialization/SerializationDiagnostic.h
+++ include/clang/Serialization/SerializationDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define SERIALIZATIONSTART
#include "clang/Basic/DiagnosticSerializationKinds.inc"
#undef DIAG
Index: include/clang/Sema/SemaDiagnostic.h
===================================================================
--- include/clang/Sema/SemaDiagnostic.h
+++ include/clang/Sema/SemaDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define SEMASTART
#include "clang/Basic/DiagnosticSemaKinds.inc"
#undef DIAG
Index: include/clang/Parse/ParseDiagnostic.h
===================================================================
--- include/clang/Parse/ParseDiagnostic.h
+++ include/clang/Parse/ParseDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define PARSESTART
#include "clang/Basic/DiagnosticParseKinds.inc"
#undef DIAG
Index: include/clang/Lex/LexDiagnostic.h
===================================================================
--- include/clang/Lex/LexDiagnostic.h
+++ include/clang/Lex/LexDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define LEXSTART
#include "clang/Basic/DiagnosticLexKinds.inc"
#undef DIAG
Index: include/clang/Frontend/FrontendDiagnostic.h
===================================================================
--- include/clang/Frontend/FrontendDiagnostic.h
+++ include/clang/Frontend/FrontendDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define FRONTENDSTART
#include "clang/Basic/DiagnosticFrontendKinds.inc"
#undef DIAG
Index: include/clang/Driver/DriverDiagnostic.h
===================================================================
--- include/clang/Driver/DriverDiagnostic.h
+++ include/clang/Driver/DriverDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define DRIVERSTART
#include "clang/Basic/DiagnosticDriverKinds.inc"
#undef DIAG
Index: include/clang/CrossTU/CrossTUDiagnostic.h
===================================================================
--- include/clang/CrossTU/CrossTUDiagnostic.h
+++ include/clang/CrossTU/CrossTUDiagnostic.h
@@ -16,7 +16,7 @@
namespace diag {
enum {
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
- SHOWINSYSHEADER, CATEGORY) \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
ENUM,
#define CROSSTUSTART
#include "clang/Basic/DiagnosticCrossTUKinds.inc"
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5600,9 +5600,11 @@
"operator '%0' has lower precedence than '%1'; "
"'%1' will be evaluated first">, InGroup<ShiftOpParentheses>;
-def warn_self_assignment : Warning<
+def warn_self_assignment_builtin : Warning<
"explicitly assigning value of variable of type %0 to itself">,
InGroup<SelfAssignment>, DefaultIgnore;
+def warn_self_assignment_overloaded: Warning<warn_self_assignment_builtin.Text>,
+ InGroup<SelfAssignment>, DefaultIgnore, SuppressInTests;
def warn_self_move : Warning<
"explicitly moving variable of type %0 to itself">,
InGroup<SelfMove>, DefaultIgnore;
Index: include/clang/Basic/DiagnosticIDs.h
===================================================================
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -65,8 +65,9 @@
// Get typedefs for common diagnostics.
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,CATEGORY,NOWERROR,SHOWINSYSHEADER) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, CATEGORY, \
+ NOWERROR, SHOWINSYSHEADER, HIDEINTESTS) \
+ ENUM,
#define COMMONSTART
#include "clang/Basic/DiagnosticCommonKinds.inc"
NUM_BUILTIN_COMMON_DIAGNOSTICS
Index: include/clang/Basic/Diagnostic.td
===================================================================
--- include/clang/Basic/Diagnostic.td
+++ include/clang/Basic/Diagnostic.td
@@ -75,6 +75,7 @@
bit AccessControl = 0;
bit WarningNoWerror = 0;
bit ShowInSystemHeader = 0;
+ bit HideInTests = 0;
Severity DefaultSeverity = defaultmapping;
DiagGroup Group;
string CategoryName = "";
@@ -98,6 +99,14 @@
bit ShowInSystemHeader = 0;
}
+class ShowInTests {
+ bit HideInTests = 0;
+}
+
+class SuppressInTests {
+ bit HideInTests = 1;
+}
+
// FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
bit ShowInSystemHeader = 1;
Index: include/clang/Basic/Diagnostic.h
===================================================================
--- include/clang/Basic/Diagnostic.h
+++ include/clang/Basic/Diagnostic.h
@@ -272,13 +272,16 @@
// Suppress warnings in system headers.
unsigned SuppressSystemWarnings : 1;
+ // Suppress some warnings that are false-positives for tests.
+ unsigned TailorForTests : 1;
+
// Map extensions to warnings or errors?
diag::Severity ExtBehavior = diag::Severity::Ignored;
DiagState()
: IgnoreAllWarnings(false), EnableAllWarnings(false),
WarningsAsErrors(false), ErrorsAsFatal(false),
- SuppressSystemWarnings(false) {}
+ SuppressSystemWarnings(false), TailorForTests(false) {}
using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
using const_iterator =
@@ -626,7 +629,12 @@
return GetCurDiagState()->SuppressSystemWarnings;
}
- /// \brief Suppress all diagnostics, to silence the front end when we
+ /// \brief When set to true some warnings that are likely to be
+ /// false-positives in tests are not issued.
+ void setTailorForTests(bool Val) { GetCurDiagState()->TailorForTests = Val; }
+ bool getTailorForTests() const { return GetCurDiagState()->TailorForTests; }
+
+ /// \brief Suppress all diagnostics, to silence the front end when we
/// know that we don't want any more diagnostics to be passed along to the
/// client
void setSuppressAllDiagnostics(bool Val = true) {
Index: include/clang/AST/CommentDiagnostic.h
===================================================================
--- include/clang/AST/CommentDiagnostic.h
+++ include/clang/AST/CommentDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define COMMENTSTART
#include "clang/Basic/DiagnosticCommentKinds.inc"
#undef DIAG
Index: include/clang/AST/ASTDiagnostic.h
===================================================================
--- include/clang/AST/ASTDiagnostic.h
+++ include/clang/AST/ASTDiagnostic.h
@@ -15,8 +15,9 @@
namespace clang {
namespace diag {
enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, HIDEINTESTS, CATEGORY) \
+ ENUM,
#define ASTSTART
#include "clang/Basic/DiagnosticASTKinds.inc"
#undef DIAG
Index: docs/UsersManual.rst
===================================================================
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -139,6 +139,10 @@
Enable warnings from system headers.
+.. option:: -Wtests
+
+ Disable some warnings that are very likely a false-positives in test code.
+
.. option:: -ferror-limit=123
Stop emitting diagnostics after 123 errors have been produced. The default is
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -51,6 +51,10 @@
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+- ``-Wtests`` flag was added. It is advised to pass it when building tests.
+ It disables some diagnostics for code that is very likely intentional in
+ tests, but is an issue elsewhere, e.g. self-assignment (``-Wself-assign``).
+
- ``-Wc++98-compat-extra-semi`` is a new flag, which was previously inseparable
from ``-Wc++98-compat-pedantic``. The latter still controls the new flag.
@@ -62,8 +66,9 @@
- ``-Wself-assign`` and ``-Wself-assign-field`` were extended to diagnose
self-assignment operations using overloaded operators (i.e. classes).
If you are doing such an assignment intentionally, e.g. in a unit test for
- a data structure, the warning can be suppressed by adding ``*&`` to the
- right-hand side or casting it to the appropriate reference type.
+ a data structure, the ``-Wself-assign`` warning can be suppressed by
+ passing ``-Wtests`` flag, or adding ``*&`` to the right-hand side or
+ casting it to the appropriate reference type.
Non-comprehensive list of changes in this release
-------------------------------------------------
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits