@@ -10012,34 +10012,35 @@ void ASTReader::diagnoseOdrViolations() {
10012
10012
}
10013
10013
};
10014
10014
10015
- auto DiagnoseODRMismatch =
10016
- [this ](DiffResult &DR, NamedDecl *FirstRecord, StringRef FirstModule,
10017
- NamedDecl *SecondRecord, StringRef SecondModule) {
10018
- SourceLocation FirstLoc;
10019
- SourceRange FirstRange;
10020
- auto *FirstTag = dyn_cast<TagDecl>(FirstRecord);
10021
- if (DR.FirstDiffType == EndOfClass && FirstTag) {
10022
- FirstLoc = FirstTag->getBraceRange ().getEnd ();
10023
- } else {
10024
- FirstLoc = DR.FirstDecl ->getLocation ();
10025
- FirstRange = DR.FirstDecl ->getSourceRange ();
10026
- }
10027
- Diag (FirstLoc, diag::err_module_odr_violation_mismatch_decl)
10028
- << FirstRecord << FirstModule.empty () << FirstModule << FirstRange
10029
- << DR.FirstDiffType ;
10030
-
10031
- SourceLocation SecondLoc;
10032
- SourceRange SecondRange;
10033
- auto *SecondTag = dyn_cast<TagDecl>(SecondRecord);
10034
- if (DR.SecondDiffType == EndOfClass && SecondTag) {
10035
- SecondLoc = SecondTag->getBraceRange ().getEnd ();
10036
- } else {
10037
- SecondLoc = DR.SecondDecl ->getLocation ();
10038
- SecondRange = DR.SecondDecl ->getSourceRange ();
10039
- }
10040
- Diag (SecondLoc, diag::note_module_odr_violation_mismatch_decl)
10041
- << SecondModule << SecondRange << DR.SecondDiffType ;
10042
- };
10015
+ auto DiagnoseODRMismatch = [this ](DiffResult &DR, NamedDecl *FirstRecord,
10016
+ StringRef FirstModule,
10017
+ NamedDecl *SecondRecord,
10018
+ StringRef SecondModule) {
10019
+ auto GetMismatchedDeclLoc = [](const NamedDecl *Container,
10020
+ ODRMismatchDecl DiffType, const Decl *D) {
10021
+ SourceLocation Loc;
10022
+ SourceRange Range;
10023
+ auto *Tag = dyn_cast<TagDecl>(Container);
10024
+ if (DiffType == EndOfClass && Tag) {
10025
+ Loc = Tag->getBraceRange ().getEnd ();
10026
+ } else {
10027
+ Loc = D->getLocation ();
10028
+ Range = D->getSourceRange ();
10029
+ }
10030
+ return std::make_pair (Loc, Range);
10031
+ };
10032
+
10033
+ auto FirstDiagInfo =
10034
+ GetMismatchedDeclLoc (FirstRecord, DR.FirstDiffType , DR.FirstDecl );
10035
+ Diag (FirstDiagInfo.first , diag::err_module_odr_violation_mismatch_decl)
10036
+ << FirstRecord << FirstModule.empty () << FirstModule
10037
+ << FirstDiagInfo.second << DR.FirstDiffType ;
10038
+
10039
+ auto SecondDiagInfo =
10040
+ GetMismatchedDeclLoc (SecondRecord, DR.SecondDiffType , DR.SecondDecl );
10041
+ Diag (SecondDiagInfo.first , diag::note_module_odr_violation_mismatch_decl)
10042
+ << SecondModule << SecondDiagInfo.second << DR.SecondDiffType ;
10043
+ };
10043
10044
10044
10045
// Issue any pending ODR-failure diagnostics.
10045
10046
for (auto &Merge : OdrMergeFailures) {
0 commit comments