summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
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
commit369e4fd353aff061fb6858463ebe452b21a2ec61 (patch)
treefdf3d075d221365d508b11068eabef42fb2a3080 /clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
parenta70685f63a08d16be40424b45697f6badfaaae4e (diff)
downloadbcm5719-llvm-369e4fd353aff061fb6858463ebe452b21a2ec61.tar.gz
bcm5719-llvm-369e4fd353aff061fb6858463ebe452b21a2ec61.zip
[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 llvm-svn: 337710
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp b/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
index 7cbc6ddf96a..2b7f9233e36 100644
--- a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
+++ b/clang-tools-extra/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";
}
OpenPOWER on IntegriCloud