Skip to content

Commit 3a7b35e

Browse files
authored
Merge pull request #68965 from rmaz/fixasan
Fix ASAN use-after-scope in module-file-home-is-cwd.swift
2 parents e42bb73 + 1bc715a commit 3a7b35e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "clang/Lex/HeaderSearchOptions.h"
5252
#include "clang/Lex/Preprocessor.h"
5353
#include "clang/Serialization/ASTReader.h"
54+
#include "llvm/ADT/StringRef.h"
5455
#include "llvm/ADT/StringSet.h"
5556
#include "llvm/Config/config.h"
5657
#include "llvm/IR/Constants.h"
@@ -775,10 +776,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
775776
// include path set to the working directory.
776777
auto &HSI =
777778
CI.getClangPreprocessor().getHeaderSearchInfo().getHeaderSearchOpts();
778-
if (HSI.ModuleFileHomeIsCwd) {
779-
Desc = ASTSourceDescriptor(Desc.getModuleName(), Opts.DebugCompilationDir,
780-
Desc.getASTFile(), Desc.getSignature());
781-
}
779+
StringRef IncludePath =
780+
HSI.ModuleFileHomeIsCwd ? Opts.DebugCompilationDir : Desc.getPath();
782781

783782
// Handle Clang modules.
784783
if (ClangModule) {
@@ -800,11 +799,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
800799
ClangModule->Parent);
801800
}
802801
return getOrCreateModule(ClangModule, Parent, Desc.getModuleName(),
803-
Desc.getPath(), Signature, Desc.getASTFile());
802+
IncludePath, Signature, Desc.getASTFile());
804803
}
805804
// Handle PCH.
806805
return getOrCreateModule(Desc.getASTFile().bytes_begin(), nullptr,
807-
Desc.getModuleName(), Desc.getPath(), Signature,
806+
Desc.getModuleName(), IncludePath, Signature,
808807
Desc.getASTFile());
809808
};
810809

0 commit comments

Comments
 (0)