[clang-tools-extra] r239122 - Fixed modularize to warn about missing headers referenced in a module map.
John Thompson
John.Thompson.JTSoftware at gmail.com
Thu Jun 4 16:35:19 PDT 2015
Author: jtsoftware
Date: Thu Jun 4 18:35:19 2015
New Revision: 239122
URL: http://llvm.org/viewvc/llvm-project?rev=239122&view=rev
Log:
Fixed modularize to warn about missing headers referenced in a module map.
Added:
clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/
clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/Level1A.h
clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/module.modulemap
clang-tools-extra/trunk/test/modularize/ProblemsMissingHeader.modularize
Modified:
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.h
Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=239122&r1=239121&r2=239122&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Thu Jun 4 18:35:19 2015
@@ -221,13 +221,13 @@ bool CoverageChecker::collectModuleHeade
}
for (auto &HeaderKind : Mod.Headers)
- for (auto &Header : HeaderKind)
- ModuleMapHeadersSet.insert(ModularizeUtilities::getCanonicalPath(
- Header.Entry->getName()));
+ for (auto &Header : HeaderKind)
+ ModuleMapHeadersSet.insert(ModularizeUtilities::getCanonicalPath(
+ Header.Entry->getName()));
for (Module::submodule_const_iterator MI = Mod.submodule_begin(),
- MIEnd = Mod.submodule_end();
- MI != MIEnd; ++MI)
+ MIEnd = Mod.submodule_end();
+ MI != MIEnd; ++MI)
collectModuleHeaders(**MI);
return true;
Modified: clang-tools-extra/trunk/modularize/Modularize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/Modularize.cpp?rev=239122&r1=239121&r2=239122&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
+++ clang-tools-extra/trunk/modularize/Modularize.cpp Thu Jun 4 18:35:19 2015
@@ -738,8 +738,8 @@ int main(int Argc, const char **Argv) {
ListFileNames, HeaderPrefix));
// Get header file names and dependencies.
- ModUtil->loadAllHeaderListsAndDependencies();
-
+ if (ModUtil->loadAllHeaderListsAndDependencies())
+ HadErrors = 1;
// If we are in assistant mode, output the module map and quit.
if (ModuleMapPath.length() != 0) {
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=239122&r1=239121&r2=239122&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Thu Jun 4 18:35:19 2015
@@ -46,6 +46,7 @@ ModularizeUtilities::ModularizeUtilities
: InputFilePaths(InputPaths),
HeaderPrefix(Prefix),
HasModuleMap(false),
+ MissingHeaderCount(0),
// Init clang stuff needed for loading the module map and preprocessing.
LangOpts(new LangOptions()), DiagIDs(new DiagnosticIDs()),
DiagnosticOpts(new DiagnosticOptions()),
@@ -234,6 +235,9 @@ std::error_code ModularizeUtilities::loa
// Do matching end call.
DC.EndSourceFile();
+ // Reset missing header count.
+ MissingHeaderCount = 0;
+
if (!collectModuleMapHeaders(ModMap.get()))
return std::error_code(1, std::generic_category());
@@ -243,6 +247,10 @@ std::error_code ModularizeUtilities::loa
// Indicate we are using module maps.
HasModuleMap = true;
+ // Return code of 1 for missing headers.
+ if (MissingHeaderCount)
+ return std::error_code(1, std::generic_category());
+
return std::error_code();
}
@@ -310,6 +318,17 @@ bool ModularizeUtilities::collectModuleH
HeaderFileNames.push_back(HeaderPath);
}
+ int MissingCountThisModule = Mod.MissingHeaders.size();
+
+ for (int Index = 0; Index < MissingCountThisModule; ++Index) {
+ std::string MissingFile = Mod.MissingHeaders[Index].FileName;
+ SourceLocation Loc = Mod.MissingHeaders[Index].FileNameLoc;
+ errs() << Loc.printToString(*SourceMgr)
+ << ": error : Header not found: " << MissingFile << "\n";
+ }
+
+ MissingHeaderCount += MissingCountThisModule;
+
return true;
}
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.h?rev=239122&r1=239121&r2=239122&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.h (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.h Thu Jun 4 18:35:19 2015
@@ -52,6 +52,8 @@ public:
DependencyMap Dependencies;
/// True if we have module maps.
bool HasModuleMap;
+ /// Missing header count.
+ int MissingHeaderCount;
// Functions.
Added: clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/Level1A.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/Level1A.h?rev=239122&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/Level1A.h (added)
+++ clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/Level1A.h Thu Jun 4 18:35:19 2015
@@ -0,0 +1 @@
+#define MACRO_1A 1
Added: clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/module.modulemap?rev=239122&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/module.modulemap (added)
+++ clang-tools-extra/trunk/test/modularize/Inputs/MissingHeader/module.modulemap Thu Jun 4 18:35:19 2015
@@ -0,0 +1,10 @@
+// module.map
+
+module Level1A {
+ header "Level1A.h"
+ export *
+}
+module Missing {
+ header "Missing.h"
+ export *
+}
Added: clang-tools-extra/trunk/test/modularize/ProblemsMissingHeader.modularize
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/ProblemsMissingHeader.modularize?rev=239122&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/modularize/ProblemsMissingHeader.modularize (added)
+++ clang-tools-extra/trunk/test/modularize/ProblemsMissingHeader.modularize Thu Jun 4 18:35:19 2015
@@ -0,0 +1,3 @@
+# RUN: not modularize %S/Inputs/MissingHeader/module.modulemap 2>&1 | FileCheck %s
+
+# CHECK: {{.*}}{{[/\\]}}Inputs/MissingHeader/module.modulemap:8:10: error : Header not found: Missing.h
More information about the cfe-commits
mailing list