Skip to content

Commit 43d549d

Browse files
committed
Out-param SmallVectorImpl<char>
1 parent 6e845bb commit 43d549d

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ class CompilerInstance : public ModuleLoader {
699699
GetDependencyDirectives = std::move(Getter);
700700
}
701701

702-
static SmallString<256> normalizeModuleCachePath(FileManager &FileMgr,
703-
StringRef ModuleCachePath);
702+
static void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
703+
SmallVectorImpl<char> &NormalizedPath);
704704
std::string getSpecificModuleCachePath(StringRef ModuleHash);
705705
std::string getSpecificModuleCachePath() {
706706
return getSpecificModuleCachePath(getInvocation().getModuleHash());

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,12 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
547547
PP->setDependencyDirectivesGetter(*GetDependencyDirectives);
548548
}
549549

550-
SmallString<256>
551-
CompilerInstance::normalizeModuleCachePath(FileManager &FileMgr,
552-
StringRef ModuleCachePath) {
553-
SmallString<256> NormalizedModuleCachePath(ModuleCachePath);
554-
FileMgr.makeAbsolutePath(NormalizedModuleCachePath);
555-
llvm::sys::path::remove_dots(NormalizedModuleCachePath);
556-
return NormalizedModuleCachePath;
550+
void CompilerInstance::normalizeModuleCachePath(
551+
FileManager &FileMgr, StringRef Path,
552+
SmallVectorImpl<char> &NormalizedPath) {
553+
NormalizedPath.assign(Path.begin(), Path.end());
554+
FileMgr.makeAbsolutePath(NormalizedPath);
555+
llvm::sys::path::remove_dots(NormalizedPath);
557556
}
558557

559558
std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) {
@@ -563,8 +562,9 @@ std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) {
563562
return "";
564563

565564
// Set up the module path, including the hash for the module-creation options.
566-
SmallString<256> SpecificModuleCache =
567-
normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath);
565+
SmallString<256> SpecificModuleCache;
566+
normalizeModuleCachePath(*FileMgr, getHeaderSearchOpts().ModuleCachePath,
567+
SpecificModuleCache);
568568
if (!getHeaderSearchOpts().DisableModuleHash)
569569
llvm::sys::path::append(SpecificModuleCache, ModuleHash);
570570
return std::string(SpecificModuleCache);

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,8 +1711,9 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
17111711
const HeaderSearchOptions &HSOpts =
17121712
PP.getHeaderSearchInfo().getHeaderSearchOpts();
17131713

1714-
auto HSOpts_ModuleCachePath = CompilerInstance::normalizeModuleCachePath(
1715-
PP.getFileManager(), HSOpts.ModuleCachePath);
1714+
SmallString<256> HSOpts_ModuleCachePath;
1715+
CompilerInstance::normalizeModuleCachePath(
1716+
PP.getFileManager(), HSOpts.ModuleCachePath, HSOpts_ModuleCachePath);
17161717

17171718
AddString(HSOpts.Sysroot, Record);
17181719
AddString(HSOpts.ResourceDir, Record);

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,10 @@ class DependencyScanningAction {
448448

449449
// Use the dependency scanning optimized file system if requested to do so.
450450
if (DepFS) {
451-
auto ModulesCachePath = CompilerInstance::normalizeModuleCachePath(
452-
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath);
451+
SmallString<256> ModulesCachePath;
452+
CompilerInstance::normalizeModuleCachePath(
453+
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
454+
ModulesCachePath);
453455
DepFS->resetBypassedPathPrefix();
454456
if (!ModulesCachePath.empty())
455457
DepFS->setBypassedPathPrefix(ModulesCachePath);

0 commit comments

Comments
 (0)