================
@@ -881,6 +886,35 @@ diagnoseFrameworkInclude(DiagnosticsEngine &Diags,
SourceLocation IncludeLoc,
<< IncludeFilename;
}
+/// Return true if a shadow has been detected and the caller should
+/// stop and return the first-found file and module, false otherwise.
+static bool checkAndStoreCandidate(
+ ModuleMap::KnownHeader *SuggestedModule, OptionalFileEntryRef
CandidateFile,
+ StringRef CandidateDir, DiagnosticsEngine &Diags, StringRef Filename,
+ SourceLocation IncludeLoc, ModuleMap::KnownHeader &FirstModule,
+ OptionalFileEntryRef &FirstHeader, SmallString<1024> &FirstDir) {
+ if (!FirstHeader) {
+ // Found the first candidate
+ FirstHeader = CandidateFile;
+ FirstDir = CandidateDir;
+ if (SuggestedModule)
+ FirstModule = *SuggestedModule;
+ return false;
+ }
+
+ if (FirstDir != CandidateDir) {
+ // Found a second candidate from a different directory
+ Diags.Report(IncludeLoc, diag::warn_header_shadowed)
+ << Filename << FirstDir << CandidateDir;
+ if (SuggestedModule)
+ *SuggestedModule = FirstModule;
+ return true;
+ }
+
+ // Found a candidate from the same directory as the first one
+ return false;
----------------
Jinjie-Huang wrote:
The new warning is used to diagnose header files with the same name. And as
mentioned below, it might be possible to incorporate the logic of the new
warning into 'ext_pp_include_search_ms', I’ll give it a try.
https://github.com/llvm/llvm-project/pull/162491
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits