Skip to content

Commit 4656cc1

Browse files
committed
Don't create a SwiftASTContext just for ClearModuleDependentCaches() (NFC)
1 parent be90eef commit 4656cc1

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,13 +1335,18 @@ SwiftASTContext *TypeSystemSwiftTypeRef::GetSwiftASTContext() const {
13351335
return m_swift_ast_context;
13361336
}
13371337

1338+
SwiftASTContext *TypeSystemSwiftTypeRef::GetSwiftASTContextOrNull() const {
1339+
return m_swift_ast_context;
1340+
}
1341+
13381342
void TypeSystemSwiftTypeRef::SetTriple(const llvm::Triple triple) {
13391343
if (auto *swift_ast_context = GetSwiftASTContext())
13401344
swift_ast_context->SetTriple(triple);
13411345
}
13421346

13431347
void TypeSystemSwiftTypeRef::ClearModuleDependentCaches() {
1344-
if (auto *swift_ast_context = GetSwiftASTContext())
1348+
// There is no need to notify a not-yet created SwiftASTContext to reset.
1349+
if (auto *swift_ast_context = GetSwiftASTContextOrNull())
13451350
swift_ast_context->ClearModuleDependentCaches();
13461351
}
13471352
const char *TypeSystemSwiftTypeRef::AsMangledName(opaque_compiler_type_t type) {

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
5757
~TypeSystemSwiftTypeRef();
5858
TypeSystemSwiftTypeRef(Module &module);
5959
TypeSystemSwiftTypeRef(SwiftASTContextForExpressions &swift_ast_context);
60+
/// Get the corresponding SwiftASTContext, and create one if necessary.
6061
SwiftASTContext *GetSwiftASTContext() const override;
62+
/// Return SwiftASTContext, iff one has already been created.
63+
SwiftASTContext *GetSwiftASTContextOrNull() const;
6164
TypeSystemSwiftTypeRef &GetTypeSystemSwiftTypeRef() override { return *this; }
6265
void SetTriple(const llvm::Triple triple) override;
6366
void ClearModuleDependentCaches() override;

lldb/test/API/lang/swift/clangimporter/rewrite_clang_paths/TestSwiftRewriteClangPaths.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def dotest(self, remap):
8787
self.expect("fr var foo", comment, substrs=["x", "23"])
8888
self.expect("fr var bar", comment, substrs=["y", "42"])
8989
self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
90+
else:
91+
self.expect("p foo", error=True)
9092

9193
# Scan through the types log.
9294
errs = 0

lldb/test/API/lang/swift/parseable_interfaces/shared/TestSwiftInterfaceNoDebugInfo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def test_prebuilt_cache_location(self):
5959
lldbutil.run_to_source_breakpoint(
6060
self, "break here", lldb.SBFileSpec("main.swift"),
6161
exe_name=self.getBuildArtifact("main"))
62+
self.expect("expr 1")
6263

6364
# Check the prebuilt cache path in the log output
6465
prefix = 'Using prebuilt Swift module cache path: '

0 commit comments

Comments
 (0)