diff options
| author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2016-03-21 23:05:14 +0000 |
|---|---|---|
| committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2016-03-21 23:05:14 +0000 |
| commit | 345b712b472a42b80175a548bcf8877c5f8f573b (patch) | |
| tree | 4c48aa6d38388811e913ee039c1dc2ccd6ada510 /modularize/ModuleAssistant.cpp | |
| parent | 9c31a56df691380423cfe7ecbd56970f9c41468b (diff) | |
Fixed some cases in the modularize assistant mode where header file names didn't translate to valid module names.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@264001 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'modularize/ModuleAssistant.cpp')
| -rw-r--r-- | modularize/ModuleAssistant.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modularize/ModuleAssistant.cpp b/modularize/ModuleAssistant.cpp index 64bb9b48..e1c32dfa 100644 --- a/modularize/ModuleAssistant.cpp +++ b/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); |
