Skip to content

Commit 48fe48a

Browse files
committed
reuse LOG_PRINTF_IMPL
1 parent 97740ea commit 48fe48a

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

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

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ std::recursive_mutex g_log_mutex;
170170

171171
/// Similar to LLDB_LOG, but with richer contextual information.
172172
#define LOG_PRINTF(CHANNEL, FMT, ...) \
173-
LOG_PRINTF_IMPL(CHANNEL, false, FMT, ##__VA_ARGS__)
173+
LOG_PRINTF_IMPL(lldb_private::GetLogIfAllCategoriesSet(CHANNEL), false, FMT, \
174+
##__VA_ARGS__)
174175
#define LOG_VERBOSE_PRINTF(CHANNEL, FMT, ...) \
175-
LOG_PRINTF_IMPL(CHANNEL, true, FMT, ##__VA_ARGS__)
176+
LOG_PRINTF_IMPL(lldb_private::GetLogIfAllCategoriesSet(CHANNEL), true, FMT, \
177+
##__VA_ARGS__)
176178
#define LOG_PRINTF_IMPL(CHANNEL, VERBOSE, FMT, ...) \
177179
do { \
178-
if (Log *log = lldb_private::GetLogIfAllCategoriesSet(CHANNEL)) \
180+
if (Log *log = CHANNEL) \
179181
if (!(VERBOSE) || log->GetVerbose()) { \
180182
std::lock_guard<std::recursive_mutex> locker(g_log_mutex); \
181183
/* The format string is optimized for code size, not speed. */ \
@@ -185,19 +187,9 @@ std::recursive_mutex g_log_mutex;
185187
} \
186188
} while (0)
187189

188-
#define SWIFT_LOG_PRINTF(FMT, ...) \
189-
LOG_PRINTF_IMPL(LIBLLDB_LOG_TYPES, false, FMT, ##__VA_ARGS__); \
190-
SWIFT_LOG_PRINTF_IMPL(FMT, ##__VA_ARGS__)
191-
#define SWIFT_LOG_PRINTF_IMPL(FMT, ...) \
192-
do { \
193-
if (Log *log = lldb_private::GetSwiftHealthLog()) { \
194-
std::lock_guard<std::recursive_mutex> locker(g_log_mutex); \
195-
/* The format string is optimized for code size, not speed. */ \
196-
log->Printf("%s::%s%s" FMT, m_description.c_str(), \
197-
IsLambda(__FUNCTION__) ? "" : __FUNCTION__, \
198-
(FMT && FMT[0] == '(') ? "" : "() -- ", ##__VA_ARGS__); \
199-
} \
200-
} while (0)
190+
#define HEALTH_LOG_PRINTF(FMT, ...) \
191+
LOG_PRINTF(LIBLLDB_LOG_TYPES, FMT, ##__VA_ARGS__); \
192+
LOG_PRINTF_IMPL(lldb_private::GetSwiftHealthLog(), false, FMT, ##__VA_ARGS__)
201193

202194
using namespace lldb;
203195
using namespace lldb_private;
@@ -5092,61 +5084,62 @@ void SwiftASTContext::ClearModuleDependentCaches() {
50925084
void SwiftASTContext::LogConfiguration() {
50935085
// It makes no sense to call VALID_OR_RETURN here. We specifically
50945086
// want the logs in the error case!
5095-
SWIFT_LOG_PRINTF("(SwiftASTContext*)%p:", static_cast<void *>(this));
5087+
HEALTH_LOG_PRINTF("(SwiftASTContext*)%p:", static_cast<void *>(this));
50965088

50975089
if (!m_ast_context_ap) {
5098-
SWIFT_LOG_PRINTF(" (no AST context)");
5090+
HEALTH_LOG_PRINTF(" (no AST context)");
50995091
return;
51005092
}
51015093

5102-
SWIFT_LOG_PRINTF(" Architecture : %s",
5103-
m_ast_context_ap->LangOpts.Target.getTriple().c_str());
5104-
SWIFT_LOG_PRINTF(" SDK path : %s",
5105-
m_ast_context_ap->SearchPathOpts.SDKPath.c_str());
5106-
SWIFT_LOG_PRINTF(
5094+
HEALTH_LOG_PRINTF(" Architecture : %s",
5095+
m_ast_context_ap->LangOpts.Target.getTriple().c_str());
5096+
HEALTH_LOG_PRINTF(" SDK path : %s",
5097+
m_ast_context_ap->SearchPathOpts.SDKPath.c_str());
5098+
HEALTH_LOG_PRINTF(
51075099
" Runtime resource path : %s",
51085100
m_ast_context_ap->SearchPathOpts.RuntimeResourcePath.c_str());
5109-
SWIFT_LOG_PRINTF(" Runtime library paths : (%llu items)",
5110-
(unsigned long long)m_ast_context_ap->SearchPathOpts
5111-
.RuntimeLibraryPaths.size());
5101+
HEALTH_LOG_PRINTF(" Runtime library paths : (%llu items)",
5102+
(unsigned long long)m_ast_context_ap->SearchPathOpts
5103+
.RuntimeLibraryPaths.size());
51125104

51135105
for (const auto &runtime_library_path :
51145106
m_ast_context_ap->SearchPathOpts.RuntimeLibraryPaths) {
5115-
SWIFT_LOG_PRINTF(" %s", runtime_library_path.c_str());
5107+
HEALTH_LOG_PRINTF(" %s", runtime_library_path.c_str());
51165108
}
51175109

5118-
SWIFT_LOG_PRINTF(" Runtime library import paths : (%llu items)",
5119-
(unsigned long long)m_ast_context_ap->SearchPathOpts
5120-
.RuntimeLibraryImportPaths.size());
5110+
HEALTH_LOG_PRINTF(" Runtime library import paths : (%llu items)",
5111+
(unsigned long long)m_ast_context_ap->SearchPathOpts
5112+
.RuntimeLibraryImportPaths.size());
51215113

51225114
for (const auto &runtime_import_path :
51235115
m_ast_context_ap->SearchPathOpts.RuntimeLibraryImportPaths) {
5124-
SWIFT_LOG_PRINTF(" %s", runtime_import_path.c_str());
5116+
HEALTH_LOG_PRINTF(" %s", runtime_import_path.c_str());
51255117
}
51265118

5127-
SWIFT_LOG_PRINTF(" Framework search paths : (%llu items)",
5128-
(unsigned long long)m_ast_context_ap->SearchPathOpts
5129-
.FrameworkSearchPaths.size());
5119+
HEALTH_LOG_PRINTF(" Framework search paths : (%llu items)",
5120+
(unsigned long long)m_ast_context_ap->SearchPathOpts
5121+
.FrameworkSearchPaths.size());
51305122
for (const auto &framework_search_path :
51315123
m_ast_context_ap->SearchPathOpts.FrameworkSearchPaths) {
5132-
SWIFT_LOG_PRINTF(" %s", framework_search_path.Path.c_str());
5124+
HEALTH_LOG_PRINTF(" %s", framework_search_path.Path.c_str());
51335125
}
51345126

5135-
SWIFT_LOG_PRINTF(" Import search paths : (%llu items)",
5136-
(unsigned long long)m_ast_context_ap->SearchPathOpts
5137-
.ImportSearchPaths.size());
5127+
HEALTH_LOG_PRINTF(" Import search paths : (%llu items)",
5128+
(unsigned long long)m_ast_context_ap->SearchPathOpts
5129+
.ImportSearchPaths.size());
51385130
for (std::string &import_search_path :
51395131
m_ast_context_ap->SearchPathOpts.ImportSearchPaths) {
5140-
SWIFT_LOG_PRINTF(" %s", import_search_path.c_str());
5132+
HEALTH_LOG_PRINTF(" %s", import_search_path.c_str());
51415133
}
51425134

51435135
swift::ClangImporterOptions &clang_importer_options =
51445136
GetClangImporterOptions();
51455137

5146-
SWIFT_LOG_PRINTF(" Extra clang arguments : (%llu items)",
5147-
(unsigned long long)clang_importer_options.ExtraArgs.size());
5138+
HEALTH_LOG_PRINTF(
5139+
" Extra clang arguments : (%llu items)",
5140+
(unsigned long long)clang_importer_options.ExtraArgs.size());
51485141
for (std::string &extra_arg : clang_importer_options.ExtraArgs) {
5149-
SWIFT_LOG_PRINTF(" %s", extra_arg.c_str());
5142+
HEALTH_LOG_PRINTF(" %s", extra_arg.c_str());
51505143
}
51515144
}
51525145

0 commit comments

Comments
 (0)