Skip to content

Use const versions of accessors, which don't assert that files is non #8203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,15 +1824,15 @@ GetASTBuffersFromModule(const std::string &m_description,
/// Detect whether a Swift module was "imported" by DWARFImporter.
/// All this *really* means is that it couldn't be loaded through any
/// other mechanism.
static bool IsDWARFImported(swift::ModuleDecl &module) {
return llvm::any_of(module.getFiles(), [](swift::FileUnit *file_unit) {
static bool IsDWARFImported(const swift::ModuleDecl &module) {
return llvm::any_of(module.getFiles(), [](const swift::FileUnit *file_unit) {
return (file_unit->getKind() == swift::FileUnitKind::DWARFModule);
});
}

/// Detect whether this is a proper Swift module.
static bool IsSerializedAST(swift::ModuleDecl &module) {
return llvm::any_of(module.getFiles(), [](swift::FileUnit *file_unit) {
static bool IsSerializedAST(const swift::ModuleDecl &module) {
return llvm::any_of(module.getFiles(), [](const swift::FileUnit *file_unit) {
return (file_unit->getKind() == swift::FileUnitKind::SerializedAST);
});
}
Expand Down Expand Up @@ -8488,14 +8488,14 @@ SwiftASTContextForExpressions::GetPersistentExpressionState() {
return GetTypeSystemSwiftTypeRef().GetPersistentExpressionState();
}

static void DescribeFileUnit(Stream &s, swift::FileUnit *file_unit) {
static void DescribeFileUnit(Stream &s, const swift::FileUnit *file_unit) {
s.PutCString("kind = ");

switch (file_unit->getKind()) {
case swift::FileUnitKind::Source: {
s.PutCString("Source, ");
if (swift::SourceFile *source_file =
llvm::dyn_cast<swift::SourceFile>(file_unit)) {
if (auto *source_file =
llvm::dyn_cast<const swift::SourceFile>(file_unit)) {
s.Printf("filename = \"%s\", ", source_file->getFilename().str().c_str());
s.PutCString("source file kind = ");
switch (source_file->Kind) {
Expand Down Expand Up @@ -8529,7 +8529,7 @@ static void DescribeFileUnit(Stream &s, swift::FileUnit *file_unit) {
s.PutCString("Serialized Swift AST, ");
else
s.PutCString("Clang module, ");
swift::LoadedFile *loaded_file = swift::cast<swift::LoadedFile>(file_unit);
auto *loaded_file = swift::cast<const swift::LoadedFile>(file_unit);
s.Printf("filename = \"%s\"", loaded_file->getFilename().str().c_str());
} break;
case swift::FileUnitKind::DWARFModule:
Expand Down Expand Up @@ -8622,7 +8622,7 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,

if (GetLog(LLDBLog::Types | LLDBLog::Expressions)) {
StreamString ss;
for (swift::FileUnit *file_unit : swift_module->getFiles())
for (const swift::FileUnit *file_unit : swift_module->getFiles())
DescribeFileUnit(ss, file_unit);
LOG_PRINTF(GetLog(LLDBLog::Types | LLDBLog::Expressions),
"Imported module %s from {%s}", module.path.front().AsCString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def test_negative(self):
self.runCmd('log enable lldb types -f "%s"' % log)
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'break here', lldb.SBFileSpec('main.swift'))
#lldbutil.check_variable(self,
# target.FindFirstGlobalVariable("point"),
# typename="Point", num_children=2)
lldbutil.check_variable(self,
target.FindFirstGlobalVariable("point"),
typename="CModule.Point", num_children=2)
# This can't be resolved.
self.expect("expr swiftStructCMember", error=True)

Expand Down