Skip to content

Commit 82f08c6

Browse files
authored
Stop unused variable warnings if llvm built with assertions off (#679)
1 parent ea8b2aa commit 82f08c6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

lib/CppInterOp/DynamicLibraryManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,22 @@ std::string DynamicLibraryManager::lookupLibInPaths(
145145

146146
LLVM_DEBUG(dbgs() << "Dyld::lookupLibInPaths: \n");
147147
LLVM_DEBUG(dbgs() << ":: RPATH\n");
148+
#ifndef NDEBUG
148149
for (auto Info : RPath) {
149150
LLVM_DEBUG(dbgs() << ":::: " << Info.str() << "\n");
150151
}
152+
#endif
151153
LLVM_DEBUG(dbgs() << ":: SearchPaths (LD_LIBRARY_PATH, etc...)\n");
152154
for (auto Info : getSearchPaths()) {
153155
LLVM_DEBUG(dbgs() << ":::: " << Info.Path
154156
<< ", user=" << (Info.IsUser ? "true" : "false") << "\n");
155157
}
156158
LLVM_DEBUG(dbgs() << ":: RUNPATH\n");
159+
#ifndef NDEBUG
157160
for (auto Info : RunPath) {
158161
LLVM_DEBUG(dbgs() << ":::: " << Info.str() << "\n");
159162
}
160-
163+
#endif
161164
SmallString<512> ThisPath;
162165
// RPATH
163166
for (auto Info : RPath) {

lib/CppInterOp/DynamicLibraryManagerSymbol.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,11 @@ void Dyld::ScanForLibraries(bool searchSystemLibraries /* = false*/) {
620620

621621
LLVM_DEBUG(dbgs() << "Dyld::ScanForLibraries: system="
622622
<< (searchSystemLibraries ? "true" : "false") << "\n");
623+
#ifndef NDEBUG
623624
for (const DynamicLibraryManager::SearchPathInfo& Info : searchPaths)
624625
LLVM_DEBUG(dbgs() << ">>>" << Info.Path << ", "
625626
<< (Info.IsUser ? "user\n" : "system\n"));
626-
627+
#endif
627628
llvm::SmallSet<const BasePath*, 32> ScannedPaths;
628629

629630
for (const DynamicLibraryManager::SearchPathInfo& Info : searchPaths) {
@@ -769,11 +770,12 @@ void Dyld::ScanForLibraries(bool searchSystemLibraries /* = false*/) {
769770
<< RPathToStr(RPath) << "\n");
770771
LLVM_DEBUG(dbgs() << "Dyld::ScanForLibraries: RUNPATH="
771772
<< RPathToStr(RunPath) << "\n");
773+
#ifndef NDEBUG
772774
int x = 0;
773775
for (StringRef dep : Deps)
774776
LLVM_DEBUG(dbgs() << "Dyld::ScanForLibraries: Deps[" << x++
775777
<< "]=" << dep.str() << "\n");
776-
778+
#endif
777779
// Heuristics for workaround performance problems:
778780
// (H1) If RPATH and RUNPATH == "" -> skip handling Deps
779781
if (RPath.empty() && RunPath.empty()) {
@@ -965,10 +967,11 @@ void Dyld::BuildBloomFilter(LibraryPath* Lib,
965967
}
966968

967969
LLVM_DEBUG(dbgs() << "Dyld::BuildBloomFilter: Symbols:\n");
970+
#ifndef NDEBUG
968971
for (auto it : symbols)
969972
LLVM_DEBUG(dbgs() << "Dyld::BuildBloomFilter"
970973
<< "- " << it << "\n");
971-
974+
#endif
972975
// Generate BloomFilter
973976
for (const auto& S : symbols) {
974977
if (m_UseHashTable)
@@ -1036,7 +1039,11 @@ bool Dyld::ContainsSymbol(const LibraryPath* Lib, StringRef mangledName,
10361039
}
10371040

10381041
auto ForeachSymbol =
1042+
#ifndef NDEBUG
10391043
[&library_filename](
1044+
#else
1045+
[](
1046+
#endif
10401047
llvm::iterator_range<llvm::object::symbol_iterator> range,
10411048
unsigned IgnoreSymbolFlags, llvm::StringRef mangledName) -> bool {
10421049
for (const llvm::object::SymbolRef& S : range) {
@@ -1157,6 +1164,7 @@ bool Dyld::ShouldPermanentlyIgnore(StringRef FileName) const {
11571164
void Dyld::dumpDebugInfo() const {
11581165
#define DEBUG_TYPE "Dyld:"
11591166
LLVM_DEBUG(dbgs() << "---\n");
1167+
#ifndef NDEBUG
11601168
size_t x = 0;
11611169
for (auto const& item : m_BasePaths.m_Paths) {
11621170
LLVM_DEBUG(dbgs() << "Dyld: - m_BasePaths[" << x++ << "]:" << &item << ": "
@@ -1174,6 +1182,7 @@ void Dyld::dumpDebugInfo() const {
11741182
<< ": " << item->m_Path << ", " << item->m_LibName
11751183
<< "\n");
11761184
}
1185+
#endif
11771186
#undef DEBUG_TYPE
11781187
}
11791188

@@ -1213,12 +1222,13 @@ std::string Dyld::searchLibrariesForSymbol(StringRef mangledName,
12131222
// from our lists of not-yet-loaded libs.
12141223

12151224
LLVM_DEBUG(dbgs() << "Dyld::ResolveSymbol: m_QueriedLibraries:\n");
1225+
#ifndef NDEBUG
12161226
size_t x = 0;
12171227
for (auto item : m_QueriedLibraries.GetLibraries()) {
12181228
LLVM_DEBUG(dbgs() << "Dyld::ResolveSymbol - [" << x++ << "]:" << &item
12191229
<< ": " << item->GetFullName() << "\n");
12201230
}
1221-
1231+
#endif
12221232
for (const LibraryPath* P : m_QueriedLibraries.GetLibraries()) {
12231233
const std::string LibName = P->GetFullName();
12241234
if (!m_DynamicLibraryManager.isLibraryLoaded(LibName))

lib/CppInterOp/Paths.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,11 @@ void AddIncludePaths(
390390

391391
if (HOpts.Verbose) {
392392
LLVM_DEBUG(dbgs() << "Added include paths:\n");
393+
#ifndef NDEBUG
393394
for (llvm::StringRef Path : PathsChecked)
394395
LLVM_DEBUG(dbgs() << " " << Path << "\n");
396+
#endif
395397
}
396-
397398
#undef DEBUG_TYPE
398399
}
399400

0 commit comments

Comments
 (0)