summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Toth <jonas.toth@gmail.com>2018-07-23 17:13:06 +0000
committerJonas Toth <jonas.toth@gmail.com>2018-07-23 17:13:06 +0000
commiteb5112d6f64f31b36c52b8af7be701ceeabeaecc (patch)
tree4b1bb785247c65be725492cb8766a42da14fd9e0
parentf745d4304fceb04022f14aedf19374f1f230faca (diff)
[clang-tidy] fix PR36489 - respect deduced pointer types from auto as well
Summary: The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where pointer arithmetic is used, but does not check values where the pointer types is deduced via ``auto``. This patch adjusts this behaviour and solved PR36489. Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov Reviewed By: alexfh, aaron.ballman Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D48717 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@337710 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp b/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
index 7cbc6ddf..2b7f9233 100644
--- a/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
+++ b/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
@@ -85,5 +85,32 @@ void okay() {
auto diff = p - q; // OK, result is arithmetic
- for(int ii : a) ; // OK, pointer arithmetic generated by compiler
+ for (int ii : a)
+ ; // OK, pointer arithmetic generated by compiler
+}
+
+// Fix PR36207
+namespace std {
+template <typename CharT>
+struct char_traits {};
+
+template <typename T>
+struct allocator {};
+
+template <typename CharT,
+ typename Traits = char_traits<CharT>,
+ typename Allocator = allocator<CharT>>
+class basic_string {};
+
+template <class CharT, class Traits, class Alloc>
+basic_string<CharT, Traits, Alloc> operator+(const basic_string<CharT, Traits, Alloc> &lhs,
+ const CharT *rhs) {}
+
+using string = basic_string<char>;
+} // namespace std
+
+std::string str_generated() {}
+
+void problematic_addition() {
+ std::string status = str_generated() + " is not found";
}