[PATCH] D48717: [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 23 10:13:19 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE337710: [clang-tidy] fix PR36489 - respect deduced pointer types from auto as well (authored by JonasToth, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48717?vs=156812&id=156813#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48717

Files:
  test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp


Index: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
===================================================================
--- test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
@@ -85,5 +85,32 @@
 
   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";
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48717.156813.patch
Type: text/x-patch
Size: 1192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180723/0421ea72/attachment.bin>


More information about the cfe-commits mailing list