Skip to content

Commit 0cd9d8a

Browse files
committed
Revert "[clang-cl] Accept #pragma warning(disable : N) for some N"
because it causes `error: error reading '/wd4091'` errors in compiler-rt builds.
1 parent 27451a0 commit 0cd9d8a

File tree

18 files changed

+28
-175
lines changed

18 files changed

+28
-175
lines changed

clang/include/clang/Basic/CLWarnings.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

clang/include/clang/Basic/Diagnostic.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,6 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
807807
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group,
808808
diag::Severity Map,
809809
SourceLocation Loc = SourceLocation());
810-
bool setSeverityForGroup(diag::Flavor Flavor, diag::Group Group,
811-
diag::Severity Map,
812-
SourceLocation Loc = SourceLocation());
813810

814811
/// Set the warning-as-error flag for the given diagnostic group.
815812
///

clang/include/clang/Basic/DiagnosticCategories.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ namespace clang {
1919
#undef GET_CATEGORY_TABLE
2020
DiagCat_NUM_CATEGORIES
2121
};
22-
23-
enum class Group {
24-
#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) GroupName,
25-
#include "clang/Basic/DiagnosticGroups.inc"
26-
#undef CATEGORY
27-
#undef DIAG_ENTRY
28-
};
2922
} // end namespace diag
3023
} // end namespace clang
3124

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ def Dangling : DiagGroup<"dangling", [DanglingField,
396396
DanglingGsl,
397397
ReturnStackAddress]>;
398398
def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
399-
def DllexportExplicitInstantiationDecl : DiagGroup<"dllexport-explicit-instantiation-decl">;
400399
def ExcessInitializers : DiagGroup<"excess-initializers">;
401400
def ExpansionToDefined : DiagGroup<"expansion-to-defined">;
402401
def FlagEnum : DiagGroup<"flag-enum">;

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ namespace clang {
2525

2626
// Import the diagnostic enums themselves.
2727
namespace diag {
28-
enum class Group;
29-
3028
// Size of each of the diagnostic categories.
3129
enum {
3230
DIAG_SIZE_COMMON = 300,
@@ -226,10 +224,6 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
226224
///
227225
static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault);
228226

229-
/// Given a group ID, returns the flag that toggles the group.
230-
/// For example, for Group::DeprecatedDeclarations, returns
231-
/// "deprecated-declarations".
232-
static StringRef getWarningOptionForGroup(diag::Group);
233227

234228
/// Return the lowest-level warning option that enables the specified
235229
/// diagnostic.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,7 @@ def warn_attribute_dllimport_static_field_definition : Warning<
33963396
InGroup<DiagGroup<"dllimport-static-field-def">>;
33973397
def warn_attribute_dllexport_explicit_instantiation_decl : Warning<
33983398
"explicit instantiation declaration should not be 'dllexport'">,
3399-
InGroup<DllexportExplicitInstantiationDecl>;
3399+
InGroup<DiagGroup<"dllexport-explicit-instantiation-decl">>;
34003400
def warn_attribute_dllexport_explicit_instantiation_def : Warning<
34013401
"'dllexport' attribute ignored on explicit instantiation definition">,
34023402
InGroup<IgnoredAttributes>;

clang/include/clang/Driver/Options.td

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6106,7 +6106,16 @@ def _SLASH_WX_ : CLFlag<"WX-">,
61066106
HelpText<"Do not treat warnings as errors (default)">,
61076107
Alias<W_Joined>, AliasArgs<["no-error"]>;
61086108
def _SLASH_w_flag : CLFlag<"w">, HelpText<"Disable all warnings">, Alias<w>;
6109-
def _SLASH_wd : CLCompileJoined<"wd">;
6109+
def _SLASH_wd4005 : CLFlag<"wd4005">, Alias<W_Joined>,
6110+
AliasArgs<["no-macro-redefined"]>;
6111+
def _SLASH_wd4018 : CLFlag<"wd4018">, Alias<W_Joined>,
6112+
AliasArgs<["no-sign-compare"]>;
6113+
def _SLASH_wd4100 : CLFlag<"wd4100">, Alias<W_Joined>,
6114+
AliasArgs<["no-unused-parameter"]>;
6115+
def _SLASH_wd4910 : CLFlag<"wd4910">, Alias<W_Joined>,
6116+
AliasArgs<["no-dllexport-explicit-instantiation-decl"]>;
6117+
def _SLASH_wd4996 : CLFlag<"wd4996">, Alias<W_Joined>,
6118+
AliasArgs<["no-deprecated-declarations"]>;
61106119
def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
61116120
Alias<vtordisp_mode_EQ>;
61126121
def _SLASH_X : CLFlag<"X">,

clang/lib/Basic/CLWarnings.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang/lib/Basic/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ endif()
3939
add_clang_library(clangBasic
4040
Attributes.cpp
4141
Builtins.cpp
42-
CLWarnings.cpp
4342
CharInfo.cpp
4443
CodeGenOptions.cpp
4544
Cuda.cpp

clang/lib/Basic/Diagnostic.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,6 @@ bool DiagnosticsEngine::setSeverityForGroup(diag::Flavor Flavor,
408408
return false;
409409
}
410410

411-
bool DiagnosticsEngine::setSeverityForGroup(diag::Flavor Flavor,
412-
diag::Group Group,
413-
diag::Severity Map,
414-
SourceLocation Loc) {
415-
return setSeverityForGroup(Flavor, Diags->getWarningOptionForGroup(Group),
416-
Map, Loc);
417-
}
418-
419411
bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group,
420412
bool Enabled) {
421413
// If we are enabling this feature, just set the diagnostic mappings to map to

clang/lib/Basic/DiagnosticIDs.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,23 +609,17 @@ namespace {
609609

610610
// Second the table of options, sorted by name for fast binary lookup.
611611
static const WarningOption OptionTable[] = {
612-
#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) \
613-
{FlagNameOffset, Members, SubGroups},
612+
#define GET_DIAG_TABLE
614613
#include "clang/Basic/DiagnosticGroups.inc"
615-
#undef DIAG_ENTRY
614+
#undef GET_DIAG_TABLE
616615
};
617616

618-
StringRef DiagnosticIDs::getWarningOptionForGroup(diag::Group Group) {
619-
return OptionTable[static_cast<int>(Group)].getName();
620-
}
621-
622617
/// getWarningOptionForDiag - Return the lowest-level warning option that
623618
/// enables the specified diagnostic. If there is no -Wfoo flag that controls
624619
/// the diagnostic, this returns null.
625620
StringRef DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) {
626621
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
627-
return getWarningOptionForGroup(
628-
static_cast<diag::Group>(Info->getOptionGroupIndex()));
622+
return OptionTable[Info->getOptionGroupIndex()].getName();
629623
return StringRef();
630624
}
631625

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "Hexagon.h"
2323
#include "MSP430.h"
2424
#include "PS4CPU.h"
25-
#include "clang/Basic/CLWarnings.h"
2625
#include "clang/Basic/CharInfo.h"
2726
#include "clang/Basic/CodeGenOptions.h"
2827
#include "clang/Basic/LangOptions.h"
@@ -5439,26 +5438,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54395438

54405439
Args.AddAllArgs(CmdArgs, options::OPT_R_Group);
54415440

5442-
for (const Arg *A :
5443-
Args.filtered(options::OPT_W_Group, options::OPT__SLASH_wd)) {
5444-
A->claim();
5445-
if (A->getOption().getID() == options::OPT__SLASH_wd) {
5446-
unsigned WarningNumber;
5447-
if (StringRef(A->getValue()).getAsInteger(10, WarningNumber)) {
5448-
D.Diag(diag::err_drv_invalid_int_value)
5449-
<< A->getAsString(Args) << A->getValue();
5450-
continue;
5451-
}
5452-
5453-
if (auto Group = diagGroupFromCLWarningID(WarningNumber)) {
5454-
CmdArgs.push_back(Args.MakeArgString(
5455-
"-Wno-" + DiagnosticIDs::getWarningOptionForGroup(*Group)));
5456-
continue;
5457-
}
5458-
}
5459-
A->render(Args, CmdArgs);
5460-
}
5461-
5441+
Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
54625442
if (Args.hasFlag(options::OPT_pedantic, options::OPT_no_pedantic, false))
54635443
CmdArgs.push_back("-pedantic");
54645444
Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors);

clang/lib/Lex/Pragma.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "clang/Lex/Pragma.h"
15-
#include "clang/Basic/CLWarnings.h"
1615
#include "clang/Basic/Diagnostic.h"
1716
#include "clang/Basic/DiagnosticLex.h"
1817
#include "clang/Basic/FileManager.h"
@@ -1414,15 +1413,12 @@ struct PragmaWarningHandler : public PragmaHandler {
14141413
return;
14151414
}
14161415
}
1417-
PP.getDiagnostics().pushMappings(DiagLoc);
14181416
if (Callbacks)
14191417
Callbacks->PragmaWarningPush(DiagLoc, Level);
14201418
} else if (II && II->isStr("pop")) {
14211419
// #pragma warning( pop )
14221420
PP.Lex(Tok);
1423-
if (!PP.getDiagnostics().popMappings(DiagLoc))
1424-
PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
1425-
else if (Callbacks)
1421+
if (Callbacks)
14261422
Callbacks->PragmaWarningPop(DiagLoc);
14271423
} else {
14281424
// #pragma warning( warning-specifier : warning-number-list
@@ -1486,22 +1482,6 @@ struct PragmaWarningHandler : public PragmaHandler {
14861482
}
14871483
Ids.push_back(int(Value));
14881484
}
1489-
1490-
// Only act on disable for now.
1491-
diag::Severity SV = diag::Severity();
1492-
if (Specifier == PPCallbacks::PWS_Disable)
1493-
SV = diag::Severity::Ignored;
1494-
if (SV != diag::Severity())
1495-
for (int Id : Ids) {
1496-
if (auto Group = diagGroupFromCLWarningID(Id)) {
1497-
bool unknownDiag = PP.getDiagnostics().setSeverityForGroup(
1498-
diag::Flavor::WarningOrError, *Group, SV, DiagLoc);
1499-
assert(!unknownDiag &&
1500-
"wd table should only contain known diags");
1501-
(void)unknownDiag;
1502-
}
1503-
}
1504-
15051485
if (Callbacks)
15061486
Callbacks->PragmaWarning(DiagLoc, Specifier, Ids);
15071487

clang/test/Driver/cl-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@
353353
// CHECK-C11: -std=c11
354354

355355
// For some warning ids, we can map from MSVC warning to Clang warning.
356-
// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
356+
// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
357357
// Wno: "-cc1"
358358
// Wno: "-Wno-macro-redefined"
359359
// Wno: "-Wno-unused-parameter"

clang/test/Sema/pragma-warning.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

clang/tools/diagtool/DiagnosticNames.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ const DiagnosticRecord &diagtool::getDiagnosticForID(short DiagID) {
6666

6767
// Second the table of options, sorted by name for fast binary lookup.
6868
static const GroupRecord OptionTable[] = {
69-
#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) \
70-
{FlagNameOffset, Members, SubGroups},
69+
#define GET_DIAG_TABLE
7170
#include "clang/Basic/DiagnosticGroups.inc"
72-
#undef DIAG_ENTRY
71+
#undef GET_DIAG_TABLE
7372
};
7473

7574
llvm::StringRef GroupRecord::getName() const {

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ namespace {
129129
};
130130

131131
struct GroupInfo {
132-
llvm::StringRef GroupName;
133132
std::vector<const Record*> DiagsInGroup;
134133
std::vector<std::string> SubGroups;
135134
unsigned IDNo;
@@ -175,7 +174,6 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
175174
Record *Group = DiagGroups[i];
176175
GroupInfo &GI =
177176
DiagsInGroup[std::string(Group->getValueAsString("GroupName"))];
178-
GI.GroupName = Group->getName();
179177
GI.Defs.push_back(Group);
180178

181179
std::vector<Record*> SubGroups = Group->getValueAsListOfDefs("SubGroups");
@@ -1281,8 +1279,8 @@ void clang::EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS,
12811279
OS << ", \"";
12821280
OS.write_escaped(DiagTextBuilder.buildForDefinition(&R)) << '"';
12831281

1284-
// Warning group associated with the diagnostic. This is stored as an index
1285-
// into the alphabetically sorted warning group table.
1282+
// Warning associated with the diagnostic. This is stored as an index into
1283+
// the alphabetically sorted warning table.
12861284
if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) {
12871285
std::map<std::string, GroupInfo>::iterator I = DiagsInGroup.find(
12881286
std::string(DI->getDef()->getValueAsString("GroupName")));
@@ -1489,20 +1487,18 @@ static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
14891487
for (auto const &I: DiagsInGroup)
14901488
MaxLen = std::max(MaxLen, (unsigned)I.first.size());
14911489

1492-
OS << "\n#ifdef DIAG_ENTRY\n";
1490+
OS << "\n#ifdef GET_DIAG_TABLE\n";
14931491
unsigned SubGroupIndex = 1, DiagArrayIndex = 1;
14941492
for (auto const &I: DiagsInGroup) {
14951493
// Group option string.
1496-
OS << "DIAG_ENTRY(";
1497-
OS << I.second.GroupName << " /* ";
1498-
1494+
OS << " { /* ";
14991495
if (I.first.find_first_not_of("abcdefghijklmnopqrstuvwxyz"
15001496
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
15011497
"0123456789!@#$%^*-+=:?") !=
15021498
std::string::npos)
15031499
PrintFatalError("Invalid character in diagnostic group '" + I.first +
15041500
"'");
1505-
OS << I.first << " */, ";
1501+
OS << I.first << " */ " << std::string(MaxLen - I.first.size(), ' ');
15061502
// Store a pascal-style length byte at the beginning of the string.
15071503
std::string Name = char(I.first.size()) + I.first;
15081504
OS << GroupNames.GetOrAddStringOffset(Name, false) << ", ";
@@ -1521,7 +1517,7 @@ static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
15211517
DiagArrayIndex += DiagsInPedantic.size();
15221518
DiagArrayIndex += V.size() + 1;
15231519
} else {
1524-
OS << "0, ";
1520+
OS << "/* Empty */ 0, ";
15251521
}
15261522

15271523
// Subgroups.
@@ -1534,12 +1530,12 @@ static void emitDiagTable(std::map<std::string, GroupInfo> &DiagsInGroup,
15341530
SubGroupIndex += GroupsInPedantic.size();
15351531
SubGroupIndex += SubGroups.size() + 1;
15361532
} else {
1537-
OS << "0";
1533+
OS << "/* Empty */ 0";
15381534
}
15391535

1540-
OS << ")\n";
1536+
OS << " },\n";
15411537
}
1542-
OS << "#endif // DIAG_ENTRY\n\n";
1538+
OS << "#endif // GET_DIAG_TABLE\n\n";
15431539
}
15441540

15451541
/// Emit the table of diagnostic categories.

llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static_library("Basic") {
5555
sources = [
5656
"Attributes.cpp",
5757
"Builtins.cpp",
58-
"CLWarnings.cpp",
5958
"CharInfo.cpp",
6059
"CodeGenOptions.cpp",
6160
"Cuda.cpp",

0 commit comments

Comments
 (0)