[PATCH] D47111: : Implement monotonic_buffer_resource.
Quuxplusone updated this revision to Diff 154486. Quuxplusone added a comment. Oops, my previous diff had a stray `)` in it, somehow. Repository: rCXX libc++ https://reviews.llvm.org/D47111 Files: include/experimental/memory_resource src/experimental/memory_resource.cpp test/libcxx/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/copy_move.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/with_default_resource.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/without_buffer.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_deallocate.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_exception_safety.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_initial_buffer.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_underaligned_buffer.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_zero_sized_buffer.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_overaligned_request.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp === --- /dev/null +++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp @@ -0,0 +1,62 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// REQUIRES: c++experimental +// UNSUPPORTED: c++98, c++03 + +// + +// class monotonic_buffer_resource + +#include +#include +#include +#include + +struct assert_on_compare : public std::experimental::pmr::memory_resource +{ +protected: +virtual void * do_allocate(size_t, size_t) +{ assert(false); } + +virtual void do_deallocate(void *, size_t, size_t) +{ assert(false); } + +virtual bool do_is_equal(std::experimental::pmr::memory_resource const &) const noexcept +{ assert(false); } +}; + +int main() +{ +// Same object +{ +std::experimental::pmr::monotonic_buffer_resource r1; +std::experimental::pmr::monotonic_buffer_resource r2; +assert(r1 == r1); +assert(r1 != r2); + +std::experimental::pmr::memory_resource & p1 = r1; +std::experimental::pmr::memory_resource & p2 = r2; +assert(p1 == p1); +assert(p1 != p2); +assert(p1 == r1); +assert(r1 == p1); +assert(p1 != r2); +assert(r2 != p1); +} +// Different types +{ +std::experimental::pmr::monotonic_buffer_resource mono1; +std::experimental::pmr::memory_resource & r1 = mono1; +assert_on_compare c; +std::experimental::pmr::memory_resource & r2 = c; +assert(r1 != r2); +assert(!(r1 == r2)); +} +} Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp === --- /dev/null +++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp @@ -0,0 +1,51 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// REQUIRES: c++experimental +// UNSUPPORTED: c++98, c++03 + +// + +// class monotonic_buffer_resource + +#include +#include + +#include "count_new.hpp" + +void test(size_t initial_buffer_size) +{ +globalMemCounter.reset(); + +std::experimental::pmr::monotonic_buffer_resource mono1( +initial_buffer_size, +std::experimental::pmr::new_delete_resource() +); +assert(globalMem
[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
lebedev.ri updated this revision to Diff 154490. lebedev.ri added a comment. Rebased, just to control bitrot, no changes. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36892 Files: test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -78,6 +78,7 @@ file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + check_notes_prefix = 'CHECK-NOTES' + file_check_suffix # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. @@ -91,9 +92,10 @@ has_check_fixes = check_fixes_prefix in input_text has_check_messages = check_messages_prefix in input_text + has_check_notes = check_notes_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) +sys.exit('None of %s, %s or %s found in the input' % (check_fixes_prefix, check_messages_prefix, check_notes_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -156,5 +158,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=' + check_notes_prefix, + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -78,6 +78,7 @@ file_check_suffix = ('-' + args.check_suffix) if args.check_suffix else '' check_fixes_prefix = 'CHECK-FIXES' + file_check_suffix check_messages_prefix = 'CHECK-MESSAGES' + file_check_suffix + check_notes_prefix = 'CHECK-NOTES' + file_check_suffix # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. @@ -91,9 +92,10 @@ has_check_fixes = check_fixes_prefix in input_text has_check_messages = check_messages_prefix in input_text + has_check_notes = check_notes_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) +sys.exit('None of %s, %s or %s found in the input' % (check_fixes_prefix, check_messages_prefix, check_notes_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while @@ -156,5 +158,18 @@ print('FileCheck failed:\n' + e.output.decode()) raise + if has_check_notes: +messages_file = temp_file_name + '.msg' +write_file(messages_file, clang_tidy_output) +try: + subprocess.check_output( + ['FileCheck', '-input-file=' + messages_file, input_file_name, + '-check-prefix=' + check_notes_prefix, + '-implicit-check-not={{note|warning|error}}:'], + stderr=subprocess.STDOUT) +except subprocess.CalledProcessError as e: + print('FileCheck failed:\n' + e.output.decode()) + raise + if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36836: [clang-tidy] Implement sonarsource-function-cognitive-complexity check
lebedev.ri updated this revision to Diff 154491. lebedev.ri added a comment. Rebased, just to control bitrot, no changes. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D36836 Files: LICENSE.TXT clang-tidy/CMakeLists.txt clang-tidy/plugin/CMakeLists.txt clang-tidy/sonarsource/CMakeLists.txt clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.cpp clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.h clang-tidy/sonarsource/LICENSE.TXT clang-tidy/sonarsource/SONARSOURCETidyModule.cpp clang-tidy/tool/CMakeLists.txt clang-tidy/tool/ClangTidyMain.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/sonarsource-function-cognitive-complexity.rst test/clang-tidy/sonarsource-function-cognitive-complexity.cpp Index: test/clang-tidy/sonarsource-function-cognitive-complexity.cpp === --- /dev/null +++ test/clang-tidy/sonarsource-function-cognitive-complexity.cpp @@ -0,0 +1,954 @@ +// RUN: %check_clang_tidy %s sonarsource-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: sonarsource-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11 -w + +// any function should be checked. + +extern int ext_func(int x = 0); + +int some_func(int x = 0); + +static int some_other_func(int x = 0) {} + +template void some_templ_func(T x = 0) {} + +class SomeClass { +public: + int *begin(int x = 0); + int *end(int x = 0); + static int func(int x = 0); + template void some_templ_func(T x = 0) {} + SomeClass() = default; + SomeClass(SomeClass&) = delete; +}; + +// nothing ever decreases cognitive complexity, so we can check all the things +// in one go. none of the following should increase cognitive complexity: +void unittest_false() { + {}; + ext_func(); + some_func(); + some_other_func(); + some_templ_func(); + some_templ_func(); + SomeClass::func(); + SomeClass C; + C.some_templ_func(); + C.some_templ_func(); + C.func(); + C.end(); + int i = some_func(); + i = i; + i++; + --i; + i < 0; + int j = 0 ?: 1; + auto k = new int; + delete k; + throw i; + { +throw i; + } +end: + return; +} + +#if 1 +#define CC100 +#else +// this macro has cognitive complexity of 100. +// it is needed to be able to compare the testcases with the +// reference Sonar implementation. please place it right after the first +// CHECK-NOTES in each function +#define CC100 if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){}if(1){} +#endif + +//// +//-- B1. Increments --// +//// +// Check that every thing listed in B1 of the specification does indeed // +// recieve the base increment, and that not-body does not increase nesting// +//// + +// break does not increase cognitive complexity. +// only break LABEL does, but it is unavaliable in C or C++ + +// continue does not increase cognitive complexity. +// only continue LABEL does, but it is unavaliable in C or C++ + +void unittest_b1_00() { +// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 33 (threshold 0) [sonarsource-function-cognitive-complexity] + CC100; + + if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}} +// CHECK-NOTES: :[[@LINE-2]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}} + +if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}} +// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}} +} else if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}} +// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}} +} else { +// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level increased to 2{{$}} +} + } else if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}} +// CHECK-NOTES: :[[@LINE-2]]:16: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}} + +if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}} +// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}} +} else if (1 ? 1 : 0) { +// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}} +// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}} +} else { +// CHECK-NOTES: :[[
[PATCH] D48521: [analyzer] Highlight container object destruction in MallocChecker
rnkovacs added a comment. No crashes on Harfbuzz, ICU, Bitcoin, and LLVM. I'll commit. https://reviews.llvm.org/D48521 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336487 - [X86] Fix various type mismatches in intrinsic headers and intrinsic tests that cause extra bitcasts to be emitted in the IR.
Author: ctopper Date: Sat Jul 7 10:03:32 2018 New Revision: 336487 URL: http://llvm.org/viewvc/llvm-project?rev=336487&view=rev Log: [X86] Fix various type mismatches in intrinsic headers and intrinsic tests that cause extra bitcasts to be emitted in the IR. Found via imprecise grepping of the -O0 IR. There could still be more bugs out there. Modified: cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/lib/Headers/avx512vlintrin.h cfe/trunk/lib/Headers/avxintrin.h cfe/trunk/test/CodeGen/avx-builtins.c cfe/trunk/test/CodeGen/avx-shuffle-builtins.c cfe/trunk/test/CodeGen/avx512dq-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=336487&r1=336486&r2=336487&view=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 7 10:03:32 2018 @@ -3374,7 +3374,7 @@ _mm512_maskz_permutex2var_epi64(__mmask8 #define _mm512_extractf64x4_pd(A, I) \ (__m256d)__builtin_ia32_extractf64x4_mask((__v8df)(__m512d)(A), (int)(I), \ -(__v4df)_mm256_undefined_si256(), \ +(__v4df)_mm256_undefined_pd(), \ (__mmask8)-1) #define _mm512_mask_extractf64x4_pd(W, U, A, imm) \ @@ -5544,7 +5544,7 @@ _mm_maskz_getexp_ss (__mmask8 __U, __m12 { return (__m128) __builtin_ia32_getexpss128_round_mask ((__v4sf) __A, (__v4sf) __B, - (__v4sf) _mm_setzero_pd (), + (__v4sf) _mm_setzero_ps (), (__mmask8) __U, _MM_FROUND_CUR_DIRECTION); } @@ -5634,7 +5634,7 @@ _mm_maskz_getexp_ss (__mmask8 __U, __m12 (__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ (__v4sf)(__m128)(B), \ (int)(((D)<<2) | (C)), \ - (__v4sf)_mm_setzero_pd(), \ + (__v4sf)_mm_setzero_ps(), \ (__mmask8)(U), \ _MM_FROUND_CUR_DIRECTION) @@ -6721,24 +6721,24 @@ _mm512_maskz_srai_epi64(__mmask8 __U, __ (__v8df)_mm512_setzero_pd()) #define _mm512_shuffle_ps(A, B, M) \ - (__m512d)__builtin_shufflevector((__v16sf)(__m512)(A), \ - (__v16sf)(__m512)(B), \ - 0 + (((M) >> 0) & 0x3), \ - 0 + (((M) >> 2) & 0x3), \ - 16 + (((M) >> 4) & 0x3), \ - 16 + (((M) >> 6) & 0x3), \ - 4 + (((M) >> 0) & 0x3), \ - 4 + (((M) >> 2) & 0x3), \ - 20 + (((M) >> 4) & 0x3), \ - 20 + (((M) >> 6) & 0x3), \ - 8 + (((M) >> 0) & 0x3), \ - 8 + (((M) >> 2) & 0x3), \ - 24 + (((M) >> 4) & 0x3), \ - 24 + (((M) >> 6) & 0x3), \ - 12 + (((M) >> 0) & 0x3), \ - 12 + (((M) >> 2) & 0x3), \ - 28 + (((M) >> 4) & 0x3), \ - 28 + (((M) >> 6) & 0x3)) + (__m512)__builtin_shufflevector((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + 0 + (((M) >> 0) & 0x3), \ + 0 + (((M) >> 2) & 0x3), \ + 16 + (((M) >> 4) & 0x3), \ + 16 + (((M) >> 6) & 0x3), \ + 4 + (((M) >> 0) & 0x3), \ + 4 + (((M) >> 2) & 0x3), \ + 20 + (((M) >> 4) & 0x3), \ + 20 + (((M) >> 6) & 0x3), \ + 8 + (((M) >> 0) & 0x3), \ + 8 + (((M) >> 2) & 0x3), \ + 24 + (((M) >> 4) & 0x3), \ + 24 + (((M) >> 6) & 0x3), \ + 12 + (((M) >> 0) & 0x3), \ + 12 + (((M) >> 2) & 0x3), \ + 28 + (((M) >> 4) & 0x3), \ + 28 + (((M) >> 6) & 0x3)) #define _mm512_mask_shuffle_ps(W, U, A, B, M) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ @@ -7651,7 +7651,7 @@ _mm512_maskz_getexp_ps (__mmask16 __U, _ (__mmask8)(ma
r336488 - [X86] Change _mm512_shuffle_pd and _mm512_shuffle_ps to use target specific shuffle builtins instead of generic __builtin_shufflevector.
Author: ctopper Date: Sat Jul 7 10:03:34 2018 New Revision: 336488 URL: http://llvm.org/viewvc/llvm-project?rev=336488&view=rev Log: [X86] Change _mm512_shuffle_pd and _mm512_shuffle_ps to use target specific shuffle builtins instead of generic __builtin_shufflevector. I added the builtins for 128, 256, and 512 bits recently but looks like I failed to convert to using the 512 bit one. Modified: cfe/trunk/lib/Headers/avx512fintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=336488&r1=336487&r2=336488&view=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 7 10:03:34 2018 @@ -6699,16 +6699,8 @@ _mm512_maskz_srai_epi64(__mmask8 __U, __ (__v8di)_mm512_setzero_si512()) #define _mm512_shuffle_pd(A, B, M) \ - (__m512d)__builtin_shufflevector((__v8df)(__m512d)(A), \ - (__v8df)(__m512d)(B), \ - 0 + (((M) >> 0) & 0x1), \ - 8 + (((M) >> 1) & 0x1), \ - 2 + (((M) >> 2) & 0x1), \ - 10 + (((M) >> 3) & 0x1), \ - 4 + (((M) >> 4) & 0x1), \ - 12 + (((M) >> 5) & 0x1), \ - 6 + (((M) >> 6) & 0x1), \ - 14 + (((M) >> 7) & 0x1)) + (__m512d)__builtin_ia32_shufpd512((__v8df)(__m512d)(A), \ +(__v8df)(__m512d)(B), (int)(M)) #define _mm512_mask_shuffle_pd(W, U, A, B, M) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ @@ -6721,24 +6713,8 @@ _mm512_maskz_srai_epi64(__mmask8 __U, __ (__v8df)_mm512_setzero_pd()) #define _mm512_shuffle_ps(A, B, M) \ - (__m512)__builtin_shufflevector((__v16sf)(__m512)(A), \ - (__v16sf)(__m512)(B), \ - 0 + (((M) >> 0) & 0x3), \ - 0 + (((M) >> 2) & 0x3), \ - 16 + (((M) >> 4) & 0x3), \ - 16 + (((M) >> 6) & 0x3), \ - 4 + (((M) >> 0) & 0x3), \ - 4 + (((M) >> 2) & 0x3), \ - 20 + (((M) >> 4) & 0x3), \ - 20 + (((M) >> 6) & 0x3), \ - 8 + (((M) >> 0) & 0x3), \ - 8 + (((M) >> 2) & 0x3), \ - 24 + (((M) >> 4) & 0x3), \ - 24 + (((M) >> 6) & 0x3), \ - 12 + (((M) >> 0) & 0x3), \ - 12 + (((M) >> 2) & 0x3), \ - 28 + (((M) >> 4) & 0x3), \ - 28 + (((M) >> 6) & 0x3)) + (__m512)__builtin_ia32_shufps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(M)) #define _mm512_mask_shuffle_ps(W, U, A, B, M) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48521: [analyzer] Highlight container object destruction in MallocChecker
This revision was automatically updated to reflect the committed changes. Closed by commit rL336489: [analyzer] Highlight container object destruction in MallocChecker. (authored by rkovacs, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48521?vs=152615&id=154494#toc Repository: rL LLVM https://reviews.llvm.org/D48521 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Index: cfe/trunk/test/Analysis/dangling-internal-buffer.cpp === --- cfe/trunk/test/Analysis/dangling-internal-buffer.cpp +++ cfe/trunk/test/Analysis/dangling-internal-buffer.cpp @@ -26,7 +26,7 @@ { std::string s; c = s.c_str(); - } + } // expected-note {{Internal buffer is released because the object was destroyed}} consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } @@ -36,7 +36,7 @@ { std::wstring ws; w = ws.c_str(); - } + } // expected-note {{Internal buffer is released because the object was destroyed}} consume(w); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } @@ -46,7 +46,7 @@ { std::u16string s16; c16 = s16.c_str(); - } + } // expected-note {{Internal buffer is released because the object was destroyed}} consume(c16); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } @@ -56,7 +56,7 @@ { std::u32string s32; c32 = s32.c_str(); - } + } // expected-note {{Internal buffer is released because the object was destroyed}} consume(c32); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -480,8 +480,13 @@ inline bool isReleased(const RefState *S, const RefState *SPrev, const Stmt *Stmt) { // Did not track -> released. Other state (allocated) -> released. - return (Stmt && (isa(Stmt) || isa(Stmt)) && - (S && S->isReleased()) && (!SPrev || !SPrev->isReleased())); + // The statement associated with the release might be missing. + bool IsReleased = (S && S->isReleased()) && +(!SPrev || !SPrev->isReleased()); + assert(!IsReleased || + (Stmt && (isa(Stmt) || isa(Stmt))) || + (!Stmt && S->getAllocationFamily() == AF_InternalBuffer)); + return IsReleased; } inline bool isRelinquished(const RefState *S, const RefState *SPrev, @@ -2850,8 +2855,17 @@ std::shared_ptr MallocChecker::MallocBugVisitor::VisitNode( const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) { + + ProgramStateRef state = N->getState(); + ProgramStateRef statePrev = PrevN->getState(); + + const RefState *RS = state->get(Sym); + const RefState *RSPrev = statePrev->get(Sym); + const Stmt *S = PathDiagnosticLocation::getStmt(N); - if (!S) + // When dealing with containers, we sometimes want to give a note + // even if the statement is missing. + if (!S && (!RS || RS->getAllocationFamily() != AF_InternalBuffer)) return nullptr; const LocationContext *CurrentLC = N->getLocationContext(); @@ -2876,14 +2890,6 @@ } } - ProgramStateRef state = N->getState(); - ProgramStateRef statePrev = PrevN->getState(); - - const RefState *RS = state->get(Sym); - const RefState *RSPrev = statePrev->get(Sym); - if (!RS) -return nullptr; - // FIXME: We will eventually need to handle non-statement-based events // (__attribute__((cleanup))). @@ -2896,7 +2902,22 @@ StackHint = new StackHintGeneratorForSymbol(Sym, "Returned allocated memory"); } else if (isReleased(RS, RSPrev, S)) { - Msg = "Memory is released"; + const auto Family = RS->getAllocationFamily(); + switch(Family) { +case AF_Alloca: +case AF_Malloc: +case AF_CXXNew: +case AF_CXXNewArray: +case AF_IfNameIndex: + Msg = "Memory is released"; + break; +case AF_InternalBuffer: + Msg = "Internal buffer is released because the object was destroyed"; + break; +case AF_None: +default: + llvm_unreachable("Unhandled allocation family!"); + } StackHint = new StackHintGeneratorForSymbol(Sym, "Returning; memory was released"); @@ -2967,8 +2988,19 @@ assert(StackHint); // Generate the extra
[PATCH] D48522: [analyzer] Highlight c_str() call in DanglingInternalBuffer checker
This revision was automatically updated to reflect the committed changes. Closed by commit rC336495: [analyzer] Highlight c_str() call in DanglingInternalBufferChecker. (authored by rkovacs, committed by ). Changed prior to commit: https://reviews.llvm.org/D48522?vs=152719&id=154499#toc Repository: rC Clang https://reviews.llvm.org/D48522 Files: lib/StaticAnalyzer/Checkers/AllocationState.h lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/dangling-internal-buffer.cpp Index: test/Analysis/dangling-internal-buffer.cpp === --- test/Analysis/dangling-internal-buffer.cpp +++ test/Analysis/dangling-internal-buffer.cpp @@ -6,7 +6,7 @@ class basic_string { public: ~basic_string(); - const CharT *c_str(); + const CharT *c_str() const; }; typedef basic_string string; @@ -25,17 +25,29 @@ const char *c; { std::string s; -c = s.c_str(); +c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} + } // expected-note {{Internal buffer is released because the object was destroyed}} + consume(c); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void deref_after_scope_char2() { + const char *c; + { +std::string s; +c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::string s; + const char *c2 = s.c_str(); consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } void deref_after_scope_wchar_t() { const wchar_t *w; { std::wstring ws; -w = ws.c_str(); +w = ws.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} consume(w); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} @@ -45,7 +57,7 @@ const char16_t *c16; { std::u16string s16; -c16 = s16.c_str(); +c16 = s16.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} consume(c16); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} @@ -55,7 +67,7 @@ const char32_t *c32; { std::u32string s32; -c32 = s32.c_str(); +c32 = s32.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} consume(c32); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1993,6 +1993,11 @@ R->markInteresting(Sym); R->addRange(Range); R->addVisitor(llvm::make_unique(Sym)); + +const RefState *RS = C.getState()->get(Sym); +if (RS->getAllocationFamily() == AF_InternalBuffer) + R->addVisitor(allocation_state::getDanglingBufferBRVisitor(Sym)); + C.emitReport(std::move(R)); } } Index: lib/StaticAnalyzer/Checkers/AllocationState.h === --- lib/StaticAnalyzer/Checkers/AllocationState.h +++ lib/StaticAnalyzer/Checkers/AllocationState.h @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_ALLOCATIONSTATE_H #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_ALLOCATIONSTATE_H +#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" namespace clang { @@ -20,6 +21,11 @@ ProgramStateRef markReleased(ProgramStateRef State, SymbolRef Sym, const Expr *Origin); +/// This function provides an additional visitor that augments the bug report +/// with information relevant to memory errors caused by the misuse of +/// AF_InternalBuffer symbols. +std::unique_ptr getDanglingBufferBRVisitor(SymbolRef Sym); + } // end namespace allocation_state } // end namespace ento Index: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp === --- lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp +++ lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp @@ -7,30 +7,66 @@ // //===--===// // -// This file defines a check that marks a raw pointer to a C++ standard library -// container
[PATCH] D48532: [analyzer] Add support for std::basic_string::data() in DanglingInternalBufferChecker
This revision was automatically updated to reflect the committed changes. Closed by commit rC336497: [analyzer] Add support for data() in DanglingInternalBufferChecker. (authored by rkovacs, committed by ). Changed prior to commit: https://reviews.llvm.org/D48532?vs=152737&id=154501#toc Repository: rC Clang https://reviews.llvm.org/D48532 Files: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp test/Analysis/dangling-internal-buffer.cpp Index: test/Analysis/dangling-internal-buffer.cpp === --- test/Analysis/dangling-internal-buffer.cpp +++ test/Analysis/dangling-internal-buffer.cpp @@ -7,6 +7,8 @@ public: ~basic_string(); const CharT *c_str() const; + const CharT *data() const; + CharT *data(); }; typedef basic_string string; @@ -21,63 +23,105 @@ void consume(const char16_t *) {} void consume(const char32_t *) {} -void deref_after_scope_char() { +void deref_after_scope_char_cstr() { const char *c; { std::string s; c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::string s; + const char *c2 = s.c_str(); consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_char2() { +void deref_after_scope_char_data() { const char *c; { std::string s; -c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} +c = s.data(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} std::string s; - const char *c2 = s.c_str(); + const char *c2 = s.data(); + consume(c); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void deref_after_scope_char_data_non_const() { + char *c; + { +std::string s; +c = s.data(); // expected-note {{Pointer to dangling buffer was obtained here}} + } // expected-note {{Internal buffer is released because the object was destroyed}} + std::string s; + char *c2 = s.data(); consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_wchar_t() { + +void deref_after_scope_wchar_t_cstr() { const wchar_t *w; { std::wstring ws; w = ws.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::wstring ws; + const wchar_t *w2 = ws.c_str(); + consume(w); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void deref_after_scope_wchar_t_data() { + const wchar_t *w; + { +std::wstring ws; +w = ws.data(); // expected-note {{Pointer to dangling buffer was obtained here}} + } // expected-note {{Internal buffer is released because the object was destroyed}} + std::wstring ws; + const wchar_t *w2 = ws.data(); consume(w); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_char16_t() { +void deref_after_scope_char16_t_cstr() { const char16_t *c16; { std::u16string s16; c16 = s16.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::u16string s16; + const char16_t *c16_2 = s16.c_str(); consume(c16); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_char32_t() { +void deref_after_scope_char32_t_data() { const char32_t *c32; { std::u32string s32; -c32 = s32.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} +c32 = s32.data(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::u32string s32; + const char32_t *c32_2 = s32.data(); consume(c32); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_ok() { +void deref_after_scope_cstr_ok() { const char *c; std::string s; { c = s.c_str(); } consume(c); // no-warning } + +void deref_after_scope_data_ok() { + const char *c; + std::string s; + { +c = s.data(); + } + consume(c); // no-warning +} Index: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp === --- lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp +++ lib/StaticAnalyzer
[PATCH] D49054: [MinGW] Treat any -lucrt* as replacing -lmsvcrt
mstorsjo created this revision. mstorsjo added reviewers: rnk, martell, compnerd, smeenai. Since SVN r314138, we check if the user has specified any particular alternative msvcrt/ucrt version, and skip the default -lmsvcrt in those cases. In addition to the existing names checked, we should also treat a plain -lucrt in the same way, mingw-w64 has now added a separate import library named libucrt.a, in addition to libucrtbase.a. Repository: rC Clang https://reviews.llvm.org/D49054 Files: lib/Driver/ToolChains/MinGW.cpp test/Driver/mingw-msvcrt.c Index: test/Driver/mingw-msvcrt.c === --- test/Driver/mingw-msvcrt.c +++ test/Driver/mingw-msvcrt.c @@ -1,6 +1,12 @@ // RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s +// RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRTBASE %s +// RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRT %s // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32" // CHECK_MSVCR120: "-lmsvcr120" // CHECK_MSVCR120-SAME: "-lmingwex" "-ladvapi32" +// CHECK_UCRTBASE: "-lucrtbase" +// CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32" +// CHECK_UCRT: "-lucrt" +// CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -83,7 +83,7 @@ CmdArgs.push_back("-lmoldname"); CmdArgs.push_back("-lmingwex"); for (auto Lib : Args.getAllArgValues(options::OPT_l)) -if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase") +if (StringRef(Lib).startswith("msvcr") || StringRef(Lib).startswith("ucrt")) return; CmdArgs.push_back("-lmsvcrt"); } Index: test/Driver/mingw-msvcrt.c === --- test/Driver/mingw-msvcrt.c +++ test/Driver/mingw-msvcrt.c @@ -1,6 +1,12 @@ // RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s +// RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRTBASE %s +// RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRT %s // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32" // CHECK_MSVCR120: "-lmsvcr120" // CHECK_MSVCR120-SAME: "-lmingwex" "-ladvapi32" +// CHECK_UCRTBASE: "-lucrtbase" +// CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32" +// CHECK_UCRT: "-lucrt" +// CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -83,7 +83,7 @@ CmdArgs.push_back("-lmoldname"); CmdArgs.push_back("-lmingwex"); for (auto Lib : Args.getAllArgValues(options::OPT_l)) -if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase") +if (StringRef(Lib).startswith("msvcr") || StringRef(Lib).startswith("ucrt")) return; CmdArgs.push_back("-lmsvcrt"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336500 - [X86] Remove __builtin_ia32_vfnmsubsd3_mask3 and __builtin_ia32_vfnmsubss3_mask3 from clang.
Author: ctopper Date: Sat Jul 7 15:03:20 2018 New Revision: 336500 URL: http://llvm.org/viewvc/llvm-project?rev=336500&view=rev Log: [X86] Remove __builtin_ia32_vfnmsubsd3_mask3 and __builtin_ia32_vfnmsubss3_mask3 from clang. They are no longer used by clang. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=336500&r1=336499&r2=336500&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Jul 7 15:03:20 2018 @@ -1712,8 +1712,6 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_ TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask3, "V2dV2dV2dV2dUcIi", "nc", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmsubsd3_mask3, "V2dV2dV2dV2dUcIi", "nc", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmsubss3_mask3, "V4fV4fV4fV4fUcIi", "nc", "avx512f") -TARGET_BUILTIN(__builtin_ia32_vfnmsubsd3_mask3, "V2dV2dV2dV2dUcIi", "nc", "avx512f") -TARGET_BUILTIN(__builtin_ia32_vfnmsubss3_mask3, "V4fV4fV4fV4fUcIi", "nc", "avx512f") TARGET_BUILTIN(__builtin_ia32_permdf512, "V8dV8dIi", "nc", "avx512f") TARGET_BUILTIN(__builtin_ia32_permdi512, "V8LLiV8LLiIi", "nc", "avx512f") TARGET_BUILTIN(__builtin_ia32_permvarhi512, "V32sV32sV32s", "nc", "avx512bw") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336498 - [X86] Fix a few intrinsics that were ignoring their rounding mode argument and hardcoded _MM_FROUND_CUR_DIRECTION internally.
Author: ctopper Date: Sat Jul 7 15:03:16 2018 New Revision: 336498 URL: http://llvm.org/viewvc/llvm-project?rev=336498&view=rev Log: [X86] Fix a few intrinsics that were ignoring their rounding mode argument and hardcoded _MM_FROUND_CUR_DIRECTION internally. I believe these have been broken since their introduction into clang. I've enhanced the tests for these intrinsics to using a real rounding mode and checking all the intrinsic arguments instead of just the name. Modified: cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/test/CodeGen/avx512f-builtins.c Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=336498&r1=336497&r2=336498&view=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 7 15:03:16 2018 @@ -6597,7 +6597,7 @@ _mm_maskz_scalef_ss (__mmask8 __U, __m12 (__v4sf)(__m128)(B), \ (__v4sf)_mm_setzero_ps(), \ (__mmask8)(U), \ - _MM_FROUND_CUR_DIRECTION) + (int)(R)) static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_srai_epi32(__m512i __A, int __B) @@ -7826,7 +7826,7 @@ _mm_maskz_fmadd_ss (__mmask8 __U, __m128 (__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ (__v4sf)(__m128)(B), \ (__v4sf)(__m128)(C), (__mmask8)(U), \ - _MM_FROUND_CUR_DIRECTION) + (int)(R)) static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_mask3_fmadd_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) @@ -7988,7 +7988,7 @@ _mm_maskz_fnmsub_ss (__mmask8 __U, __m12 (__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ -(__v4sf)(__m128)(B), \ -(__v4sf)(__m128)(C), (__mmask8)(U), \ - _MM_FROUND_CUR_DIRECTION) + (int)(R)) static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_mask3_fnmsub_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) @@ -8042,7 +8042,7 @@ _mm_maskz_fmadd_sd (__mmask8 __U, __m128 (__m128d)__builtin_ia32_vfmaddsd3_maskz((__v2df)(__m128d)(A), \ (__v2df)(__m128d)(B), \ (__v2df)(__m128d)(C), (__mmask8)(U), \ - _MM_FROUND_CUR_DIRECTION) + (int)(R)) static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mask3_fmadd_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) @@ -8205,7 +8205,7 @@ _mm_maskz_fnmsub_sd (__mmask8 __U, __m12 -(__v2df)(__m128d)(B), \ -(__v2df)(__m128d)(C), \ (__mmask8)(U), \ - _MM_FROUND_CUR_DIRECTION) + (int)(R)) static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_mask3_fnmsub_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=336498&r1=336497&r2=336498&view=diff == --- cfe/trunk/test/CodeGen/avx512f-builtins.c (original) +++ cfe/trunk/test/CodeGen/avx512f-builtins.c Sat Jul 7 15:03:16 2018 @@ -5433,8 +5433,8 @@ __m512 test_mm512_maskz_scalef_ps(__mmas __m128d test_mm_scalef_round_sd(__m128d __A, __m128d __B) { // CHECK-LABEL: @test_mm_scalef_round_sd - // CHECK: @llvm.x86.avx512.mask.scalef - return _mm_scalef_round_sd(__A, __B, _MM_FROUND_CUR_DIRECTION); + // CHECK: @llvm.x86.avx512.mask.scalef.sd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %2, i8 -1, i32 8) + return _mm_scalef_round_sd(__A, __B, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); } __m128d test_mm_scalef_sd(__m128d __A, __m128d __B) { @@ -5451,8 +5451,8 @@ __m128d test_mm_mask_scalef_sd(__m128d _ __m128d test_mm_mask_scalef_round_sd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B){ // CHECK-LABEL: @test_mm_mask_scalef_round_sd - // CHECK: @llvm.x86.avx512.mask.scalef.sd -return _mm_mask_scalef_round_sd(__W, __U, __A, __B, _MM_FROUND_CUR_DIRECTION); + // CHECK: @llvm.x86.avx512.mask.scalef.sd(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, i8 %{{.*}}, i32 8) +return _mm_mask_scalef_round_sd(__W, __U, __A, __B, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); }
r336499 - [X86] Remove some unnecessarily escaped new lines from avx512fintrin.h
Author: ctopper Date: Sat Jul 7 15:03:19 2018 New Revision: 336499 URL: http://llvm.org/viewvc/llvm-project?rev=336499&view=rev Log: [X86] Remove some unnecessarily escaped new lines from avx512fintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=336499&r1=336498&r2=336499&view=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat Jul 7 15:03:19 2018 @@ -4061,9 +4061,9 @@ _mm512_cvtps_epu32 ( __m512 __A) { return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A,\ (__v16si)\ - _mm512_undefined_epi32 (),\ + _mm512_undefined_epi32 (), (__mmask16) -1,\ - _MM_FROUND_CUR_DIRECTION);\ + _MM_FROUND_CUR_DIRECTION); } static __inline__ __m512i __DEFAULT_FN_ATTRS @@ -6608,15 +6608,15 @@ _mm512_srai_epi32(__m512i __A, int __B) static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_srai_epi32(__m512i __W, __mmask16 __U, __m512i __A, int __B) { - return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, \ - (__v16si)_mm512_srai_epi32(__A, __B), \ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srai_epi32(__A, __B), (__v16si)__W); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_srai_epi32(__mmask16 __U, __m512i __A, int __B) { - return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, \ - (__v16si)_mm512_srai_epi32(__A, __B), \ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srai_epi32(__A, __B), (__v16si)_mm512_setzero_si512()); } @@ -6629,16 +6629,16 @@ _mm512_srai_epi64(__m512i __A, int __B) static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_srai_epi64(__m512i __W, __mmask8 __U, __m512i __A, int __B) { - return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, \ - (__v8di)_mm512_srai_epi64(__A, __B), \ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srai_epi64(__A, __B), (__v8di)__W); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_srai_epi64(__mmask8 __U, __m512i __A, int __B) { - return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, \ - (__v8di)_mm512_srai_epi64(__A, __B), \ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srai_epi64(__A, __B), (__v8di)_mm512_setzero_si512()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336493 - [analyzer] Fix -Wcovered-switch-default warning in MallocChecker.
Author: rkovacs Date: Sat Jul 7 11:37:37 2018 New Revision: 336493 URL: http://llvm.org/viewvc/llvm-project?rev=336493&view=rev Log: [analyzer] Fix -Wcovered-switch-default warning in MallocChecker. Remove unnecessary default case that caused buildbot failures. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=336493&r1=336492&r2=336493&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sat Jul 7 11:37:37 2018 @@ -2915,7 +2915,6 @@ std::shared_ptr Mal Msg = "Internal buffer is released because the object was destroyed"; break; case AF_None: -default: llvm_unreachable("Unhandled allocation family!"); } StackHint = new StackHintGeneratorForSymbol(Sym, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336489 - [analyzer] Highlight container object destruction in MallocChecker.
Author: rkovacs Date: Sat Jul 7 10:22:45 2018 New Revision: 336489 URL: http://llvm.org/viewvc/llvm-project?rev=336489&view=rev Log: [analyzer] Highlight container object destruction in MallocChecker. Extend MallocBugVisitor to place a note at the point where objects with AF_InternalBuffer allocation family are destroyed. Differential Revision: https://reviews.llvm.org/D48521 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=336489&r1=336488&r2=336489&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sat Jul 7 10:22:45 2018 @@ -480,8 +480,13 @@ private: inline bool isReleased(const RefState *S, const RefState *SPrev, const Stmt *Stmt) { // Did not track -> released. Other state (allocated) -> released. - return (Stmt && (isa(Stmt) || isa(Stmt)) && - (S && S->isReleased()) && (!SPrev || !SPrev->isReleased())); + // The statement associated with the release might be missing. + bool IsReleased = (S && S->isReleased()) && +(!SPrev || !SPrev->isReleased()); + assert(!IsReleased || + (Stmt && (isa(Stmt) || isa(Stmt))) || + (!Stmt && S->getAllocationFamily() == AF_InternalBuffer)); + return IsReleased; } inline bool isRelinquished(const RefState *S, const RefState *SPrev, @@ -2850,8 +2855,17 @@ static bool isReferenceCountingPointerDe std::shared_ptr MallocChecker::MallocBugVisitor::VisitNode( const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) { + + ProgramStateRef state = N->getState(); + ProgramStateRef statePrev = PrevN->getState(); + + const RefState *RS = state->get(Sym); + const RefState *RSPrev = statePrev->get(Sym); + const Stmt *S = PathDiagnosticLocation::getStmt(N); - if (!S) + // When dealing with containers, we sometimes want to give a note + // even if the statement is missing. + if (!S && (!RS || RS->getAllocationFamily() != AF_InternalBuffer)) return nullptr; const LocationContext *CurrentLC = N->getLocationContext(); @@ -2876,14 +2890,6 @@ std::shared_ptr Mal } } - ProgramStateRef state = N->getState(); - ProgramStateRef statePrev = PrevN->getState(); - - const RefState *RS = state->get(Sym); - const RefState *RSPrev = statePrev->get(Sym); - if (!RS) -return nullptr; - // FIXME: We will eventually need to handle non-statement-based events // (__attribute__((cleanup))). @@ -2896,7 +2902,22 @@ std::shared_ptr Mal StackHint = new StackHintGeneratorForSymbol(Sym, "Returned allocated memory"); } else if (isReleased(RS, RSPrev, S)) { - Msg = "Memory is released"; + const auto Family = RS->getAllocationFamily(); + switch(Family) { +case AF_Alloca: +case AF_Malloc: +case AF_CXXNew: +case AF_CXXNewArray: +case AF_IfNameIndex: + Msg = "Memory is released"; + break; +case AF_InternalBuffer: + Msg = "Internal buffer is released because the object was destroyed"; + break; +case AF_None: +default: + llvm_unreachable("Unhandled allocation family!"); + } StackHint = new StackHintGeneratorForSymbol(Sym, "Returning; memory was released"); @@ -2967,8 +2988,19 @@ std::shared_ptr Mal assert(StackHint); // Generate the extra diagnostic. - PathDiagnosticLocation Pos(S, BRC.getSourceManager(), - N->getLocationContext()); + PathDiagnosticLocation Pos; + if (!S) { +assert(RS->getAllocationFamily() == AF_InternalBuffer); +auto PostImplCall = N->getLocation().getAs(); +if (!PostImplCall) + return nullptr; +Pos = PathDiagnosticLocation(PostImplCall->getLocation(), + BRC.getSourceManager()); + } else { +Pos = PathDiagnosticLocation(S, BRC.getSourceManager(), + N->getLocationContext()); + } + return std::make_shared(Pos, Msg, true, StackHint); } Modified: cfe/trunk/test/Analysis/dangling-internal-buffer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dangling-internal-buffer.cpp?rev=336489&r1=336488&r2=336489&view=diff == --- cfe/trunk/test/Analysis/dangling-internal-buffer.cpp (original) +++ cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Sat Jul 7 10:22:45 2018 @@ -26,7 +26,7 @@ void deref_after_sc
r336497 - [analyzer] Add support for data() in DanglingInternalBufferChecker.
Author: rkovacs Date: Sat Jul 7 13:29:24 2018 New Revision: 336497 URL: http://llvm.org/viewvc/llvm-project?rev=336497&view=rev Log: [analyzer] Add support for data() in DanglingInternalBufferChecker. DanglingInternalBufferChecker now tracks use-after-free problems related to the incorrect usage of std::basic_string::data(). Differential Revision: https://reviews.llvm.org/D48532 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp?rev=336497&r1=336496&r2=336497&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp Sat Jul 7 13:29:24 2018 @@ -24,15 +24,16 @@ using namespace clang; using namespace ento; -// FIXME: c_str() may be called on a string object many times, so it should -// have a list of symbols associated with it. +// FIXME: member functions that return a pointer to the container's internal +// buffer may be called on the object many times, so the object's memory +// region should have a list of pointer symbols associated with it. REGISTER_MAP_WITH_PROGRAMSTATE(RawPtrMap, const MemRegion *, SymbolRef) namespace { class DanglingInternalBufferChecker : public Checker { - CallDescription CStrFn; + CallDescription CStrFn, DataFn; public: class DanglingBufferBRVisitor : public BugReporterVisitor { @@ -67,7 +68,7 @@ public: } }; - DanglingInternalBufferChecker() : CStrFn("c_str") {} + DanglingInternalBufferChecker() : CStrFn("c_str"), DataFn("data") {} /// Record the connection between the symbol returned by c_str() and the /// corresponding string object region in the ProgramState. Mark the symbol @@ -97,7 +98,7 @@ void DanglingInternalBufferChecker::chec ProgramStateRef State = C.getState(); - if (Call.isCalled(CStrFn)) { + if (Call.isCalled(CStrFn) || Call.isCalled(DataFn)) { SVal RawPtr = Call.getReturnValue(); if (!RawPtr.isUnknown()) { State = State->set(TypedR, RawPtr.getAsSymbol()); Modified: cfe/trunk/test/Analysis/dangling-internal-buffer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dangling-internal-buffer.cpp?rev=336497&r1=336496&r2=336497&view=diff == --- cfe/trunk/test/Analysis/dangling-internal-buffer.cpp (original) +++ cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Sat Jul 7 13:29:24 2018 @@ -7,6 +7,8 @@ class basic_string { public: ~basic_string(); const CharT *c_str() const; + const CharT *data() const; + CharT *data(); }; typedef basic_string string; @@ -21,59 +23,92 @@ void consume(const wchar_t *) {} void consume(const char16_t *) {} void consume(const char32_t *) {} -void deref_after_scope_char() { +void deref_after_scope_char_cstr() { const char *c; { std::string s; c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::string s; + const char *c2 = s.c_str(); consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_char2() { +void deref_after_scope_char_data() { const char *c; { std::string s; -c = s.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} +c = s.data(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} std::string s; - const char *c2 = s.c_str(); + const char *c2 = s.data(); + consume(c); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void deref_after_scope_char_data_non_const() { + char *c; + { +std::string s; +c = s.data(); // expected-note {{Pointer to dangling buffer was obtained here}} + } // expected-note {{Internal buffer is released because the object was destroyed}} + std::string s; + char *c2 = s.data(); consume(c); // expected-warning {{Use of memory after it is freed}} // expected-note@-1 {{Use of memory after it is freed}} } -void deref_after_scope_wchar_t() { + +void deref_after_scope_wchar_t_cstr() { const wchar_t *w; { std::wstring ws; w = ws.c_str(); // expected-note {{Pointer to dangling buffer was obtained here}} } // expected-note {{Internal buffer is released because the object was destroyed}} + std::wstring ws; + const wchar_t *w2 = ws.c_str(); + consume(w); //
r336495 - [analyzer] Highlight c_str() call in DanglingInternalBufferChecker.
Author: rkovacs Date: Sat Jul 7 12:27:18 2018 New Revision: 336495 URL: http://llvm.org/viewvc/llvm-project?rev=336495&view=rev Log: [analyzer] Highlight c_str() call in DanglingInternalBufferChecker. Add a bug visitor to DanglingInternalBufferChecker that places a note at the point where the dangling pointer was obtained. The visitor is handed over to MallocChecker and attached to the report there. Differential Revision: https://reviews.llvm.org/D48522 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h?rev=336495&r1=336494&r2=336495&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h Sat Jul 7 12:27:18 2018 @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_ALLOCATIONSTATE_H #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_ALLOCATIONSTATE_H +#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" namespace clang { @@ -20,6 +21,11 @@ namespace allocation_state { ProgramStateRef markReleased(ProgramStateRef State, SymbolRef Sym, const Expr *Origin); +/// This function provides an additional visitor that augments the bug report +/// with information relevant to memory errors caused by the misuse of +/// AF_InternalBuffer symbols. +std::unique_ptr getDanglingBufferBRVisitor(SymbolRef Sym); + } // end namespace allocation_state } // end namespace ento Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp?rev=336495&r1=336494&r2=336495&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp Sat Jul 7 12:27:18 2018 @@ -7,30 +7,66 @@ // //===--===// // -// This file defines a check that marks a raw pointer to a C++ standard library -// container's inner buffer released when the object is destroyed. This -// information can be used by MallocChecker to detect use-after-free problems. +// This file defines a check that marks a raw pointer to a C++ container's +// inner buffer released when the object is destroyed. This information can +// be used by MallocChecker to detect use-after-free problems. // //===--===// +#include "AllocationState.h" #include "ClangSACheckers.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "AllocationState.h" using namespace clang; using namespace ento; +// FIXME: c_str() may be called on a string object many times, so it should +// have a list of symbols associated with it. +REGISTER_MAP_WITH_PROGRAMSTATE(RawPtrMap, const MemRegion *, SymbolRef) + namespace { -class DanglingInternalBufferChecker : public Checker { +class DanglingInternalBufferChecker +: public Checker { CallDescription CStrFn; public: + class DanglingBufferBRVisitor : public BugReporterVisitor { +SymbolRef PtrToBuf; + + public: +DanglingBufferBRVisitor(SymbolRef Sym) : PtrToBuf(Sym) {} + +static void *getTag() { + static int Tag = 0; + return &Tag; +} + +void Profile(llvm::FoldingSetNodeID &ID) const override { + ID.AddPointer(getTag()); +} + +std::shared_ptr VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + +// FIXME: Scan the map once in the visitor's constructor and do a direct +// lookup by region. +bool isSymbolTracked(ProgramStateRef State, SymbolRef Sym) { + RawPtrMapTy Map = State->get(); + for (const auto Entry : Map) { +if (Entry.second == Sym) + return true; + } + return false; +} + }; + DanglingInternalBufferChecker() : CStrFn("c_str") {} /// Re
[libcxx] r336502 - type_traits: aligned_union is NOT the same as __uncvref [NFC]
Author: caseycarter Date: Sat Jul 7 17:06:27 2018 New Revision: 336502 URL: http://llvm.org/viewvc/llvm-project?rev=336502&view=rev Log: type_traits: aligned_union is NOT the same as __uncvref [NFC] Modified: libcxx/trunk/include/type_traits Modified: libcxx/trunk/include/type_traits URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=336502&r1=336501&r2=336502&view=diff == --- libcxx/trunk/include/type_traits (original) +++ libcxx/trunk/include/type_traits Sat Jul 7 17:06:27 2018 @@ -21,7 +21,7 @@ namespace std template struct integral_constant; typedef integral_constant true_type; // C++11 typedef integral_constant false_type; // C++11 - + template// C++14 using bool_constant = integral_constant; // C++14 typedef bool_constant true_type; // C++14 @@ -172,7 +172,7 @@ namespace std using add_volatile_t= typename add_volatile::type; // C++14 template using add_cv_t = typename add_cv::type; // C++14 - + // reference modifications: template using remove_reference_t = typename remove_reference::type; // C++14 @@ -180,13 +180,13 @@ namespace std using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 template using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 - + // sign modifications: template using make_signed_t = typename make_signed::type; // C++14 template using make_unsigned_t = typename make_unsigned::type; // C++14 - + // array modifications: template using remove_extent_t = typename remove_extent::type; // C++14 @@ -223,7 +223,7 @@ namespace std template using void_t = void; // C++17 - + // See C++14 20.10.4.1, primary type categories template inline constexpr bool is_void_v = is_void::value; // C++17 @@ -386,13 +386,13 @@ namespace std // [meta.logical], logical operator traits: template struct conjunction; // C++17 - template + template inline constexpr bool conjunction_v = conjunction::value; // C++17 template struct disjunction; // C++17 template inline constexpr bool disjunction_v = disjunction::value; // C++17 template struct negation; // C++17 - template + template inline constexpr bool negation_v = negation::value; // C++17 } @@ -595,7 +595,7 @@ template struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; template -struct __and_<_B0, _B1, _B2, _Bn...> +struct __and_<_B0, _B1, _B2, _Bn...> : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; // __or_ @@ -608,11 +608,11 @@ template struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; template -struct __or_<_B0, _B1, _B2, _Bn...> +struct __or_<_B0, _B1, _B2, _Bn...> : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; // __not_ -template +template struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; #endif // !defined(_LIBCPP_CXX03_LANG) @@ -903,7 +903,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo // template struct__libcpp_is_member_function_pointer : public false_type {}; // template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; -// +// template struct __member_pointer_traits_imp @@ -1184,7 +1184,7 @@ struct __is_same_uncvref : is_same::type> {}; #if _LIBCPP_STD_VER > 17 -// aligned_union - same as __uncvref +// remove_cvref - same as __uncvref template struct remove_cvref : public __uncvref<_Tp> {}; @@ -1211,12 +1211,12 @@ template using remove_pointe // add_pointer -template ::value || +template ::value || is_same::type, void>::value> struct __add_pointer_impl {typedef typename remove_reference<_Tp>::type* type;}; -template struct __add_pointer_impl<_Tp, false> +template struct __add_pointer_impl<_Tp, false> {typedef _Tp type;}; template struct _LIBCPP_TEMPLATE_VIS add_pointer @@ -1630,7 +1630,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) template struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations -: public integral_constant>)> {}; #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) @@ -2241,7 +2241,7 @@ struct __is_destructor_wellformed { template static __two __test (...); - + static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); }; @@ -2249,8 +2249,8 @@ template struct __destructible_imp; te
[PATCH] D45712: Diagnose invalid cv-qualifiers for friend decls.
rsmith added a comment. Can we avoid the duplication by putting this check in `Sema::ParsedFreeStandingDeclSpec` instead? Repository: rC Clang https://reviews.llvm.org/D45712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336507 - [X86] Add new scalar fma intrinsics with rounding mode that use f32/f64 types.
Author: ctopper Date: Sat Jul 7 18:10:47 2018 New Revision: 336507 URL: http://llvm.org/viewvc/llvm-project?rev=336507&view=rev Log: [X86] Add new scalar fma intrinsics with rounding mode that use f32/f64 types. This allows us to handle masking in a very similar way to the default rounding version that uses llvm.fma Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/avx512f-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=336507&r1=336506&r2=336507&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jul 7 18:10:47 2018 @@ -8718,6 +8718,47 @@ static Value *EmitX86FMAExpr(CodeGenFunc return Res; } +static Value * +EmitScalarFMAExpr(CodeGenFunction &CGF, MutableArrayRef Ops, + Value *Upper, bool ZeroMask = false, unsigned PTIdx = 0, + bool NegAcc = false) { + unsigned Rnd = 4; + if (Ops.size() > 4) +Rnd = cast(Ops[4])->getZExtValue(); + + if (NegAcc) +Ops[2] = CGF.Builder.CreateFNeg(Ops[2]); + + Ops[0] = CGF.Builder.CreateExtractElement(Ops[0], (uint64_t)0); + Ops[1] = CGF.Builder.CreateExtractElement(Ops[1], (uint64_t)0); + Ops[2] = CGF.Builder.CreateExtractElement(Ops[2], (uint64_t)0); + Value *Res; + if (Rnd != 4) { +Intrinsic::ID IID = Ops[0]->getType()->getPrimitiveSizeInBits() == 32 ? +Intrinsic::x86_avx512_vfmadd_f32 : +Intrinsic::x86_avx512_vfmadd_f64; +Res = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IID), + {Ops[0], Ops[1], Ops[2], Ops[4]}); + } else { +Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ops[0]->getType()); +Res = CGF.Builder.CreateCall(FMA, Ops.slice(0, 3)); + } + // If we have more than 3 arguments, we need to do masking. + if (Ops.size() > 3) { +Value *PassThru = ZeroMask ? Constant::getNullValue(Res->getType()) + : Ops[PTIdx]; + +// If we negated the accumulator and the its the PassThru value we need to +// bypass the negate. Conveniently Upper should be the same thing in this +// case. +if (NegAcc && PTIdx == 2) + PassThru = CGF.Builder.CreateExtractElement(Upper, (uint64_t)0); + +Res = EmitX86ScalarSelect(CGF, Ops[3], Res, PassThru); + } + return CGF.Builder.CreateInsertElement(Upper, Res, (uint64_t)0); +} + static Value *EmitX86Muldq(CodeGenFunction &CGF, bool IsSigned, ArrayRef Ops) { llvm::Type *Ty = Ops[0]->getType(); @@ -9141,24 +9182,24 @@ Value *CodeGenFunction::EmitX86BuiltinEx return EmitX86ConvertToMask(*this, Ops[0]); case X86::BI__builtin_ia32_vfmaddss3: - case X86::BI__builtin_ia32_vfmaddsd3: { -Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0); -Value *B = Builder.CreateExtractElement(Ops[1], (uint64_t)0); -Value *C = Builder.CreateExtractElement(Ops[2], (uint64_t)0); -Function *FMA = CGM.getIntrinsic(Intrinsic::fma, A->getType()); -Value *Res = Builder.CreateCall(FMA, {A, B, C} ); -return Builder.CreateInsertElement(Ops[0], Res, (uint64_t)0); - } + case X86::BI__builtin_ia32_vfmaddsd3: + case X86::BI__builtin_ia32_vfmaddss3_mask: + case X86::BI__builtin_ia32_vfmaddsd3_mask: +return EmitScalarFMAExpr(*this, Ops, Ops[0]); case X86::BI__builtin_ia32_vfmaddss: - case X86::BI__builtin_ia32_vfmaddsd: { -Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0); -Value *B = Builder.CreateExtractElement(Ops[1], (uint64_t)0); -Value *C = Builder.CreateExtractElement(Ops[2], (uint64_t)0); -Function *FMA = CGM.getIntrinsic(Intrinsic::fma, A->getType()); -Value *Res = Builder.CreateCall(FMA, {A, B, C} ); -Value *Zero = Constant::getNullValue(Ops[0]->getType()); -return Builder.CreateInsertElement(Zero, Res, (uint64_t)0); - } + case X86::BI__builtin_ia32_vfmaddsd: +return EmitScalarFMAExpr(*this, Ops, + Constant::getNullValue(Ops[0]->getType())); + case X86::BI__builtin_ia32_vfmaddss3_maskz: + case X86::BI__builtin_ia32_vfmaddsd3_maskz: +return EmitScalarFMAExpr(*this, Ops, Ops[0], /*ZeroMask*/true); + case X86::BI__builtin_ia32_vfmaddss3_mask3: + case X86::BI__builtin_ia32_vfmaddsd3_mask3: +return EmitScalarFMAExpr(*this, Ops, Ops[2], /*ZeroMask*/false, 2); + case X86::BI__builtin_ia32_vfmsubss3_mask3: + case X86::BI__builtin_ia32_vfmsubsd3_mask3: +return EmitScalarFMAExpr(*this, Ops, Ops[2], /*ZeroMask*/false, 2, + /*NegAcc*/true); case X86::BI__builtin_ia32_vfmaddps: case X86::BI__builtin_ia32_vfmaddpd: case X86::BI__builtin_ia32_vfmaddps256: Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=336507&r1=336506&r2=
[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute
rjmccall added inline comments. Comment at: test/SemaObjC/property-in-class-extension-1.m:18 -@property (assign, readonly) NSString* changeMemoryModel; // expected-note {{property declared here}} +@property (unsafe_unretained, readonly) NSString* changeMemoryModel; // expected-note {{property declared here}} QF5690 wrote: > rjmccall wrote: > > Whoa, why is this test case using `-Weverything`? That seems unnecessarily > > fragile. > Do you think it should be relaxed only to warnings that are appearing here? Yeah, tests should generally only be testing specific categories. Opt-out warnings are different, of course, but it's understood that adding a new opt-out warning is an ambitious change. Repository: rC Clang https://reviews.llvm.org/D44539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits