Repository navigation
[mlir][NFC] Remove internal linkage from core header function templates - #214756
Merged
Merged
Conversation
These are more of the cases fixed alongside llvm#208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
|
@llvm/pr-subscribers-mlir-core @llvm/pr-subscribers-mlir Author: Aditya Medhane (flash1729) ChangesThese are more of the cases fixed alongside #208001, which enabled -Wunused-template under -Wall. Each template is 5 Files Affected:
diff --git a/mlir/include/mlir/Bytecode/BytecodeImplementation.h b/mlir/include/mlir/Bytecode/BytecodeImplementation.h
index d8d0ca7b3b9f7..93045439d2ba4 100644
--- a/mlir/include/mlir/Bytecode/BytecodeImplementation.h
+++ b/mlir/include/mlir/Bytecode/BytecodeImplementation.h
@@ -443,8 +443,8 @@ class DialectBytecodeWriter {
/// Helper for resource handle reading that returns LogicalResult.
template <typename T, typename... Ts>
-static LogicalResult readResourceHandle(DialectBytecodeReader &reader,
- FailureOr<T> &value, Ts &&...params) {
+LogicalResult readResourceHandle(DialectBytecodeReader &reader,
+ FailureOr<T> &value, Ts &&...params) {
FailureOr<T> handle = reader.readResourceHandle<T>();
if (failed(handle))
return failure();
diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h
index 0643f0a4b308f..aa932e7bcda6c 100644
--- a/mlir/include/mlir/IR/AffineMap.h
+++ b/mlir/include/mlir/IR/AffineMap.h
@@ -694,8 +694,8 @@ SmallVector<T> applyPermutationMap(AffineMap map, llvm::ArrayRef<T> source) {
/// Calculates maximum dimension and symbol positions from the expressions
/// in `exprsLists` and stores them in `maxDim` and `maxSym` respectively.
template <typename AffineExprContainer>
-static void getMaxDimAndSymbol(ArrayRef<AffineExprContainer> exprsList,
- int64_t &maxDim, int64_t &maxSym) {
+void getMaxDimAndSymbol(ArrayRef<AffineExprContainer> exprsList,
+ int64_t &maxDim, int64_t &maxSym) {
for (const auto &exprs : exprsList) {
for (auto expr : exprs) {
expr.walk([&maxDim, &maxSym](AffineExpr e) {
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index bd7fa1ffd4428..fe2fa0a0ccd23 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1607,8 +1607,8 @@ using detect_has_any_fold_trait =
/// Returns the result of folding a trait that implements a `foldTrait` function
/// that is specialized for operations that have a single result.
template <typename Trait>
-static std::enable_if_t<detect_has_single_result_fold_trait<Trait>::value,
- LogicalResult>
+std::enable_if_t<detect_has_single_result_fold_trait<Trait>::value,
+ LogicalResult>
foldTrait(Operation *op, ArrayRef<Attribute> operands,
SmallVectorImpl<OpFoldResult> &results) {
assert(op->hasTrait<OpTrait::OneResult>() &&
@@ -1629,7 +1629,7 @@ foldTrait(Operation *op, ArrayRef<Attribute> operands,
/// Returns the result of folding a trait that implements a generalized
/// `foldTrait` function that is supports any operation type.
template <typename Trait>
-static std::enable_if_t<detect_has_fold_trait<Trait>::value, LogicalResult>
+std::enable_if_t<detect_has_fold_trait<Trait>::value, LogicalResult>
foldTrait(Operation *op, ArrayRef<Attribute> operands,
SmallVectorImpl<OpFoldResult> &results) {
// If a previous trait has already been folded and replaced this operation, we
@@ -1637,8 +1637,7 @@ foldTrait(Operation *op, ArrayRef<Attribute> operands,
return results.empty() ? Trait::foldTrait(op, operands, results) : failure();
}
template <typename Trait>
-static inline std::enable_if_t<!detect_has_any_fold_trait<Trait>::value,
- LogicalResult>
+inline std::enable_if_t<!detect_has_any_fold_trait<Trait>::value, LogicalResult>
foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
return failure();
}
@@ -1646,8 +1645,8 @@ foldTrait(Operation *, ArrayRef<Attribute>, SmallVectorImpl<OpFoldResult> &) {
/// Given a tuple type containing a set of traits, return the result of folding
/// the given operation.
template <typename... Ts>
-static LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
- SmallVectorImpl<OpFoldResult> &results) {
+LogicalResult foldTraits(Operation *op, ArrayRef<Attribute> operands,
+ SmallVectorImpl<OpFoldResult> &results) {
return success((succeeded(foldTrait<Ts>(op, operands, results)) || ...));
}
diff --git a/mlir/include/mlir/IR/PDLPatternMatch.h.inc b/mlir/include/mlir/IR/PDLPatternMatch.h.inc
index aa74202178a9b..a39a46382affd 100644
--- a/mlir/include/mlir/IR/PDLPatternMatch.h.inc
+++ b/mlir/include/mlir/IR/PDLPatternMatch.h.inc
@@ -642,8 +642,8 @@ void assertArgs(PatternRewriter &rewriter, ArrayRef<PDLValue> values,
/// Store a single result within the result list.
template <typename T>
-static LogicalResult processResults(PatternRewriter &rewriter,
- PDLResultList &results, T &&value) {
+LogicalResult processResults(PatternRewriter &rewriter, PDLResultList &results,
+ T &&value) {
ProcessPDLValue<T>::processAsResult(rewriter, results,
std::forward<T>(value));
return success();
@@ -651,9 +651,8 @@ static LogicalResult processResults(PatternRewriter &rewriter,
/// Store a std::pair<> as individual results within the result list.
template <typename T1, typename T2>
-static LogicalResult processResults(PatternRewriter &rewriter,
- PDLResultList &results,
- std::pair<T1, T2> &&pair) {
+LogicalResult processResults(PatternRewriter &rewriter, PDLResultList &results,
+ std::pair<T1, T2> &&pair) {
if (failed(processResults(rewriter, results, std::move(pair.first))) ||
failed(processResults(rewriter, results, std::move(pair.second))))
return failure();
@@ -662,9 +661,8 @@ static LogicalResult processResults(PatternRewriter &rewriter,
/// Store a std::tuple<> as individual results within the result list.
template <typename... Ts>
-static LogicalResult processResults(PatternRewriter &rewriter,
- PDLResultList &results,
- std::tuple<Ts...> &&tuple) {
+LogicalResult processResults(PatternRewriter &rewriter, PDLResultList &results,
+ std::tuple<Ts...> &&tuple) {
auto applyFn = [&](auto &&...args) {
return (succeeded(processResults(rewriter, results, std::move(args))) &&
...);
@@ -679,9 +677,8 @@ inline LogicalResult processResults(PatternRewriter &rewriter,
return result;
}
template <typename T>
-static LogicalResult processResults(PatternRewriter &rewriter,
- PDLResultList &results,
- FailureOr<T> &&result) {
+LogicalResult processResults(PatternRewriter &rewriter, PDLResultList &results,
+ FailureOr<T> &&result) {
if (failed(result))
return failure();
return processResults(rewriter, results, std::move(*result));
diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h
index 0c71f78b52d3d..4e4652ee8eef1 100644
--- a/mlir/include/mlir/Pass/PassOptions.h
+++ b/mlir/include/mlir/Pass/PassOptions.h
@@ -57,11 +57,11 @@ using has_stream_operator = llvm::is_detected<has_stream_operator_trait, T>;
/// Utility methods for printing option values.
template <typename ParserT>
-static void printOptionValue(raw_ostream &os, const bool &value) {
+void printOptionValue(raw_ostream &os, const bool &value) {
os << (value ? StringRef("true") : StringRef("false"));
}
template <typename ParserT>
-static void printOptionValue(raw_ostream &os, const std::string &str) {
+void printOptionValue(raw_ostream &os, const std::string &str) {
// Check if the string needs to be escaped before writing it to the ostream.
const size_t spaceIndex = str.find_first_of(' ');
const size_t escapeIndex =
@@ -75,7 +75,7 @@ static void printOptionValue(raw_ostream &os, const std::string &str) {
os << "}";
}
template <typename ParserT, typename DataT>
-static void printOptionValue(raw_ostream &os, const DataT &value) {
+void printOptionValue(raw_ostream &os, const DataT &value) {
if constexpr (has_stream_operator<DataT>::value)
os << value;
else
|
makslevental
approved these changes
Aug 11, 2026
hulxv
pushed a commit
that referenced
this pull request
Aug 12, 2026
…es (#214756) These are more of the cases fixed alongside #208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
zhangweize9-cyber
pushed a commit
to zhangweize9-cyber/llvm-project
that referenced
this pull request
Aug 16, 2026
…es (llvm#214756) These are more of the cases fixed alongside llvm#208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
carlobertolli
pushed a commit
to carlobertolli/llvm-project
that referenced
this pull request
Aug 18, 2026
…es (llvm#214756) These are more of the cases fixed alongside llvm#208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These are more of the cases fixed alongside #208001, which enabled -Wunused-template under -Wall. Each template is
staticin a widely included header, so clang warns in every TU that includes it without instantiating it. Droppingstaticgives them vague linkage and silences the warning.