[llvm-branch-commits] [clang-tools-extra] 8f63114 - Revert "[clang-tidy] [Modules] Skip checking decls in clang-tidy (#145630)"

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 19 02:24:50 PDT 2026


Author: Chuanqi Xu
Date: 2026-03-19T17:24:46+08:00
New Revision: 8f6311470bb726822dfed73e2d75c11e6d63303c

URL: https://github.com/llvm/llvm-project/commit/8f6311470bb726822dfed73e2d75c11e6d63303c
DIFF: https://github.com/llvm/llvm-project/commit/8f6311470bb726822dfed73e2d75c11e6d63303c.diff

LOG: Revert "[clang-tidy] [Modules] Skip checking decls in clang-tidy (#145630)"

This reverts commit c800afd65e121410d539c4210f73285fffee548b.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/ClangTidy.cpp
    clang-tools-extra/test/lit.cfg.py
    clang/include/clang/ASTMatchers/ASTMatchFinder.h
    clang/lib/ASTMatchers/ASTMatchFinder.cpp

Removed: 
    clang-tools-extra/test/clang-tidy/infrastructure/cxx20-modules.cppm


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 0e5f8fbda631a..60f4823d930c1 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -434,9 +434,6 @@ ClangTidyASTConsumerFactory::createASTConsumer(CompilerInstance &Compiler,
 
   ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
 
-  // We should always skip the declarations in modules.
-  FinderOptions.SkipDeclsInModules = true;
-
   std::unique_ptr<ClangTidyProfiling> Profiling;
   if (Context.getEnableProfiling()) {
     Profiling =

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/cxx20-modules.cppm b/clang-tools-extra/test/clang-tidy/infrastructure/cxx20-modules.cppm
deleted file mode 100644
index 663df0104fd0a..0000000000000
--- a/clang-tools-extra/test/clang-tidy/infrastructure/cxx20-modules.cppm
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: rm -fr %t
-// RUN: mkdir %t
-// RUN: split-file %s %t
-// RUN: mkdir %t/tmp
-//
-// RUN: %check_clang_tidy -std=c++20 -check-suffix=DEFAULT %t/a.cpp \
-// RUN:   cppcoreguidelines-narrowing-conversions %t/a.cpp -- \
-// RUN:   -config='{}'
-
-// RUN: clang -std=c++20 -x c++-module %t/a.cpp --precompile -o %t/a.pcm
-
-// RUN: %check_clang_tidy -std=c++20 -check-suffix=DEFAULT %t/use.cpp \
-// RUN:   cppcoreguidelines-narrowing-conversions %t/a.cpp -- \
-// RUN:   -config='{}' -- -fmodule-file=a=%t/a.pcm 
-
-//--- a.cpp
-export module a;
-export void most_narrowing_is_not_ok() {
-  int i;
-  long long ui;
-  i = ui;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
-}
-
-//--- use.cpp
-import a;
-void use() {
-  most_narrowing_is_not_ok();
-}

diff  --git a/clang-tools-extra/test/lit.cfg.py b/clang-tools-extra/test/lit.cfg.py
index c075650ff7a73..c39ea29329674 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -27,7 +27,6 @@
 config.suffixes = [
     ".c",
     ".cpp",
-    ".cppm",
     ".hpp",
     ".m",
     ".mm",

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/clang/include/clang/ASTMatchers/ASTMatchFinder.h
index b0ccbf22a4269..2d36e8c4fae1c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -144,8 +144,6 @@ class MatchFinder {
 
     /// Avoids matching declarations in system headers.
     bool IgnoreSystemHeaders{false};
-
-    bool SkipDeclsInModules{false};
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 004a02c279099..83ffae65c67d4 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -20,7 +20,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/Basic/Module.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringMap.h"
@@ -1512,9 +1511,6 @@ bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) {
   if (shouldSkipNode(DeclNode))
     return true;
 
-  if (Options.SkipDeclsInModules && DeclNode->isInAnotherModuleUnit())
-    return true;
-
   bool ScopedTraversal =
       TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();
   bool ScopedChildren = TraversingASTChildrenNotSpelledInSource;


        


More information about the llvm-branch-commits mailing list