Skip to content

Commit 008c49d

Browse files
Merge pull request #9616 from adrian-prantl/fmt-spec
[lldb] Fix incorrect format specifiers
2 parents 698b909 + d425213 commit 008c49d

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,8 +3832,8 @@ SwiftASTContext::CreateModule(std::string module_name,
38323832
return llvm::createStringError("invalid module name (empty)");
38333833

38343834
if (swift::ModuleDecl *module_decl = GetCachedModule(module_name))
3835-
return llvm::createStringError("module already exists for \"{0}\"",
3836-
module_name.c_str());
3835+
return llvm::createStringError(
3836+
llvm::formatv("module already exists for \"{0}\"", module_name));
38373837

38383838
ThreadSafeASTContext ast = GetASTContext();
38393839
if (!ast)
@@ -3842,8 +3842,8 @@ SwiftASTContext::CreateModule(std::string module_name,
38423842
swift::Identifier module_id(ast->getIdentifier(module_name));
38433843
auto *module_decl = swift::ModuleDecl::create(module_id, **ast, importInfo);
38443844
if (!module_decl)
3845-
return llvm::createStringError("failed to create module for \"{0}\"",
3846-
module_name.c_str());
3845+
return llvm::createStringError(
3846+
llvm::formatv("failed to create module for \"{0}\"", module_name));
38473847
swift::ModuleDecl &decl_ref = *module_decl;
38483848
m_swift_module_cache.insert(
38493849
std::pair<llvm::StringRef, const swift::ModuleDecl &>(module_name,
@@ -3894,9 +3894,9 @@ SwiftASTContext::GetModule(const SourceModule &module, bool *cached) {
38943894

38953895
if (HasFatalErrors()) {
38963896
return llvm::createStringError(
3897-
"failed to get module \"{0}\" from AST context:\n"
3898-
"AST context is in a fatal error state",
3899-
module_name.c_str());
3897+
llvm::formatv("failed to get module \"{0}\" from AST context:\n"
3898+
"AST context is in a fatal error state",
3899+
module_name));
39003900
}
39013901

39023902
// Create a diagnostic consumer for the diagnostics produced by the import.
@@ -3942,14 +3942,14 @@ SwiftASTContext::GetModule(const SourceModule &module, bool *cached) {
39423942
LOG_PRINTF(GetLog(LLDBLog::Types), "(\"%s\") -- %s",
39433943
module.path.front().GetCString(), diagnostic.c_str());
39443944
return llvm::createStringError(
3945-
"failed to get module \"{0}\" from AST context:\n{1}",
3946-
module_name.c_str(), diagnostic.c_str());
3945+
llvm::formatv("failed to get module \"{0}\" from AST context:\n{1}",
3946+
module_name, diagnostic));
39473947
}
39483948

39493949
if (!module_decl) {
39503950
LOG_PRINTF(GetLog(LLDBLog::Types), "failed with no error");
3951-
return llvm::createStringError(
3952-
"failed to get module \"{0}\" from AST context", module_name.c_str());
3951+
return llvm::createStringError(llvm::formatv(
3952+
"failed to get module \"{0}\" from AST context", module_name));
39533953
}
39543954
LOG_PRINTF(GetLog(LLDBLog::Types), "(\"%s\") -- found %s",
39553955
module_name.c_str(), module_decl->getName().str().str().c_str());
@@ -3969,8 +3969,8 @@ SwiftASTContext::GetModule(const FileSpec &module_spec) {
39693969
if (!module_basename) {
39703970
LOG_PRINTF(GetLog(LLDBLog::Types), "((FileSpec)\"%s\") -- no basename",
39713971
module_spec.GetPath().c_str());
3972-
return llvm::createStringError("no module basename in \"{0}\"",
3973-
module_spec.GetPath().c_str());
3972+
return llvm::createStringError(
3973+
llvm::formatv("no module basename in \"{0}\"", module_spec.GetPath()));
39743974
}
39753975

39763976
if (auto *cached = GetCachedModule(module_basename.GetString()))
@@ -3979,8 +3979,8 @@ SwiftASTContext::GetModule(const FileSpec &module_spec) {
39793979
if (!FileSystem::Instance().Exists(module_spec)) {
39803980
LOG_PRINTF(GetLog(LLDBLog::Types), "((FileSpec)\"%s\") -- doesn't exist",
39813981
module_spec.GetPath().c_str());
3982-
return llvm::createStringError("module \"{0}\" doesn't exist",
3983-
module_spec.GetPath().c_str());
3982+
return llvm::createStringError(
3983+
llvm::formatv("module \"{0}\" doesn't exist", module_spec.GetPath()));
39843984
}
39853985
ThreadSafeASTContext ast = GetASTContext();
39863986
if (!GetClangImporter()) {
@@ -4022,9 +4022,8 @@ SwiftASTContext::GetModule(const FileSpec &module_spec) {
40224022
"((FileSpec)\"%s\") -- couldn't get from AST context",
40234023
module_spec.GetPath().c_str());
40244024

4025-
return llvm::createStringError(
4026-
"failed to get module \"{0}\" from AST context",
4027-
module_spec.GetPath().c_str());
4025+
return llvm::createStringError(llvm::formatv(
4026+
"failed to get module \"{0}\" from AST context", module_spec.GetPath()));
40284027
}
40294028

40304029
template<typename ModuleT> swift::ModuleDecl *

0 commit comments

Comments
 (0)