kadircet created this revision. kadircet requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
A header spelling in a source file could potentially mean multiple sources, especially in projects with multiple include search paths. We try to eliminate this ambiguity by using the resolved path in the diagnostics. This should improve the life of both the developers and the tooling. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103797 Files: clang/lib/Lex/ModuleMap.cpp clang/test/Modules/declare-use1.cpp clang/test/Modules/declare-use2.cpp clang/test/Modules/declare-use3.cpp clang/test/Modules/header-attribs.cpp clang/test/Modules/strict-decluse-headers.cpp clang/test/Modules/strict-decluse.cpp clang/test/Modules/textual-headers.cpp
Index: clang/test/Modules/textual-headers.cpp =================================================================== --- clang/test/Modules/textual-headers.cpp +++ clang/test/Modules/textual-headers.cpp @@ -6,13 +6,13 @@ #include "k.h" #define GIMME_AN_L -#include "l.h" // expected-error {{module XG does not depend on a module exporting 'l.h'}} +#include "l.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/l.h'}} -#include "m2.h" // expected-error {{module XG does not depend on a module exporting 'm2.h'}} +#include "m2.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/m2.h'}} const int use_m = m; // expected-error {{undeclared identifier}} #define GIMME_AN_M -#include "m.h" // expected-error {{use of private header from outside its module: 'm.h'}} +#include "m.h" // expected-error-re {{use of private header from outside its module: '{{.*}}/m.h'}} const int use_m_2 = m; const int g = k + l; Index: clang/test/Modules/strict-decluse.cpp =================================================================== --- clang/test/Modules/strict-decluse.cpp +++ clang/test/Modules/strict-decluse.cpp @@ -3,7 +3,7 @@ #include "g.h" #include "e.h" -#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}} -#include "i.h" // expected-error {{module XG does not depend on a module exporting 'i.h'}} +#include "f.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/f.h'}} +#include "i.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/i.h'}} const int g2 = g1 + e + f + aux_i; Index: clang/test/Modules/strict-decluse-headers.cpp =================================================================== --- clang/test/Modules/strict-decluse-headers.cpp +++ clang/test/Modules/strict-decluse-headers.cpp @@ -14,4 +14,4 @@ // Don't crash on this: (FIXME: we should produce an error that the specified file is not part of the specified module) // RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/foo.h // -// CHECK: module X does not depend on a module exporting 'foo.h' +// CHECK: module X does not depend on a module exporting '{{.*}}/foo.h' Index: clang/test/Modules/header-attribs.cpp =================================================================== --- clang/test/Modules/header-attribs.cpp +++ clang/test/Modules/header-attribs.cpp @@ -3,8 +3,8 @@ // RUN: not %clang_cc1 -fmodules -I%S/Inputs/header-attribs -emit-module -x c++-module-map %S/Inputs/header-attribs/modular.modulemap -fmodules-cache-path=%t -fmodule-name=A 2>&1 | FileCheck %s --check-prefix BUILD-MODULAR #include "foo.h" // ok, stats match -#include "bar.h" // expected-error {{does not depend on a module exporting 'bar.h'}} -#include "baz.h" // expected-error {{does not depend on a module exporting 'baz.h'}} +#include "bar.h" // expected-error-re {{does not depend on a module exporting '{{.*}}/bar.h'}} +#include "baz.h" // expected-error-re {{does not depend on a module exporting '{{.*}}/baz.h'}} // FIXME: Explain why the 'bar.h' found on disk doesn't match the module map. // BUILD-MODULAR: error: header 'bar.h' not found Index: clang/test/Modules/declare-use3.cpp =================================================================== --- clang/test/Modules/declare-use3.cpp +++ clang/test/Modules/declare-use3.cpp @@ -1,4 +1,4 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -include "g.h" -include "e.h" -include "f.h" -include "i.h" -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify -// expected-error {{module XG does not depend on a module exporting 'f.h'}} +// expected-error-re {{module XG does not depend on a module exporting '{{.*}}/f.h'}} const int g2 = g1 + e + f + aux_i; Index: clang/test/Modules/declare-use2.cpp =================================================================== --- clang/test/Modules/declare-use2.cpp +++ clang/test/Modules/declare-use2.cpp @@ -3,5 +3,5 @@ #include "h.h" #include "e.h" -#include "f.h" // expected-error {{module XH does not depend on a module exporting 'f.h'}} +#include "f.h" // expected-error-re {{module XH does not depend on a module exporting '{{.*}}/f.h'}} const int h2 = h1+e+f; Index: clang/test/Modules/declare-use1.cpp =================================================================== --- clang/test/Modules/declare-use1.cpp +++ clang/test/Modules/declare-use1.cpp @@ -3,7 +3,7 @@ #include "g.h" #include "e.h" -#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}} +#include "f.h" // expected-error-re {{module XG does not depend on a module exporting '{{.*}}/f.h'}} #include "i.h" #include "sub.h" const int g2 = g1 + e + f + aux_i + sub; Index: clang/lib/Lex/ModuleMap.cpp =================================================================== --- clang/lib/Lex/ModuleMap.cpp +++ clang/lib/Lex/ModuleMap.cpp @@ -516,14 +516,14 @@ // We have found a header, but it is private. if (Private) { Diags.Report(FilenameLoc, diag::warn_use_of_private_header_outside_module) - << Filename; + << File->getName(); return; } // We have found a module, but we don't use it. if (NotUsed) { Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module) - << RequestingModule->getTopLevelModule()->Name << Filename; + << RequestingModule->getTopLevelModule()->Name << File->getName(); return; } @@ -534,7 +534,7 @@ if (RequestingModule && LangOpts.ModulesStrictDeclUse) { Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module) - << RequestingModule->getTopLevelModule()->Name << Filename; + << RequestingModule->getTopLevelModule()->Name << File->getName(); } else if (RequestingModule && RequestingModuleIsModuleInterface && LangOpts.isCompilingModule()) { // Do not diagnose when we are not compiling a module.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits