-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[clang-tidy] [Modules] Skip checking decls in clang-tidy #145630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
config.suffixes = [ | ||
".c", | ||
".cpp", | ||
".cppm", | ||
".hpp", | ||
".m", | ||
".mm", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
#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" | ||
|
@@ -1469,6 +1470,12 @@ bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { | |
return true; | ||
} | ||
|
||
if (Options.SkipDeclsInModules && DeclNode->isFromASTFile()) { | ||
auto *M = DeclNode->getOwningModule(); | ||
if (M && (M->isInterfaceOrPartition() || M->isGlobalModule())) | ||
return true; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with modules at all, I just want to make sure we check this the right way as there are about 8 member functions matching the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think this is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I picked a new API |
||
bool ScopedTraversal = | ||
TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit(); | ||
bool ScopedChildren = TraversingASTChildrenNotSpelledInSource; | ||
|
Uh oh!
There was an error while loading. Please reload this page.