Skip to content

Commit 076397f

Browse files
authored
Revert "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics" (llvm#134036)
Reverts llvm#132348 Some tests are failing and I still need to figure out what is going on here.
1 parent a2ca2f3 commit 076397f

31 files changed

+93
-356
lines changed

clang/include/clang/Basic/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ macro(clang_diag_gen component)
88
-gen-clang-diags-enums -clang-component=${component}
99
SOURCE Diagnostic.td
1010
TARGET ClangDiagnostic${component}Enums)
11-
12-
clang_tablegen(Diagnostic${component}CompatIDs.inc
13-
-gen-clang-diags-compat-ids -clang-component=${component}
14-
SOURCE Diagnostic.td
15-
TARGET ClangDiagnostic${component}CompatIDs)
1611
endmacro(clang_diag_gen)
1712

1813
clang_diag_gen(Analysis)
@@ -36,11 +31,6 @@ clang_tablegen(DiagnosticIndexName.inc -gen-clang-diags-index-name
3631
SOURCE Diagnostic.td
3732
TARGET ClangDiagnosticIndexName)
3833

39-
clang_tablegen(DiagnosticAllCompatIDs.inc
40-
-gen-clang-diags-compat-ids
41-
SOURCE Diagnostic.td
42-
TARGET ClangDiagnosticAllCompatIDs)
43-
4434
clang_tablegen(AttrList.inc -gen-clang-attr-list
4535
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
4636
SOURCE Attr.td

clang/include/clang/Basic/Diagnostic.td

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,6 @@ class DefaultWarnNoWerror {
155155
}
156156
class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
157157

158-
class CompatWarningId<string name, int std, string diag, string diag_pre> {
159-
string Component = ?;
160-
string Name = name;
161-
string Diag = diag;
162-
string DiagPre = diag_pre;
163-
int Std = std;
164-
165-
// This is unused, but Tablegen will complain if it's missing because we define
166-
// the compatibility ids in the same place as the other diagnostics (which means
167-
// that we'll be inside a 'let CategoryName = "" in { ... }' block).
168-
string CategoryName = ?;
169-
}
170-
171158
// C++ compatibility warnings.
172159
multiclass CXXCompat<
173160
string message,
@@ -191,11 +178,6 @@ multiclass CXXCompat<
191178
"CXX98Compat",
192179
"CXXPre"#std_ver#"Compat"))>,
193180
DefaultIgnore;
194-
195-
def : CompatWarningId<
196-
NAME, std_ver,
197-
"compat_cxx"#std_ver#"_"#NAME,
198-
"compat_pre_cxx"#std_ver#"_"#NAME>;
199181
}
200182

201183
// These generate pairs of C++ compatibility warnings of the form:

clang/include/clang/Basic/DiagnosticAST.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticASTCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICAST_H

clang/include/clang/Basic/DiagnosticAnalysis.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ enum {
3535
#undef DIAG_ENUM_ITEM
3636
#undef DIAG_ENUM
3737
} // end namespace diag
38-
39-
namespace diag_compat {
40-
#define DIAG_COMPAT_IDS_BEGIN() enum {
41-
#define DIAG_COMPAT_IDS_END() \
42-
} \
43-
;
44-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
45-
#include "clang/Basic/DiagnosticAnalysisCompatIDs.inc"
46-
#undef DIAG_COMPAT_ID
47-
#undef DIAG_COMPAT_IDS_BEGIN
48-
#undef DIAG_COMPAT_IDS_END
49-
} // end namespace diag_compat
5038
} // end namespace clang
5139

5240
#endif // LLVM_CLANG_BASIC_DIAGNOSTICANALYSIS_H

clang/include/clang/Basic/DiagnosticComment.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticCommentCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICCOMMENT_H

clang/include/clang/Basic/DiagnosticCrossTU.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticCrossTUCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICCROSSTU_H

clang/include/clang/Basic/DiagnosticDriver.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticDriverCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICDRIVER_H

clang/include/clang/Basic/DiagnosticFrontend.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticFrontendCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICFRONTEND_H

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
namespace clang {
2626
class DiagnosticsEngine;
2727
class DiagnosticBuilder;
28-
class LangOptions;
2928
class SourceLocation;
3029

3130
// Import the diagnostic enums themselves.
@@ -105,18 +104,6 @@ namespace clang {
105104
};
106105
}
107106

108-
namespace diag_compat {
109-
#define DIAG_COMPAT_IDS_BEGIN() enum {
110-
#define DIAG_COMPAT_IDS_END() \
111-
} \
112-
;
113-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
114-
#include "clang/Basic/DiagnosticCommonCompatIDs.inc"
115-
#undef DIAG_COMPAT_ID
116-
#undef DIAG_COMPAT_IDS_BEGIN
117-
#undef DIAG_COMPAT_IDS_END
118-
} // end namespace diag_compat
119-
120107
class DiagnosticMapping {
121108
LLVM_PREFERRED_TYPE(diag::Severity)
122109
unsigned Severity : 3;
@@ -477,11 +464,6 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
477464
/// given group name.
478465
static StringRef getNearestOption(diag::Flavor Flavor, StringRef Group);
479466

480-
/// Get the appropriate diagnostic Id to use for issuing a compatibility
481-
/// diagnostic. For use by the various DiagCompat() helpers.
482-
static unsigned getCXXCompatDiagId(const LangOptions &LangOpts,
483-
unsigned CompatDiagId);
484-
485467
private:
486468
/// Classify the specified diagnostic ID into a Level, consumable by
487469
/// the DiagnosticClient.

clang/include/clang/Basic/DiagnosticInstallAPI.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,5 @@ enum {
3535
#undef DIAG_ENUM_ITEM
3636
#undef DIAG_ENUM
3737
} // namespace diag
38-
39-
namespace diag_compat {
40-
#define DIAG_COMPAT_IDS_BEGIN() enum {
41-
#define DIAG_COMPAT_IDS_END() \
42-
} \
43-
;
44-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
45-
#include "clang/Basic/DiagnosticInstallAPICompatIDs.inc"
46-
#undef DIAG_COMPAT_ID
47-
#undef DIAG_COMPAT_IDS_BEGIN
48-
#undef DIAG_COMPAT_IDS_END
49-
} // end namespace diag_compat
5038
} // namespace clang
5139
#endif // LLVM_CLANG_BASIC_DIAGNOSTICINSTALLAPI_H

clang/include/clang/Basic/DiagnosticLex.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ enum {
3535
#undef DIAG_ENUM_ITEM
3636
#undef DIAG_ENUM
3737
} // end namespace diag
38-
39-
namespace diag_compat {
40-
#define DIAG_COMPAT_IDS_BEGIN() enum {
41-
#define DIAG_COMPAT_IDS_END() \
42-
} \
43-
;
44-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
45-
#include "clang/Basic/DiagnosticLexCompatIDs.inc"
46-
#undef DIAG_COMPAT_ID
47-
#undef DIAG_COMPAT_IDS_BEGIN
48-
#undef DIAG_COMPAT_IDS_END
49-
} // end namespace diag_compat
5038
} // end namespace clang
5139

5240
#endif // LLVM_CLANG_BASIC_DIAGNOSTICLEX_H

clang/include/clang/Basic/DiagnosticParse.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticParseCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICPARSE_H

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
let Component = "Parse" in {
14-
let CategoryName = "Parse Issue" in {
15-
// C++11 compatibility with C++98.
16-
defm enum_fixed_underlying_type : CXX11Compat<
17-
"enumeration types with a fixed underlying type are",
18-
/*ext_warn=*/false>;
19-
}
2014

2115
def err_asm_qualifier_ignored : Error<
2216
"expected 'volatile', 'inline', 'goto', or '('">, CatInlineAsm;
@@ -113,6 +107,9 @@ def err_enumerator_list_missing_comma : Error<
113107
"missing ',' between enumerators">;
114108
def err_enumerator_unnamed_no_def : Error<
115109
"unnamed enumeration must be a definition">;
110+
def ext_cxx11_enum_fixed_underlying_type : Extension<
111+
"enumeration types with a fixed underlying type are a C++11 extension">,
112+
InGroup<CXX11>;
116113
def ext_ms_c_enum_fixed_underlying_type : Extension<
117114
"enumeration types with a fixed underlying type are a Microsoft extension">,
118115
InGroup<MicrosoftFixedEnum>;
@@ -122,6 +119,9 @@ def ext_c23_enum_fixed_underlying_type : Extension<
122119
def warn_c17_compat_enum_fixed_underlying_type : Warning<
123120
"enumeration types with a fixed underlying type are incompatible with C standards before C23">,
124121
DefaultIgnore, InGroup<CPre23Compat>;
122+
def warn_cxx98_compat_enum_fixed_underlying_type : Warning<
123+
"enumeration types with a fixed underlying type are incompatible with C++98">,
124+
InGroup<CXX98Compat>, DefaultIgnore;
125125
def ext_enum_base_in_type_specifier : ExtWarn<
126126
"non-defining declaration of enumeration with a fixed underlying type is "
127127
"only permitted as a standalone declaration"

clang/include/clang/Basic/DiagnosticRefactoring.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticRefactoringCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICREFACTORING_H

clang/include/clang/Basic/DiagnosticSema.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,7 @@ enum {
3535
#undef DIAG_ENUM_END
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
38-
3938
} // end namespace diag
40-
41-
namespace diag_compat {
42-
#define DIAG_COMPAT_IDS_BEGIN() enum {
43-
#define DIAG_COMPAT_IDS_END() \
44-
} \
45-
;
46-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
47-
#include "clang/Basic/DiagnosticSemaCompatIDs.inc"
48-
#undef DIAG_COMPAT_ID
49-
#undef DIAG_COMPAT_IDS_BEGIN
50-
#undef DIAG_COMPAT_IDS_END
51-
} // end namespace diag_compat
5239
} // end namespace clang
5340

5441
#endif // LLVM_CLANG_BASIC_DIAGNOSTICSEMA_H

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defm decomp_decl_cond : CXX26Compat<"structured binding declaration in a conditi
6161

6262
// Compatibility warnings duplicated across multiple language versions.
6363
foreach std = [14, 20, 23] in {
64-
defm cxx#std#_constexpr_body_invalid_stmt : CXXCompat<
64+
defm constexpr_body_invalid_stmt : CXXCompat<
6565
"use of this statement in a constexpr %select{function|constructor}0 is", std>;
6666
}
6767

clang/include/clang/Basic/DiagnosticSerialization.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ enum {
3636
#undef DIAG_ENUM_ITEM
3737
#undef DIAG_ENUM
3838
} // end namespace diag
39-
40-
namespace diag_compat {
41-
#define DIAG_COMPAT_IDS_BEGIN() enum {
42-
#define DIAG_COMPAT_IDS_END() \
43-
} \
44-
;
45-
#define DIAG_COMPAT_ID(IDX, NAME, ...) NAME = IDX,
46-
#include "clang/Basic/DiagnosticSerializationCompatIDs.inc"
47-
#undef DIAG_COMPAT_ID
48-
#undef DIAG_COMPAT_IDS_BEGIN
49-
#undef DIAG_COMPAT_IDS_END
50-
} // end namespace diag_compat
5139
} // end namespace clang
5240

5341
#endif // LLVM_CLANG_BASIC_DIAGNOSTICSERIALIZATION_H

clang/include/clang/Parse/Parser.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,6 @@ class Parser : public CodeCompletionHandler {
12631263
return Diag(Tok, DiagID);
12641264
}
12651265

1266-
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId);
1267-
DiagnosticBuilder DiagCompat(const Token &Tok, unsigned CompatDiagId);
1268-
DiagnosticBuilder DiagCompat(unsigned CompatDiagId) {
1269-
return DiagCompat(Tok, CompatDiagId);
1270-
}
1271-
12721266
private:
12731267
void SuggestParentheses(SourceLocation Loc, unsigned DK,
12741268
SourceRange ParenRange);

clang/include/clang/Sema/SemaBase.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@ class SemaBase {
219219
SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic &PD,
220220
bool DeferHint = false);
221221

222-
/// Emit a compatibility diagnostic.
223-
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId,
224-
bool DeferHint = false);
225-
226222
/// Build a partial diagnostic.
227223
PartialDiagnostic PDiag(unsigned DiagID = 0);
228224
};

0 commit comments

Comments
 (0)