Skip to content

Commit 34b2a3a

Browse files
committed
Move into LLVM module as this seems better spot given lack of other planned rewrites & limited scope
1 parent b404f53 commit 34b2a3a

File tree

13 files changed

+42
-113
lines changed

13 files changed

+42
-113
lines changed

clang-tools-extra/clang-tidy/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ add_subdirectory(linuxkernel)
6666
add_subdirectory(llvm)
6767
add_subdirectory(llvmlibc)
6868
add_subdirectory(misc)
69-
add_subdirectory(mlir)
7069
add_subdirectory(modernize)
7170
if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
7271
add_subdirectory(mpi)
@@ -94,7 +93,6 @@ set(ALL_CLANG_TIDY_CHECKS
9493
clangTidyLLVMModule
9594
clangTidyLLVMLibcModule
9695
clangTidyMiscModule
97-
clangTidyMLIRModule
9896
clangTidyModernizeModule
9997
clangTidyObjCModule
10098
clangTidyOpenMPModule

clang-tools-extra/clang-tidy/ClangTidyForceLinker.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ extern volatile int MiscModuleAnchorSource;
9494
static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
9595
MiscModuleAnchorSource;
9696

97-
// This anchor is used to force the linker to link the MLIRModule.
98-
extern volatile int MLIRModuleAnchorSource;
99-
static int LLVM_ATTRIBUTE_UNUSED MLIRModuleAnchorDestination =
100-
MLIRModuleAnchorSource;
101-
10297
// This anchor is used to force the linker to link the ModernizeModule.
10398
extern volatile int ModernizeModuleAnchorSource;
10499
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =

clang-tools-extra/clang-tidy/llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_clang_library(clangTidyLLVMModule STATIC
77
HeaderGuardCheck.cpp
88
IncludeOrderCheck.cpp
99
LLVMTidyModule.cpp
10+
MLIROpBuilderCheck.cpp
1011
PreferIsaOrDynCastInConditionalsCheck.cpp
1112
PreferRegisterOverUnsignedCheck.cpp
1213
PreferStaticOverAnonymousNamespaceCheck.cpp
@@ -16,6 +17,7 @@ add_clang_library(clangTidyLLVMModule STATIC
1617
clangTidy
1718
clangTidyReadabilityModule
1819
clangTidyUtils
20+
clangTransformer
1921

2022
DEPENDS
2123
omp_gen

clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "../readability/QualifiedAutoCheck.h"
1515
#include "HeaderGuardCheck.h"
1616
#include "IncludeOrderCheck.h"
17+
#include "MLIROpBuilderCheck.h"
1718
#include "PreferIsaOrDynCastInConditionalsCheck.h"
1819
#include "PreferRegisterOverUnsignedCheck.h"
1920
#include "PreferStaticOverAnonymousNamespaceCheck.h"
@@ -40,6 +41,7 @@ class LLVMModule : public ClangTidyModule {
4041
CheckFactories.registerCheck<readability::QualifiedAutoCheck>(
4142
"llvm-qualified-auto");
4243
CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
44+
CheckFactories.registerCheck<MlirOpBuilderCheck>("llvm-mlir-op-builder");
4345
}
4446

4547
ClangTidyOptions getModuleOptions() override {

clang-tools-extra/clang-tidy/mlir/OpBuilderCheck.cpp renamed to clang-tools-extra/clang-tidy/llvm/MLIROpBuilderCheck.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//===--- OpBuilderCheck.cpp - clang-tidy ----------------------------------===//
1+
//===--- MLIROpBuilderCheck.cpp - clang-tidy -------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "OpBuilderCheck.h"
9+
#include "MLIROpBuilderCheck.h"
1010
#include "clang/ASTMatchers/ASTMatchers.h"
1111
#include "clang/Basic/LLVM.h"
1212
#include "clang/Lex/Lexer.h"
@@ -16,7 +16,7 @@
1616
#include "clang/Tooling/Transformer/Stencil.h"
1717
#include "llvm/Support/Error.h"
1818

19-
namespace clang::tidy::mlir_check {
19+
namespace clang::tidy::llvm_check {
2020
namespace {
2121

2222
using namespace ::clang::ast_matchers; // NOLINT: Too many names.
@@ -80,7 +80,7 @@ Stencil typeAsWritten(StringRef Id) {
8080
return std::make_shared<TypeAsWrittenStencil>(std::string(Id));
8181
}
8282

83-
RewriteRuleWith<std::string> OpBuilderCheckRule() {
83+
RewriteRuleWith<std::string> MlirOpBuilderCheckRule() {
8484
return makeRule(
8585
cxxMemberCallExpr(
8686
on(expr(hasType(
@@ -96,7 +96,7 @@ RewriteRuleWith<std::string> OpBuilderCheckRule() {
9696
}
9797
} // namespace
9898

99-
OpBuilderCheck::OpBuilderCheck(StringRef Name, ClangTidyContext *Context)
100-
: TransformerClangTidyCheck(OpBuilderCheckRule(), Name, Context) {}
99+
MlirOpBuilderCheck::MlirOpBuilderCheck(StringRef Name, ClangTidyContext *Context)
100+
: TransformerClangTidyCheck(MlirOpBuilderCheckRule(), Name, Context) {}
101101

102102
} // namespace clang::tidy::mlir_check
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_MLIROPBUILDERCHECK_H
2+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_MLIROPBUILDERCHECK_H
3+
4+
#include "../utils/TransformerClangTidyCheck.h"
5+
6+
namespace clang::tidy::llvm_check {
7+
8+
/// Checks for uses of MLIR's `OpBuilder::create<T>` and suggests using
9+
/// `T::create` instead.
10+
class MlirOpBuilderCheck : public utils::TransformerClangTidyCheck {
11+
public:
12+
MlirOpBuilderCheck(StringRef Name, ClangTidyContext *Context);
13+
14+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
15+
return getLangOpts().CPlusPlus;
16+
}
17+
};
18+
19+
} // namespace clang::tidy::llvm_check
20+
21+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_MLIROPBUILDERCHECK_H

clang-tools-extra/clang-tidy/mlir/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang-tools-extra/clang-tidy/mlir/MLIRTidyModule.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

clang-tools-extra/clang-tidy/mlir/OpBuilderCheck.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ Improvements to clang-tidy
9696
New checks
9797
^^^^^^^^^^
9898

99-
- New :doc:`mlir-op-builder
100-
<clang-tidy/checks/mlir/op-builder>` check.
99+
- New :doc:`llvm-mlir-op-builder
100+
<clang-tidy/checks/llvm/mlir-op-builder>` check.
101101

102102
Flags usage of old OpBuilder format.
103103

0 commit comments

Comments
 (0)