File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 11
11
#include " clang/Lex/Lexer.h"
12
12
13
13
using namespace clang ::ast_matchers;
14
+ namespace {
15
+
16
+ AST_MATCHER (clang::LinkageSpecDecl, isExternCLinkage) {
17
+ return Node.getLanguage () == clang::LinkageSpecDecl::lang_c;
18
+ }
19
+ } // namespace
14
20
15
21
namespace clang ::tidy::modernize {
16
22
@@ -27,10 +33,12 @@ void UseUsingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
27
33
}
28
34
29
35
void UseUsingCheck::registerMatchers (MatchFinder *Finder) {
30
- Finder->addMatcher (typedefDecl (unless (isInstantiated ()),
31
- hasParent (decl ().bind (ParentDeclName)))
32
- .bind (TypedefName),
33
- this );
36
+ Finder->addMatcher (
37
+ typedefDecl (unless (anyOf (isInstantiated (), hasAncestor (linkageSpecDecl (
38
+ isExternCLinkage ())))),
39
+ hasParent (decl ().bind (ParentDeclName)))
40
+ .bind (TypedefName),
41
+ this );
34
42
35
43
// This matcher is used to find tag declarations in source code within
36
44
// typedefs. They appear in the AST just *prior* to the typedefs.
Original file line number Diff line number Diff line change @@ -325,3 +325,17 @@ typedef bool (*ISSUE_65055_2)(int);
325
325
typedef class ISSUE_67529_1 *ISSUE_67529;
326
326
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
327
327
// CHECK-FIXES: using ISSUE_67529 = class ISSUE_67529_1 *;
328
+
329
+ // Some Header
330
+ extern " C" {
331
+
332
+ typedef int InExternC;
333
+ }
334
+
335
+ extern " C++" {
336
+
337
+ typedef int InExternCPP;
338
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
339
+ // CHECK-FIXES: using InExternCPP = int;
340
+
341
+ }
You can’t perform that action at this time.
0 commit comments