summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>2016-03-21 23:05:14 +0000
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>2016-03-21 23:05:14 +0000
commit1c158c192aa281129b884081b84dd843374cfd7a (patch)
treee8bb314ab91b5e0a842e2978787a74c0c17966b0
parent0a33abdfd215336ed0bd1c3dde78036f65f156c9 (diff)
downloadbcm5719-llvm-1c158c192aa281129b884081b84dd843374cfd7a.tar.gz
bcm5719-llvm-1c158c192aa281129b884081b84dd843374cfd7a.zip
Fixed some cases in the modularize assistant mode where header file names didn't translate to valid module names.
llvm-svn: 264001
-rw-r--r--clang-tools-extra/modularize/ModuleAssistant.cpp15
-rw-r--r--clang-tools-extra/test/modularize/NoProblemsAssistant.modularize5
2 files changed, 19 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);
diff --git a/clang-tools-extra/test/modularize/NoProblemsAssistant.modularize b/clang-tools-extra/test/modularize/NoProblemsAssistant.modularize
index 2f0559fc15f..7ddc72619af 100644
--- a/clang-tools-extra/test/modularize/NoProblemsAssistant.modularize
+++ b/clang-tools-extra/test/modularize/NoProblemsAssistant.modularize
@@ -7,6 +7,7 @@ SubModule1/Header1.h
SubModule1/Header2.h
SubModule2/Header3.h
SubModule2/Header4.h
+SubModule2/Header5-dash.dot.h
SubModule2.h
# CHECK: // Output/NoProblemsAssistant.txt
@@ -39,6 +40,10 @@ SubModule2.h
# CHECK-NEXT: header "SubModule2/Header4.h"
# CHECK-NEXT: export *
# CHECK-NEXT: }
+# CHECK-NEXT: module Header5_dash_dot {
+# CHECK-NEXT: header "SubModule2/Header5-dash.dot.h"
+# CHECK-NEXT: export *
+# CHECK-NEXT: }
# CHECK-NEXT: header "SubModule2.h"
# CHECK-NEXT: export *
# CHECK-NEXT: }
OpenPOWER on IntegriCloud