summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/google-namespaces.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2017-05-15 17:37:48 +0000
committerAlexander Kornienko <alexfh@google.com>2017-05-15 17:37:48 +0000
commit1ca0e322a27b8e058bef9a9e3a06d89784663f55 (patch)
tree1281141d173be9219517031ea551d2e070ad0d74 /clang-tools-extra/test/clang-tidy/google-namespaces.cpp
parent7d531daecec9470a4540b5303f23786b28c3c6f9 (diff)
downloadbcm5719-llvm-1ca0e322a27b8e058bef9a9e3a06d89784663f55.tar.gz
bcm5719-llvm-1ca0e322a27b8e058bef9a9e3a06d89784663f55.zip
Make google-build-using-namespace skip std::.*literals
Summary: C++14 added a couple of user-defined literals in the standard library. E.g. std::chrono_literals and std::literals::chrono_literals . Using them requires a using directive so do not warn in google-build-using-namespace if namespace name starts with "std::" and ends with "literals". Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits Patch by Martin Ejdestig! Differential Revision: https://reviews.llvm.org/D33010 llvm-svn: 303085
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/google-namespaces.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/google-namespaces.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/google-namespaces.cpp b/clang-tools-extra/test/clang-tidy/google-namespaces.cpp
index 891aee3951a..9bda3c0451b 100644
--- a/clang-tools-extra/test/clang-tidy/google-namespaces.cpp
+++ b/clang-tools-extra/test/clang-tidy/google-namespaces.cpp
@@ -6,3 +6,47 @@ using namespace spaaaace;
// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
using spaaaace::core; // no-warning
+
+namespace std {
+inline namespace literals {
+inline namespace chrono_literals {
+}
+inline namespace complex_literals {
+}
+inline namespace string_literals {
+}
+}
+}
+
+using namespace std::chrono_literals; // no-warning
+using namespace std::complex_literals; // no-warning
+using namespace std::literals; // no-warning
+using namespace std::literals::chrono_literals; // no-warning
+using namespace std::literals::complex_literals; // no-warning
+using namespace std::literals::string_literals; // no-warning
+using namespace std::string_literals; // no-warning
+
+namespace literals {}
+
+using namespace literals;
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
+
+namespace foo {
+inline namespace literals {
+inline namespace bar_literals {}
+}
+}
+
+using namespace foo::literals;
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
+
+using namespace foo::bar_literals;
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
+
+using namespace foo::literals::bar_literals;
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
+
+namespace foo_literals {}
+
+using namespace foo_literals;
+// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
OpenPOWER on IntegriCloud