Skip to content

[lldb] Fix incorrect format specifiers #9616

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 5 commits into from
Nov 19, 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
74 changes: 0 additions & 74 deletions lldb/include/lldb/Core/SwiftScratchContextReader.h

This file was deleted.

8 changes: 0 additions & 8 deletions lldb/include/lldb/Symbol/TypeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,6 @@ class TypeSystemMap {
GetTypeSystemForLanguage(lldb::LanguageType language, Target *target,
bool can_create);

// BEGIN SWIFT
llvm::Expected<lldb::TypeSystemSP>
GetTypeSystemForLanguage(lldb::LanguageType language, Target *target,
bool can_create, const char *compiler_options);

void RemoveTypeSystemsForLanguage(lldb::LanguageType language);
// END SWIFT

/// Check all type systems in the map to see if any have forcefully completed
/// types;
bool GetHasForcefullyCompletedTypes() const;
Expand Down
43 changes: 5 additions & 38 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Core/SwiftScratchContextReader.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
Expand Down Expand Up @@ -52,7 +51,10 @@ namespace lldb_private {
class ClangModulesDeclVendor;
class SwiftPersistentExpressionState;
class SharedMutex;
class SwiftASTContextForExpressions;
class TypeSystemSwiftTypeRefForExpressions;
typedef std::shared_ptr<TypeSystemSwiftTypeRefForExpressions>
TypeSystemSwiftTypeRefForExpressionsSP;


OptionEnumValues GetDynamicValueTypes();

Expand Down Expand Up @@ -1246,20 +1248,14 @@ class Target : public std::enable_shared_from_this<Target>,

llvm::Expected<lldb::TypeSystemSP>
GetScratchTypeSystemForLanguage(lldb::LanguageType language,
bool create_on_demand = true,
const char *compiler_options = nullptr);
bool create_on_demand = true);

std::vector<lldb::TypeSystemSP>
GetScratchTypeSystems(bool create_on_demand = true);

PersistentExpressionState *
GetPersistentExpressionStateForLanguage(lldb::LanguageType language);

#ifdef LLDB_ENABLE_SWIFT
SwiftPersistentExpressionState *
GetSwiftPersistentExpressionState(ExecutionContextScope &exe_scope);
#endif // LLDB_ENABLE_SWIFT

const TypeSystemMap &GetTypeSystemMap();

// Creates a UserExpression for the given language, the rest of the
Expand Down Expand Up @@ -1292,27 +1288,13 @@ class Target : public std::enable_shared_from_this<Target>,
CreateUtilityFunction(std::string expression, std::string name,
lldb::LanguageType language, ExecutionContext &exe_ctx);


#ifdef LLDB_ENABLE_SWIFT
/// Get the lock guarding the scratch typesystem from being re-initialized.
std::shared_mutex &GetSwiftScratchContextLock() {
return m_scratch_typesystem_lock;
}

std::optional<SwiftScratchContextReader>
GetSwiftScratchContext(Status &error, ExecutionContextScope &exe_scope,
bool create_on_demand = true,
bool for_playground = false);

/// Return whether this is the Swift REPL.
bool IsSwiftREPL();

bool IsSwiftCxxInteropEnabled();

bool IsEmbeddedSwift();
private:
void DisplayFallbackSwiftContextErrors(
SwiftASTContextForExpressions *swift_ast_ctx);
#endif // LLDB_ENABLE_SWIFT

public:
Expand Down Expand Up @@ -1587,14 +1569,6 @@ class Target : public std::enable_shared_from_this<Target>,

void SetREPL(lldb::LanguageType language, lldb::REPLSP repl_sp);

/// Enable the use of a separate sscratch type system per lldb::Module.
void SetUseScratchTypesystemPerModule(bool value) {
m_use_scratch_typesystem_per_module = value;
}
bool UseScratchTypesystemPerModule() const {
return m_use_scratch_typesystem_per_module;
}

public:
StackFrameRecognizerManager &GetFrameRecognizerManager() {
return *m_frame_recognizer_manager_up;
Expand Down Expand Up @@ -1726,14 +1700,7 @@ class Target : public std::enable_shared_from_this<Target>,
/// signals you will have.
llvm::StringMap<DummySignalValues> m_dummy_signals;

bool m_use_scratch_typesystem_per_module = false;
bool m_did_display_scratch_fallback_warning = false;
typedef std::pair<lldb_private::Module *, char> ModuleLanguage;
llvm::DenseMap<ModuleLanguage, lldb::TypeSystemSP>
m_scratch_typesystem_for_module;

/// Guards the scratch typesystem from being re-initialized.
std::shared_mutex m_scratch_typesystem_lock;

static void ImageSearchPathsChanged(const PathMappingList &path_list,
void *baton);
Expand Down
5 changes: 0 additions & 5 deletions lldb/include/lldb/ValueObject/ValueObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLDB_VALUEOBJECT_VALUEOBJECT_H
#define LLDB_VALUEOBJECT_VALUEOBJECT_H

#include "lldb/Core/SwiftScratchContextReader.h"
#include "lldb/Core/Value.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
Expand Down Expand Up @@ -614,10 +613,6 @@ class ValueObject {

virtual bool HasSyntheticValue();

#ifdef LLDB_ENABLE_SWIFT
std::optional<SwiftScratchContextReader> GetSwiftScratchContext();
#endif // LLDB_ENABLE_SWIFT

virtual bool IsSynthetic() { return false; }

lldb::ValueObjectSP
Expand Down
11 changes: 0 additions & 11 deletions lldb/source/Expression/Materializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,17 +1064,6 @@ class EntityResultVariable : public Materializer::Entity {

if (m_type.GetMinimumLanguage() == lldb::eLanguageTypeSwift) {
#ifdef LLDB_ENABLE_SWIFT
Status status;
std::optional<SwiftScratchContextReader> maybe_type_system =
target_sp->GetSwiftScratchContext(status, *exe_scope);
if (!maybe_type_system) {
err = Status::FromErrorStringWithFormat(
"Couldn't dematerialize a result variable: "
"couldn't get the corresponding type "
"system: %s",
status.AsCString());
return;
}
persistent_state = target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeSwift);
#endif // LLDB_ENABLE_SWIFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ LLDBNameLookup::LLDBNameLookup(

if (!m_sc.target_sp)
return;
m_persistent_vars =
m_sc.target_sp->GetSwiftPersistentExpressionState(exe_scope);
m_persistent_vars = llvm::cast<SwiftPersistentExpressionState>(
m_sc.target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeSwift));
}

swift::SILValue LLDBNameLookup::emitLValueForVariable(
Expand Down Expand Up @@ -711,7 +712,8 @@ static void ResolveSpecialNames(
return;

auto *persistent_state =
sc.target_sp->GetSwiftPersistentExpressionState(exe_scope);
sc.target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeSwift);

std::set<ConstString> resolved_names;

Expand Down Expand Up @@ -1084,7 +1086,6 @@ struct ModuleImportError : public llvm::ErrorInfo<ModuleImportError> {
ModuleImportError(llvm::Twine message, bool is_new_dylib = false)
: msg(message.str()), is_new_dylib(is_new_dylib) {}
void log(llvm::raw_ostream &OS) const override {
OS << "error while processing module import: ";
OS << msg;
}
std::error_code convertToErrorCode() const override {
Expand Down Expand Up @@ -1453,7 +1454,8 @@ SwiftExpressionParser::ParseAndImport(
// fatal error state. One way this can happen is if the import
// triggered a dylib import, in which case the context is
// purposefully poisoned.
msg = "import may have triggered a dylib import";
msg = "import may have triggered a dylib import, "
"resetting compiler state";
}
return make_error<ModuleImportError>(msg, /*is_new_dylib=*/true);
}
Expand Down Expand Up @@ -1722,14 +1724,8 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
// There are no fallback contexts in REPL and playgrounds.
if (repl || playground)
return;
if (!m_sc.target_sp->UseScratchTypesystemPerModule()) {
// This, together with the fatal error forces
// a per-module scratch to be instantiated on
// retry.
m_sc.target_sp->SetUseScratchTypesystemPerModule(true);
m_swift_ast_ctx.RaiseFatalError(MIE.message());
retry = true;
}
// The fatal error causes a new compiler to be instantiated on retry.
m_swift_ast_ctx.RaiseFatalError(MIE.message());
},
[&](const SwiftASTContextError &SACE) {
DiagnoseSwiftASTContextError();
Expand All @@ -1745,9 +1741,7 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
});

// Signal that we want to retry the expression exactly once with a
// fresh SwiftASTContext initialized with the flags from the
// current lldb::Module / Swift dylib to avoid header search
// mismatches.
// fresh SwiftASTContext.
if (retry)
return ParseResult::retry_fresh_context;

Expand Down Expand Up @@ -1844,8 +1838,9 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
// Allow variables to be re-used from previous REPL statements.
if (m_sc.target_sp && (repl || !playground)) {
Status error;
auto *persistent_state =
m_sc.target_sp->GetSwiftPersistentExpressionState(*m_exe_scope);
auto *persistent_state = llvm::cast<SwiftPersistentExpressionState>(
m_sc.target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeSwift));

llvm::SmallVector<size_t, 1> declaration_indexes;
parsed_expr->code_manipulator->FindVariableDeclarations(declaration_indexes,
Expand Down Expand Up @@ -2125,8 +2120,9 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
module_name = module->getName().get();
m_swift_ast_ctx.CacheModule(module_name, module);
if (m_sc.target_sp) {
auto *persistent_state =
m_sc.target_sp->GetSwiftPersistentExpressionState(*m_exe_scope);
auto *persistent_state = llvm::cast<SwiftPersistentExpressionState>(
m_sc.target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeSwift));
persistent_state->CopyInSwiftPersistentDecls(
parsed_expr->external_lookup.GetStagedDecls());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SwiftExpressionParser : public ExpressionParser {
public:
enum class ParseResult {
success,
retry_fresh_context,
retry_fresh_context,
retry_no_bind_generic_params,
unrecoverable_error
};
Expand Down
Loading