summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/modularize/ModuleAssistant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/modularize/ModuleAssistant.cpp')
-rw-r--r--clang-tools-extra/modularize/ModuleAssistant.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 64bb9b4804c..e1c32dfaa82 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -99,7 +99,7 @@ bool Module::output(llvm::raw_fd_ostream &OS, int Indent) {
E = HeaderFileNames.end();
I != E; ++I) {
OS.indent(Indent);
- if (IsProblem)
+ if (IsProblem || strstr((*I).c_str(), ".inl"))
OS << "exclude header \"" << *I << "\"\n";
else
OS << "header \"" << *I << "\"\n";
@@ -157,6 +157,18 @@ ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) {
return SafeName;
}
+// Convert module name to a non-keyword.
+// Prepends a '_' to the name if and only if the name is a keyword.
+static std::string
+ensureVaidModuleName(llvm::StringRef MightBeInvalidName) {
+ std::string SafeName = MightBeInvalidName;
+ std::replace(SafeName.begin(), SafeName.end(), '-', '_');
+ std::replace(SafeName.begin(), SafeName.end(), '.', '_');
+ if (isdigit(SafeName[0]))
+ SafeName = "_" + SafeName;
+ return SafeName;
+}
+
// Add one module, given a header file path.
static bool addModuleDescription(Module *RootModule,
llvm::StringRef HeaderFilePath,
@@ -195,6 +207,7 @@ static bool addModuleDescription(Module *RootModule,
continue;
std::string Stem = llvm::sys::path::stem(*I);
Stem = ensureNoCollisionWithReservedName(Stem);
+ Stem = ensureVaidModuleName(Stem);
Module *SubModule = CurrentModule->findSubModule(Stem);
if (!SubModule) {
SubModule = new Module(Stem, IsProblemFile);
OpenPOWER on IntegriCloud