summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/modularize/ModuleAssistant.cpp
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 /clang-tools-extra/modularize/ModuleAssistant.cpp
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
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