@@ -9459,7 +9459,7 @@ void ASTReader::diagnoseOdrViolations() {
9459
9459
// Used with err_module_odr_violation_mismatch_decl and
9460
9460
// note_module_odr_violation_mismatch_decl
9461
9461
// This list should be the same Decl's as in ODRHash::isWhiteListedDecl
9462
- enum RecordDiffType {
9462
+ enum ODRMismatchDecl {
9463
9463
EndOfClass,
9464
9464
PublicSpecifer,
9465
9465
PrivateSpecifer,
@@ -9477,7 +9477,7 @@ void ASTReader::diagnoseOdrViolations() {
9477
9477
9478
9478
// Used with err_module_odr_violation_mismatch_decl_diff and
9479
9479
// note_module_odr_violation_mismatch_decl_diff
9480
- enum ODRDeclDifference {
9480
+ enum ODRMismatchDeclDifference {
9481
9481
StaticAssertCondition,
9482
9482
StaticAssertMessage,
9483
9483
StaticAssertOnlyMessage,
@@ -9530,13 +9530,13 @@ void ASTReader::diagnoseOdrViolations() {
9530
9530
// in with operator<<
9531
9531
auto ODRDiagDeclError = [this ](NamedDecl *FirstRecord, StringRef FirstModule,
9532
9532
SourceLocation Loc, SourceRange Range,
9533
- ODRDeclDifference DiffType) {
9533
+ ODRMismatchDeclDifference DiffType) {
9534
9534
return Diag (Loc, diag::err_module_odr_violation_mismatch_decl_diff)
9535
9535
<< FirstRecord << FirstModule.empty () << FirstModule << Range
9536
9536
<< DiffType;
9537
9537
};
9538
9538
auto ODRDiagDeclNote = [this ](StringRef SecondModule, SourceLocation Loc,
9539
- SourceRange Range, ODRDeclDifference DiffType) {
9539
+ SourceRange Range, ODRMismatchDeclDifference DiffType) {
9540
9540
return Diag (Loc, diag::note_module_odr_violation_mismatch_decl_diff)
9541
9541
<< SecondModule << Range << DiffType;
9542
9542
};
@@ -9803,7 +9803,7 @@ void ASTReader::diagnoseOdrViolations() {
9803
9803
9804
9804
struct DiffResult {
9805
9805
Decl *FirstDecl = nullptr , *SecondDecl = nullptr ;
9806
- RecordDiffType FirstDiffType = Other, SecondDiffType = Other;
9806
+ ODRMismatchDecl FirstDiffType = Other, SecondDiffType = Other;
9807
9807
};
9808
9808
9809
9809
// If there is a diagnoseable difference, FirstDiffType and
@@ -9835,6 +9835,9 @@ void ASTReader::diagnoseOdrViolations() {
9835
9835
return DR;
9836
9836
};
9837
9837
9838
+ // Use this to diagnose that an unexpected Decl was encountered
9839
+ // or no difference was detected. This causes a generic error
9840
+ // message to be emitted.
9838
9841
auto DiagnoseODRUnexpected = [this ](DiffResult &DR, NamedDecl *FirstRecord,
9839
9842
StringRef FirstModule,
9840
9843
NamedDecl *SecondRecord,
@@ -9859,12 +9862,13 @@ void ASTReader::diagnoseOdrViolations() {
9859
9862
};
9860
9863
9861
9864
auto DiagnoseODRMismatch =
9862
- [this ](DiffResult &DR, TagDecl *FirstRecord, StringRef FirstModule,
9863
- TagDecl *SecondRecord, StringRef SecondModule) {
9865
+ [this ](DiffResult &DR, NamedDecl *FirstRecord, StringRef FirstModule,
9866
+ NamedDecl *SecondRecord, StringRef SecondModule) {
9864
9867
SourceLocation FirstLoc;
9865
9868
SourceRange FirstRange;
9866
- if (DR.FirstDiffType == EndOfClass) {
9867
- FirstLoc = FirstRecord->getBraceRange ().getEnd ();
9869
+ auto *FirstTag = dyn_cast<TagDecl>(FirstRecord);
9870
+ if (DR.FirstDiffType == EndOfClass && FirstTag) {
9871
+ FirstLoc = FirstTag->getBraceRange ().getEnd ();
9868
9872
} else {
9869
9873
FirstLoc = DR.FirstDecl ->getLocation ();
9870
9874
FirstRange = DR.FirstDecl ->getSourceRange ();
@@ -9875,8 +9879,9 @@ void ASTReader::diagnoseOdrViolations() {
9875
9879
9876
9880
SourceLocation SecondLoc;
9877
9881
SourceRange SecondRange;
9878
- if (DR.SecondDiffType == EndOfClass) {
9879
- SecondLoc = SecondRecord->getBraceRange ().getEnd ();
9882
+ auto *SecondTag = dyn_cast<TagDecl>(SecondRecord);
9883
+ if (DR.SecondDiffType == EndOfClass && SecondTag) {
9884
+ SecondLoc = SecondTag->getBraceRange ().getEnd ();
9880
9885
} else {
9881
9886
SecondLoc = DR.SecondDecl ->getLocation ();
9882
9887
SecondRange = DR.SecondDecl ->getSourceRange ();
@@ -10219,14 +10224,11 @@ void ASTReader::diagnoseOdrViolations() {
10219
10224
PopulateHashes (SecondHashes, SecondRecord, DC);
10220
10225
10221
10226
auto DR = FindTypeDiffs (FirstHashes, SecondHashes);
10222
- RecordDiffType FirstDiffType = DR.FirstDiffType ;
10223
- RecordDiffType SecondDiffType = DR.SecondDiffType ;
10227
+ ODRMismatchDecl FirstDiffType = DR.FirstDiffType ;
10228
+ ODRMismatchDecl SecondDiffType = DR.SecondDiffType ;
10224
10229
Decl *FirstDecl = DR.FirstDecl ;
10225
10230
Decl *SecondDecl = DR.SecondDecl ;
10226
10231
10227
- // Reaching this point means an unexpected Decl was encountered
10228
- // or no difference was detected. This causes a generic error
10229
- // message to be emitted.
10230
10232
if (FirstDiffType == Other || SecondDiffType == Other) {
10231
10233
DiagnoseODRUnexpected (DR, FirstRecord, FirstModule, SecondRecord,
10232
10234
SecondModule);
@@ -11128,14 +11130,11 @@ void ASTReader::diagnoseOdrViolations() {
11128
11130
PopulateHashes (SecondHashes, SecondRecord, DC);
11129
11131
11130
11132
auto DR = FindTypeDiffs (FirstHashes, SecondHashes);
11131
- RecordDiffType FirstDiffType = DR.FirstDiffType ;
11132
- RecordDiffType SecondDiffType = DR.SecondDiffType ;
11133
+ ODRMismatchDecl FirstDiffType = DR.FirstDiffType ;
11134
+ ODRMismatchDecl SecondDiffType = DR.SecondDiffType ;
11133
11135
Decl *FirstDecl = DR.FirstDecl ;
11134
11136
Decl *SecondDecl = DR.SecondDecl ;
11135
11137
11136
- // Reaching this point means an unexpected Decl was encountered
11137
- // or no difference was detected. This causes a generic error
11138
- // message to be emitted.
11139
11138
if (FirstDiffType == Other || SecondDiffType == Other) {
11140
11139
DiagnoseODRUnexpected (DR, FirstRecord, FirstModule, SecondRecord,
11141
11140
SecondModule);
0 commit comments