Skip to content

Commit

Permalink
Suppress clang false positive warning
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTF committed Feb 27, 2025
1 parent 474f936 commit df1f21e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/engine/Union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "engine/CallFixedSize.h"
#include "util/ChunkedForLoop.h"
#include "util/TransparentFunctors.h"
#include "util/CompilerWarnings.h"

const size_t Union::NO_COLUMN = std::numeric_limits<size_t>::max();

Expand Down Expand Up @@ -498,6 +498,9 @@ Result::Generator Union::computeResultKeepOrder(
? Range{std::array{Wrapper{result2->idTable(),
result2->localVocab()}}}
: Range{std::move(result2->idTables())};

// Clang falsely reports that the this capture is unused here.
DISABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS
return std::visit(
[this, requestLaziness, &result1, &result2](auto leftRange,
auto rightRange) {
Expand All @@ -511,4 +514,5 @@ Result::Generator Union::computeResultKeepOrder(
});
},
std::move(leftRange), std::move(rightRange));
ENABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS
}
10 changes: 10 additions & 0 deletions src/util/CompilerWarnings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@
#define ENABLE_UNINITIALIZED_WARNINGS
#endif

#if defined(__clang__) && (__clang_major__ >= 16 && __clang_major__ <= 18)
#define DISABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-lambda-capture\"")
#define ENABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS _Pragma("clang diagnostic pop")
#else
#define DISABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS
#define ENABLE_UNUSED_LAMBDA_CAPTURE_WARNINGS
#endif

#endif // QLEVER_COMPILERWARNINGS_H

0 comments on commit df1f21e

Please sign in to comment.