DmitryPolukhin updated this revision to Diff 326734.
DmitryPolukhin added a comment.

Comments resolved


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97563/new/

https://reviews.llvm.org/D97563

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===================================================================
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s 
modernize-concat-nested-namespaces %t
+// RUN: cp 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t 
-- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t 
-- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
 
 namespace n1 {}
 
@@ -159,3 +167,5 @@
 
   return 0;
 }
+
+// CHECK-MESSAGES: modernize-concat-nested-namespaces.h:1:1: warning: nested 
namespaces can be concatenated [modernize-concat-nested-namespaces]
Index: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
===================================================================
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
@@ -0,0 +1,8 @@
+namespace nn1 {
+namespace nn2 {
+// CHECK-FIXES: namespace nn1::nn2
+void t();
+} // namespace nn2
+} // namespace nn1
+// CHECK-FIXES: void t();
+// CHECK-FIXES-NEXT: } // namespace nn1
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
@@ -82,9 +82,6 @@
   if (!locationsInSameFile(Sources, ND.getBeginLoc(), ND.getRBraceLoc()))
     return;
 
-  if (!Sources.isInMainFile(ND.getBeginLoc()))
-    return;
-
   if (anonymousOrInlineNamespace(ND))
     return;
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
 
 namespace n1 {}
 
@@ -159,3 +167,5 @@
 
   return 0;
 }
+
+// CHECK-MESSAGES: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
@@ -0,0 +1,8 @@
+namespace nn1 {
+namespace nn2 {
+// CHECK-FIXES: namespace nn1::nn2
+void t();
+} // namespace nn2
+} // namespace nn1
+// CHECK-FIXES: void t();
+// CHECK-FIXES-NEXT: } // namespace nn1
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
@@ -82,9 +82,6 @@
   if (!locationsInSameFile(Sources, ND.getBeginLoc(), ND.getRBraceLoc()))
     return;
 
-  if (!Sources.isInMainFile(ND.getBeginLoc()))
-    return;
-
   if (anonymousOrInlineNamespace(ND))
     return;
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to