[PATCH] D37577: [libclang] add 'clang_getCursorTLSKind'
nik added inline comments. Comment at: include/clang-c/Index.h:2840 +/** + * \brief Describe the "TLS kind" of the declaration referred to by a cursor. + */ I was wondering what "TLS" is and had to look it up. If not adapting the function and enum name, then maybe at least write it out once in the documentation. https://reviews.llvm.org/D37577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37694: [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang)
uriel.k added a comment. If I remove the builtins from the .def file this will not work, as I didn't replace the builtin call in the Header files but implemented the lowering by adding cases to the CGBuiltin.cpp and adding the IR by hand. https://reviews.llvm.org/D37694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37694: [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang)
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. Oops you are correct. Sorry. LGTM https://reviews.llvm.org/D37694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR
craig.topper added inline comments. Comment at: include/clang/Basic/BuiltinsX86.def:981 -TARGET_BUILTIN(__builtin_ia32_pbroadcastd512_gpr_mask, "V16iiV16iUs", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_pbroadcastq512_mem_mask, "V8LLiLLiV8LLiUc", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_loaddqusi512_mask, "V16iiC*V16iUs", "", "avx512f") I think you patch removed the only use of __builtin_ia32_pbroadcastq512_mem_mask right? Does your change work properly in 32-bit mode? Comment at: lib/Headers/avx512bwintrin.h:2031 { - return (__m512i) __builtin_ia32_pbroadcastb512_gpr_mask (__A, - (__v64qi) __O, - __M); + __m512i __V = _mm512_set1_epi8(__A); + return (__m512i) __builtin_ia32_selectb_512(__M,(__v64qi)__V,(__v64qi) __O); We usually don't declare variables in the intrinsics if we can avoid it. Just nest the calls. Comment at: test/CodeGen/avx512vl-builtins.c:4511 // CHECK-LABEL: @test_mm256_mask_set1_epi32 - // CHECK: @llvm.x86.avx512.mask.pbroadcast.d.gpr.256 +// CHECK: insertelement <8 x i32> undef, i32 %{{.*}}, i32 0 + // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 1 The first line is over indented Comment at: test/CodeGen/avx512vl-builtins.c:4525 // CHECK-LABEL: @test_mm256_maskz_set1_epi32 - // CHECK: @llvm.x86.avx512.mask.pbroadcast.d.gpr.256 +// CHECK: insertelement <8 x i32> undef, i32 %{{.*}}, i32 0 + // CHECK: insertelement <8 x i32> %{{.*}}, i32 %{{.*}}, i32 1 The first line is overindented https://reviews.llvm.org/D37668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.
nik added a comment. Fixes the reported issue, thanks! I still run into another case that is not yet properly covered. The reported issue was extracted from the following case. If you prefer, I'll create a separate report for the remaining issues. The follow code outlines the problems in the comments: #ifdef MYCPLUSPLUS extern "C" { // On parse this is skipped as expected. On reparse, this is surprisingly not skipped anymore. #endif #ifdef MYCPLUSPLUS } #endif int main() { return 0; } // On reparse a diagnostic is added here: "expected '}' to match this '{' (line 2)" Here are some c-index-test invocations for this to make this testable/reproducible ($FILE does not contain the above comments): Do a parse and save the tokens: % ./c-index-test -test-annotate-tokens=$FILE:1:1:7:1 $FILE > /tmp/1 No diagnostics are emitted as expected. Do a parse and reparse and save also the tokens: % CINDEXTEST_EDITING=1 ./c-index-test -test-annotate-tokens=$FILE:1:1:7:1 $FILE > /tmp/2 $FILE:12:2: error: expected '}' Number FIX-ITs = 0 $FILE:2:12: note: to match this '{' Number FIX-ITs = 0 Note that a new diagnostic is emitted on reparse at the bottom of the file (issue1). Also, the first skipped source range is not skipped anymore on reparse (issue2): % diff -u /tmp/{1,2} --- /tmp/12017-09-12 09:33:42.210204021 +0200 +++ /tmp/22017-09-12 09:33:51.458334870 +0200 @@ -1,4 +1,3 @@ -Skipping: [1:2 - 3:7] Skipping: [5:2 - 7:7] Punctuation: "#" [1:1 - 1:2] preprocessing directive= Identifier: "ifdef" [1:2 - 1:7] preprocessing directive= zsh: exit 1 colordiff -u /tmp/{1,2} % https://reviews.llvm.org/D37700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR
This revision was automatically updated to reflect the committed changes. Closed by commit rL313011: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR (authored by ytsafrir). Changed prior to commit: https://reviews.llvm.org/D37562?vs=114523&id=114772#toc Repository: rL LLVM https://reviews.llvm.org/D37562 Files: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/Headers/avx2intrin.h cfe/trunk/lib/Headers/avx512bwintrin.h cfe/trunk/lib/Headers/emmintrin.h cfe/trunk/test/CodeGen/avx2-builtins.c cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c cfe/trunk/test/CodeGen/builtins-x86.c cfe/trunk/test/CodeGen/sse2-builtins.c Index: cfe/trunk/lib/Headers/avx512bwintrin.h === --- cfe/trunk/lib/Headers/avx512bwintrin.h +++ cfe/trunk/lib/Headers/avx512bwintrin.h @@ -706,57 +706,55 @@ static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_avg_epu8 (__m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgb512_mask ((__v64qi) __A, - (__v64qi) __B, - (__v64qi) _mm512_setzero_qi(), - (__mmask64) -1); + typedef unsigned short __v64hu __attribute__((__vector_size__(128))); + return (__m512i)__builtin_convertvector( + ((__builtin_convertvector((__v64qu) __A, __v64hu) + +__builtin_convertvector((__v64qu) __B, __v64hu)) + 1) +>> 1, __v64qu); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_avg_epu8 (__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgb512_mask ((__v64qi) __A, - (__v64qi) __B, - (__v64qi) __W, - (__mmask64) __U); + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_avg_epu8(__A, __B), + (__v64qi)__W); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_avg_epu8 (__mmask64 __U, __m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgb512_mask ((__v64qi) __A, - (__v64qi) __B, - (__v64qi) _mm512_setzero_qi(), - (__mmask64) __U); + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_avg_epu8(__A, __B), + (__v64qi)_mm512_setzero_qi()); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_avg_epu16 (__m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgw512_mask ((__v32hi) __A, - (__v32hi) __B, - (__v32hi) _mm512_setzero_hi(), - (__mmask32) -1); + typedef unsigned int __v32su __attribute__((__vector_size__(128))); + return (__m512i)__builtin_convertvector( + ((__builtin_convertvector((__v32hu) __A, __v32su) + +__builtin_convertvector((__v32hu) __B, __v32su)) + 1) +>> 1, __v32hu); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_avg_epu16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgw512_mask ((__v32hi) __A, - (__v32hi) __B, - (__v32hi) __W, - (__mmask32) __U); + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_avg_epu16(__A, __B), + (__v32hi)__W); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_avg_epu16 (__mmask32 __U, __m512i __A, __m512i __B) { - return (__m512i) __builtin_ia32_pavgw512_mask ((__v32hi) __A, - (__v32hi) __B, - (__v32hi) _mm512_setzero_hi(), - (__mmask32) __U); + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_avg_epu16(__A, __B), + (__v32hi) _mm512_setzero_hi()); } static __inline__ __m512i __DEFAULT_FN_ATTRS Index: cfe/trunk/lib/Headers/emmintrin.h === --- cfe/trunk/lib/Headers/emmintrin.h +++ cfe/trunk/lib/Headers/emmintrin.h @@ -2258,7 +2258,11 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_avg_epu8(__m128i __a, __m128i __b) { - return (__m128i)__builtin_ia32_pavgb128((__v16qi)__a, (__v16qi)__b); + typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32))); + return (__m128i)__builtin_convertvector( + ((__builtin_convertvector((__v16qu)__a, __v16hu) + + __builtin_convertvector((__v16qu)__b, __v16hu)) + 1) + >> 1, __v16qu); } /// \brief Computes the rounded avarages of corresponding elements of two @@ -2278,7 +2282,11 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_avg_epu16(__m128i __a, __m128i __b) { - return (__m128i)__builtin_ia32_pavgw128((__v8hi)__a, (__v8hi)__b); + typedef unsigned int __v8su __attribute__ ((__vector_size__ (32))); + return (__m128i)__builtin_convertvector( + ((__builtin_convertvector((__v8hu)__
r313011 - [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR
Author: ytsafrir Date: Tue Sep 12 00:46:32 2017 New Revision: 313011 URL: http://llvm.org/viewvc/llvm-project?rev=313011&view=rev Log: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR Differential Revision: https://reviews.llvm.org/D37562 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/Headers/avx2intrin.h cfe/trunk/lib/Headers/avx512bwintrin.h cfe/trunk/lib/Headers/emmintrin.h cfe/trunk/test/CodeGen/avx2-builtins.c cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c cfe/trunk/test/CodeGen/builtins-x86.c cfe/trunk/test/CodeGen/sse2-builtins.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=313011&r1=313010&r2=313011&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Sep 12 00:46:32 2017 @@ -266,8 +266,6 @@ TARGET_BUILTIN(__builtin_ia32_paddusw128 TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "", "sse2") TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "", "sse2") TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "", "sse2") -TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "", "sse2") -TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "", "sse2") TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "", "sse2") TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "", "sse2") TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "", "sse2") @@ -522,8 +520,6 @@ TARGET_BUILTIN(__builtin_ia32_paddusw256 TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "", "avx2") TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "", "avx2") TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "", "avx2") -TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "", "avx2") -TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "", "avx2") TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "", "avx2") TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "", "avx2") TARGET_BUILTIN(__builtin_ia32_phaddd256, "V8iV8iV8i", "", "avx2") @@ -1075,8 +1071,6 @@ TARGET_BUILTIN(__builtin_ia32_paddsb512_ TARGET_BUILTIN(__builtin_ia32_paddsw512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_paddusb512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_paddusw512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_pavgb512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_pavgw512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_pmaxsb512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_pmaxsw512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_pmaxub512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") Modified: cfe/trunk/lib/Headers/avx2intrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=313011&r1=313010&r2=313011&view=diff == --- cfe/trunk/lib/Headers/avx2intrin.h (original) +++ cfe/trunk/lib/Headers/avx2intrin.h Tue Sep 12 00:46:32 2017 @@ -145,13 +145,21 @@ _mm256_andnot_si256(__m256i __a, __m256i static __inline__ __m256i __DEFAULT_FN_ATTRS _mm256_avg_epu8(__m256i __a, __m256i __b) { - return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b); + typedef unsigned short __v32hu __attribute__((__vector_size__(64))); + return (__m256i)__builtin_convertvector( + ((__builtin_convertvector((__v32qu)__a, __v32hu) + + __builtin_convertvector((__v32qu)__b, __v32hu)) + 1) + >> 1, __v32qu); } static __inline__ __m256i __DEFAULT_FN_ATTRS _mm256_avg_epu16(__m256i __a, __m256i __b) { - return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b); + typedef unsigned int __v16su __attribute__((__vector_size__(64))); + return (__m256i)__builtin_convertvector( + ((__builtin_convertvector((__v16hu)__a, __v16su) + + __builtin_convertvector((__v16hu)__b, __v16su)) + 1) + >> 1, __v16hu); } static __inline__ __m256i __DEFAULT_FN_ATTRS Modified: cfe/trunk/lib/Headers/avx512bwintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=313011&r1=313010&r2=313011&view=diff == --- cfe/trunk/lib/Headers/avx512bwintrin.h (original) +++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue Sep 12 00:46:32 2017 @@ -706,57 +706,55 @@ _mm512_maskz_adds_epu16 (__mmask32 __U, static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_avg_epu8 (__m512i __A, __m512i __B) { - return (__m512i) _
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
klimek accepted this revision. klimek added a comment. LG. Nice, thanks! Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:42 + +class LocalRename : public RefactoringAction { +public: I have to admit, the implementation here is pretty neat! :) Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.
erikjv added a comment. I'd put/fix Nik's issue in a separate patch. https://reviews.llvm.org/D37700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
mstorsjo added a comment. I'm not sure I like this direction. In my setups, a build-time default isn't right since I'm using the same clang builds for both native-on-linux building (with the default `ld` as linker) and cross-building targeting windows (using `ldd`), and keeping the code that reads `-fuse-ld=` is essential. I haven't followed the changes closely on how this works with the build-time `CLANG_DEFAULT_LINKER`, but can't we just make the current code check this define if `-fuse-ld` isn't set? Comment at: lib/Driver/ToolChains/MinGW.cpp:107 - StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "lld"); - if (LinkerName.equals_lower("lld")) { This diff isn't based on the current master version, where this defaults to `ld` Comment at: lib/Driver/ToolChains/MinGW.cpp:236 CmdArgs.push_back("--end-group"); - else if (!LinkerName.equals_lower("lld")) + else AddLibGCC(Args, CmdArgs); So if you do a clang build that defaults to `lld`, this should suddenly be included? Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313014 - Fix recording preamble's conditional stack in skipped PP branches.
Author: ibiryukov Date: Tue Sep 12 01:35:57 2017 New Revision: 313014 URL: http://llvm.org/viewvc/llvm-project?rev=313014&view=rev Log: Fix recording preamble's conditional stack in skipped PP branches. Summary: This fixes PR34547. `Lexer::LexEndOfFile` handles recording of ConditionalStack for preamble and reporting errors about unmatched conditionalal PP directives. However, SkipExcludedConditionalBlock contianed duplicated logic for reporting errors and clearing ConditionalStack, but not for preamble recording. This fix removes error reporting logic from `SkipExcludedConditionalBlock`, unmatched PP conditionals are now reported inside `Lexer::LexEndOfFile`. Reviewers: erikjv, klimek, bkramer Reviewed By: erikjv Subscribers: nik, cfe-commits Differential Revision: https://reviews.llvm.org/D37700 Added: cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp cfe/trunk/test/Index/preamble-conditionals-inverted.cpp Modified: cfe/trunk/lib/Lex/PPDirectives.cpp Modified: cfe/trunk/lib/Lex/PPDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=313014&r1=313013&r2=313014&view=diff == --- cfe/trunk/lib/Lex/PPDirectives.cpp (original) +++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Sep 12 01:35:57 2017 @@ -383,15 +383,8 @@ void Preprocessor::SkipExcludedCondition // If this is the end of the buffer, we have an error. if (Tok.is(tok::eof)) { - // Emit errors for each unterminated conditional on the stack, including - // the current one. - while (!CurPPLexer->ConditionalStack.empty()) { -if (CurLexer->getFileLoc() != CodeCompletionFileLoc) - Diag(CurPPLexer->ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); -CurPPLexer->ConditionalStack.pop_back(); - } - + // We don't emit errors for unterminated conditionals here, + // Lexer::LexEndOfFile can do that propertly. // Just return and let the caller lex after this #include. break; } Added: cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp?rev=313014&view=auto == --- cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp (added) +++ cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp Tue Sep 12 01:35:57 2017 @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s +#ifdef FOO_H + +void foo(); + +// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive Added: cfe/trunk/test/Index/preamble-conditionals-inverted.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble-conditionals-inverted.cpp?rev=313014&view=auto == --- cfe/trunk/test/Index/preamble-conditionals-inverted.cpp (added) +++ cfe/trunk/test/Index/preamble-conditionals-inverted.cpp Tue Sep 12 01:35:57 2017 @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" +#ifdef FOO_H + +void foo(); + +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.
This revision was automatically updated to reflect the committed changes. Closed by commit rL313014: Fix recording preamble's conditional stack in skipped PP branches. (authored by ibiryukov). Repository: rL LLVM https://reviews.llvm.org/D37700 Files: cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp cfe/trunk/test/Index/preamble-conditionals-inverted.cpp Index: cfe/trunk/lib/Lex/PPDirectives.cpp === --- cfe/trunk/lib/Lex/PPDirectives.cpp +++ cfe/trunk/lib/Lex/PPDirectives.cpp @@ -383,15 +383,8 @@ // If this is the end of the buffer, we have an error. if (Tok.is(tok::eof)) { - // Emit errors for each unterminated conditional on the stack, including - // the current one. - while (!CurPPLexer->ConditionalStack.empty()) { -if (CurLexer->getFileLoc() != CodeCompletionFileLoc) - Diag(CurPPLexer->ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); -CurPPLexer->ConditionalStack.pop_back(); - } - + // We don't emit errors for unterminated conditionals here, + // Lexer::LexEndOfFile can do that propertly. // Just return and let the caller lex after this #include. break; } Index: cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp === --- cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp +++ cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s +#ifdef FOO_H + +void foo(); + +// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive Index: cfe/trunk/test/Index/preamble-conditionals-inverted.cpp === --- cfe/trunk/test/Index/preamble-conditionals-inverted.cpp +++ cfe/trunk/test/Index/preamble-conditionals-inverted.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" +#ifdef FOO_H + +void foo(); + +#endif Index: cfe/trunk/lib/Lex/PPDirectives.cpp === --- cfe/trunk/lib/Lex/PPDirectives.cpp +++ cfe/trunk/lib/Lex/PPDirectives.cpp @@ -383,15 +383,8 @@ // If this is the end of the buffer, we have an error. if (Tok.is(tok::eof)) { - // Emit errors for each unterminated conditional on the stack, including - // the current one. - while (!CurPPLexer->ConditionalStack.empty()) { -if (CurLexer->getFileLoc() != CodeCompletionFileLoc) - Diag(CurPPLexer->ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); -CurPPLexer->ConditionalStack.pop_back(); - } - + // We don't emit errors for unterminated conditionals here, + // Lexer::LexEndOfFile can do that propertly. // Just return and let the caller lex after this #include. break; } Index: cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp === --- cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp +++ cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s +#ifdef FOO_H + +void foo(); + +// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive Index: cfe/trunk/test/Index/preamble-conditionals-inverted.cpp === --- cfe/trunk/test/Index/preamble-conditionals-inverted.cpp +++ cfe/trunk/test/Index/preamble-conditionals-inverted.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" +#ifdef FOO_H + +void foo(); + +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.
ilya-biryukov added a comment. In https://reviews.llvm.org/D37700#867625, @erikjv wrote: > I'd put/fix Nik's issue in a separate patch. Totally agree. It seems like a separate issue, though maybe related. @nik, could you file a separate bug so that we won't forget about it? Repository: rL LLVM https://reviews.llvm.org/D37700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37260: [clang-format] Fixed extern C brace wrapping
djasper added a comment. I am very strongly against a flag that just leaves the line break as is. What's the motivation? https://reviews.llvm.org/D37260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33440: clang-format: better handle statement and namespace macros
Typz updated this revision to Diff 114783. Typz added a comment. Rebase to master to fix merge issue https://reviews.llvm.org/D33440 Files: include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/FormatTokenLexer.cpp lib/Format/FormatTokenLexer.h lib/Format/NamespaceEndCommentsFixer.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineFormatter.cpp lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp unittests/Format/NamespaceEndCommentsFixerTest.cpp Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp === --- unittests/Format/NamespaceEndCommentsFixerTest.cpp +++ unittests/Format/NamespaceEndCommentsFixerTest.cpp @@ -53,6 +53,7 @@ " int i;\n" " int j;\n" "}")); + EXPECT_EQ("namespace {\n" " int i;\n" " int j;\n" @@ -249,6 +250,85 @@ "// unrelated")); } +TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) { + FormatStyle Style = getLLVMStyle(); + Style.NamespaceMacros.push_back("TESTSUITE"); + + EXPECT_EQ("TESTSUITE() {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE()", +fixNamespaceEndComments("TESTSUITE() {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + + EXPECT_EQ("TESTSUITE(A) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(A)", +fixNamespaceEndComments("TESTSUITE(A) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("inline TESTSUITE(A) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(A)", +fixNamespaceEndComments("inline TESTSUITE(A) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("TESTSUITE(::A) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(::A)", +fixNamespaceEndComments("TESTSUITE(::A) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("TESTSUITE(::A::B) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(::A::B)", +fixNamespaceEndComments("TESTSUITE(::A::B) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(::A::B)", +fixNamespaceEndComments("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("TESTSUITE(A, B) {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(A)", +fixNamespaceEndComments("TESTSUITE(A, B) {\n" +" int i;\n" +" int j;\n" +"}", +Style)); + EXPECT_EQ("TESTSUITE(\"Test1\") {\n" +" int i;\n" +" int j;\n" +"}// TESTSUITE(\"Test1\")", +fixNamespaceEndComments("TESTSUITE(\"Test1\") {\n" +" int i;\n" +" int j;\n" +"}", +Style)); +} + TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) { EXPECT_EQ("namespace A {\n" " int i;\n" @@ -381,6 +461,54 @@ "}; /* unnamed namespace */")); } +TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) { + FormatStyle Style = getLLVMStyle(); + Style.NamespaceMacros.push_back("TESTSUITE"); + + EXPECT_EQ("TESTSUITE() {\n" +" int i;\n" +"} // end anonymous TESTSUITE()", +fixNamespaceEndComments("TESTSUITE() {\n" +" int i;\n" +"} // end anonymous TESTSUITE()", +Style)); + EXPECT_EQ("TESTSUITE(A) {\n" +
[PATCH] D37260: [clang-format] Fixed extern C brace wrapping
PriMee added a comment. A new style, e.g. **BraceWrapping.AfterExternC** option is what we are considering right now. It would probably handle the problem. Leaving the line break as is might be indeed a bad idea :) https://reviews.llvm.org/D37260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33589: clang-format: consider not splitting tokens in optimization
djasper added a comment. I have a slightly hard time grasping what this patch now actually does? Doesn't it simply try to decide whether or not to make a split locally be comparing the PenaltyBreakComment against the penalty for the access characters? If so, couldn't we simply do that as an implementation detail of breakProtrudingToken() without needing to let anything outside of it now and without introducing State.Reflow? Comment at: lib/Format/ContinuationIndenter.cpp:1339 +unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, +LineState &State, Can you create a patch that doesn't move the code around so much? Seems unnecessary and hard to review. Comment at: lib/Format/ContinuationIndenter.cpp:1446 + // Do not count the penalty twice, it will be added afterwards + if (State.Column > getColumnLimit(State)) { +unsigned ExcessCharacters = State.Column - getColumnLimit(State); I believe that this is incorrect. reflowProtrudingToken counts the length of the unbreakable tail and here you just remove the penalty of the token itself. E.g. in: string s = f("aaa"); the ");" is the unbreakable tail of the stringl https://reviews.llvm.org/D33589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37260: [clang-format] Fixed extern C brace wrapping
djasper added a comment. BraceWrapping.AfterExternC makes sense to me. https://reviews.llvm.org/D37260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.
nik added a comment. In https://reviews.llvm.org/D37700#867646, @ilya-biryukov wrote: > @nik, could you file a separate bug so that we won't forget about it? Done, it's https://bugs.llvm.org/show_bug.cgi?id=34570 . Repository: rL LLVM https://reviews.llvm.org/D37700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37260: [clang-format] Fixed extern C brace wrapping
PriMee added a comment. Great! I will work on it :) https://reviews.llvm.org/D37260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37376: [libcxx] Fix libc++experimental build on Windows
hamzasood updated this revision to Diff 114784. hamzasood added a comment. Changed a CMake macro to a function. https://reviews.llvm.org/D37376 Files: CMakeLists.txt lib/CMakeLists.txt Index: lib/CMakeLists.txt === --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -186,31 +186,37 @@ split_list(LIBCXX_COMPILE_FLAGS) split_list(LIBCXX_LINK_FLAGS) +function(add_msvcrt_defs_if_needed target) + if(WIN32 AND NOT MINGW) +target_compile_definitions(${target} + PRIVATE + # Ignore the -MSC_VER mismatch, as we may build + # with a different compatibility version. + _ALLOW_MSC_VER_MISMATCH + # Don't check the msvcprt iterator debug levels + # as we will define the iterator types; libc++ + # uses a different macro to identify the debug + # level. + _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH + # We are building the c++ runtime, don't pull in + # msvcprt. + _CRTBLD + # Don't warn on the use of "deprecated" + # "insecure" functions which are standards + # specified. + _CRT_SECURE_NO_WARNINGS + # Use the ISO conforming behaviour for conversion + # in printf, scanf. + _CRT_STDIO_ISO_WIDE_SPECIFIERS) + endif() +endfunction() + # Add an object library that contains the compiled source files. add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) -if(WIN32 AND NOT MINGW) - target_compile_definitions(cxx_objects - PRIVATE - # Ignore the -MSC_VER mismatch, as we may build - # with a different compatibility version. - _ALLOW_MSC_VER_MISMATCH - # Don't check the msvcprt iterator debug levels - # as we will define the iterator types; libc++ - # uses a different macro to identify the debug - # level. - _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH - # We are building the c++ runtime, don't pull in - # msvcprt. - _CRTBLD - # Don't warn on the use of "deprecated" - # "insecure" functions which are standards - # specified. - _CRT_SECURE_NO_WARNINGS - # Use the ISO conforming behaviour for conversion - # in printf, scanf. - _CRT_STDIO_ISO_WIDE_SPECIFIERS) -endif() - +target_compile_definitions(cxx_objects + PRIVATE + _LIBCPP_BUILDING_LIBRARY) +add_msvcrt_defs_if_needed(cxx_objects) set_target_properties(cxx_objects PROPERTIES COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" @@ -285,7 +291,13 @@ if (LIBCXX_ENABLE_FILESYSTEM) file(GLOB LIBCXX_FILESYSTEM_SOURCES ../src/experimental/filesystem/*.cpp) endif() + add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES} ${LIBCXX_FILESYSTEM_SOURCES}) + target_compile_definitions(cxx_experimental + PRIVATE + _LIBCPPX_BUILDING_LIBRARY) + add_msvcrt_defs_if_needed(cxx_experimental) + if (LIBCXX_ENABLE_SHARED) target_link_libraries(cxx_experimental cxx_shared) else() @@ -313,6 +325,9 @@ add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) endif() + target_compile_definitions(cxx_external_threads + PRIVATE + _LIBCPP_BUILDING_LIBRARY) set_target_properties(cxx_external_threads PROPERTIES LINK_FLAGS"${LIBCXX_LINK_FLAGS}" Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -465,10 +465,6 @@ add_compile_flags_if_supported(-fcoroutines-ts) endif() -# Let the library headers know they are currently being used to build the -# library. -add_definitions(-D_LIBCPP_BUILDING_LIBRARY) - if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
hokein accepted this revision. hokein added a comment. LGTM, a few nits. Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:42 + +class LocalRename : public RefactoringAction { +public: klimek wrote: > I have to admit, the implementation here is pretty neat! :) +1 Comment at: test/Refactor/LocalRename/Field.cpp:4 +class Baz { + int /*range=*/Foo; // CHECK: =*/Bar; +public: I'd use a completed statement in `CHECK` (like `int /*range=*/Bar;`), which is more obvious to readers. Comment at: test/Refactor/tool-test-support.c:29 +// CHECK-NEXT: -selection={{.*}}tool-test-support.c:9:29 + +// CHECK: invoking action 'local-rename': Maybe add a comment describing the following cases are `named` test group -- it took me a while to understand why these "invoking action" messages aren't ordered by the original source line number. Comment at: tools/clang-refactor/ClangRefactor.cpp:89 + /// the test file. + virtual bool + forAllRanges(RefactoringRuleContext &Context, nit: `virtual` isn't needed. Comment at: tools/clang-refactor/TestSupport.cpp:28 +using namespace clang; +using namespace refactor; + I'm not a big fan of `using namespace`. It would make it hard to find out which namespace is the following method in -- readers have to go to the corresponding header file to find out the namespace. I'm +1 on using a more regular way `namespace clang { namespace refactor {...} }`. Comment at: tools/clang-refactor/TestSupport.cpp:127 + + virtual void handleError(llvm::Error Err) override { +handleResult(std::move(Err)); nit: virtual can be removed, the same below. Comment at: tools/clang-refactor/TestSupport.h:32 + +namespace refactor { + Do you plan to use `refactor` on other files? Comment at: tools/clang-refactor/TestSupport.h:104 + +} // end namespace clang_refactor +} // end namespace clang s/clang_refactor/refactor Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33440: clang-format: better handle statement and namespace macros
djasper added a comment. I'd still prefer individual patches for each of these changes. If the code review system or VCS make it hard for you to deal with two adjacent changes this way, do them in sequence. Adding Manuel as a reviewer who has a longer term idea on how to handle macros. https://reviews.llvm.org/D33440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r313016 - [clang-tidy] SuspiciousEnumUsageCheck bugfix
Author: szepet Date: Tue Sep 12 02:40:13 2017 New Revision: 313016 URL: http://llvm.org/viewvc/llvm-project?rev=313016&view=rev Log: [clang-tidy] SuspiciousEnumUsageCheck bugfix iThere is a reported bug on the checker not handling the some APSInt values correctly: https://bugs.llvm.org/show_bug.cgi?id=34400 This patch aims to fix it. Differential Revision: https://reviews.llvm.org/D37572 Modified: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp?rev=313016&r1=313015&r2=313016&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp Tue Sep 12 02:40:13 2017 @@ -42,7 +42,8 @@ struct ValueRange { const auto MinMaxVal = std::minmax_element( EnumDec->enumerator_begin(), EnumDec->enumerator_end(), [](const EnumConstantDecl *E1, const EnumConstantDecl *E2) { - return E1->getInitVal() < E2->getInitVal(); + return llvm::APSInt::compareValues(E1->getInitVal(), + E2->getInitVal()) < 0; }); MinVal = MinMaxVal.first->getInitVal(); MaxVal = MinMaxVal.second->getInitVal(); @@ -57,7 +58,8 @@ static int enumLength(const EnumDecl *En static bool hasDisjointValueRange(const EnumDecl *Enum1, const EnumDecl *Enum2) { ValueRange Range1(Enum1), Range2(Enum2); - return (Range1.MaxVal < Range2.MinVal) || (Range2.MaxVal < Range1.MinVal); + return llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) < 0 || + llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) < 0; } static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) { Modified: clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp?rev=313016&r1=313015&r2=313016&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp Tue Sep 12 02:40:13 2017 @@ -54,7 +54,7 @@ int trigger() { int emptytest = EmptyVal | B; if (bestDay() | A) return 1; - // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types + // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types if (I | Y) return 1; // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types @@ -88,3 +88,9 @@ int dont_trigger() { return 1; return 42; } + +namespace PR34400 { +enum { E1 = 0 }; +enum { E2 = -1 }; +enum { l = E1 | E2 }; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix
This revision was automatically updated to reflect the committed changes. Closed by commit rL313016: [clang-tidy] SuspiciousEnumUsageCheck bugfix (authored by szepet). Changed prior to commit: https://reviews.llvm.org/D37572?vs=114567&id=114788#toc Repository: rL LLVM https://reviews.llvm.org/D37572 Files: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp Index: clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp @@ -54,7 +54,7 @@ int emptytest = EmptyVal | B; if (bestDay() | A) return 1; - // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types + // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types if (I | Y) return 1; // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types @@ -88,3 +88,9 @@ return 1; return 42; } + +namespace PR34400 { +enum { E1 = 0 }; +enum { E2 = -1 }; +enum { l = E1 | E2 }; +} Index: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp @@ -42,7 +42,8 @@ const auto MinMaxVal = std::minmax_element( EnumDec->enumerator_begin(), EnumDec->enumerator_end(), [](const EnumConstantDecl *E1, const EnumConstantDecl *E2) { - return E1->getInitVal() < E2->getInitVal(); + return llvm::APSInt::compareValues(E1->getInitVal(), + E2->getInitVal()) < 0; }); MinVal = MinMaxVal.first->getInitVal(); MaxVal = MinMaxVal.second->getInitVal(); @@ -57,7 +58,8 @@ static bool hasDisjointValueRange(const EnumDecl *Enum1, const EnumDecl *Enum2) { ValueRange Range1(Enum1), Range2(Enum2); - return (Range1.MaxVal < Range2.MinVal) || (Range2.MaxVal < Range1.MinVal); + return llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) < 0 || + llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) < 0; } static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) { Index: clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-enum-usage.cpp @@ -54,7 +54,7 @@ int emptytest = EmptyVal | B; if (bestDay() | A) return 1; - // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types + // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types if (I | Y) return 1; // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types @@ -88,3 +88,9 @@ return 1; return 42; } + +namespace PR34400 { +enum { E1 = 0 }; +enum { E2 = -1 }; +enum { l = E1 | E2 }; +} Index: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp @@ -42,7 +42,8 @@ const auto MinMaxVal = std::minmax_element( EnumDec->enumerator_begin(), EnumDec->enumerator_end(), [](const EnumConstantDecl *E1, const EnumConstantDecl *E2) { - return E1->getInitVal() < E2->getInitVal(); + return llvm::APSInt::compareValues(E1->getInitVal(), + E2->getInitVal()) < 0; }); MinVal = MinMaxVal.first->getInitVal(); MaxVal = MinMaxVal.second->getInitVal(); @@ -57,7 +58,8 @@ static bool hasDisjointValueRange(const EnumDecl *Enum1, const EnumDecl *Enum2) { ValueRange Range1(Enum1), Range2(Enum2); - return (Range1.MaxVal < Range2.MinVal) || (Range2.MaxVal < Range1.MinVal); + return llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) < 0 || + llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) < 0; } static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37416: Use the VFS from the CompilerInvocation by default
teemperor updated this revision to Diff 114790. teemperor added a comment. - Rebased diff before merging. https://reviews.llvm.org/D37416 Files: lib/Frontend/CompilerInstance.cpp unittests/Frontend/CMakeLists.txt unittests/Frontend/CompilerInstanceTest.cpp Index: unittests/Frontend/CompilerInstanceTest.cpp === --- /dev/null +++ unittests/Frontend/CompilerInstanceTest.cpp @@ -0,0 +1,82 @@ +//===- unittests/Frontend/CompilerInstanceTest.cpp - ASTUnit tests ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include + +#include "clang/Frontend/ASTUnit.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/CompilerInvocation.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/ToolOutputFile.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +TEST(CompilerInstance, VFSOverlay) { + llvm::SmallString<256> CurrentPath; + llvm::sys::fs::current_path(CurrentPath); + + int VFSFD; + llvm::SmallString<256> VFSFileName; + ASSERT_FALSE( + llvm::sys::fs::createTemporaryFile("vfs", "yaml", VFSFD, VFSFileName)); + tool_output_file VFSFile(VFSFileName, VFSFD); + + llvm::sys::fs::make_absolute(CurrentPath, VFSFileName); + + VFSFile.os() << "{ 'version': 0, 'roots': [\n" + " { 'name': '" + << CurrentPath + << "',\n" + "'type': 'directory',\n" + "'contents': [\n" + " { 'name': 'virtual.file', 'type': 'file',\n" + "'external-contents': '" + << VFSFileName << "'\n" + " }\n" + "]\n" + " }\n" + "]}\n"; + VFSFile.os().flush(); + + int FD; + llvm::SmallString<256> InputFileName; + ASSERT_FALSE( + llvm::sys::fs::createTemporaryFile("vfs", "cpp", FD, InputFileName)); + tool_output_file input_file(InputFileName, FD); + input_file.os() << ""; + + std::string VFSArg = "-ivfsoverlay" + VFSFileName.str().str(); + + const char *Args[] = {"clang", VFSArg.c_str(), "-xc++", +InputFileName.c_str()}; + + IntrusiveRefCntPtr Diags = + CompilerInstance::createDiagnostics(new DiagnosticOptions()); + + std::shared_ptr CInvok = + createInvocationFromCommandLine(Args, Diags); + + if (!CInvok) +FAIL() << "could not create compiler invocation"; + CompilerInstance Instance; + Instance.setDiagnostics(Diags.get()); + Instance.setInvocation(CInvok); + Instance.createFileManager(); + + ASSERT_TRUE(Instance.getFileManager().getFile("virtual.file")); + ASSERT_FALSE(Instance.getFileManager().getFile("virtual.file2")); +} + +} // anonymous namespace Index: unittests/Frontend/CMakeLists.txt === --- unittests/Frontend/CMakeLists.txt +++ unittests/Frontend/CMakeLists.txt @@ -4,6 +4,7 @@ add_clang_unittest(FrontendTests ASTUnitTest.cpp + CompilerInstanceTest.cpp FrontendActionTest.cpp CodeGenActionTest.cpp PCHPreambleTest.cpp Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -302,8 +302,8 @@ void CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { -// TODO: choose the virtual file system based on the CompilerInvocation. -setVirtualFileSystem(vfs::getRealFileSystem()); +setVirtualFileSystem( +createVFSFromCompilerInvocation(getInvocation(), getDiagnostics())); } FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34878: [ARM] Option for reading thread pointer from coprocessor register
This revision was automatically updated to reflect the committed changes. Closed by commit rL313018: [ARM] Option for reading thread pointer from coprocessor register (authored by spetrovic). Changed prior to commit: https://reviews.llvm.org/D34878?vs=114618&id=114792#toc Repository: rL LLVM https://reviews.llvm.org/D34878 Files: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h cfe/trunk/test/Driver/clang-translation.c Index: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h === --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h @@ -32,14 +32,21 @@ void appendEBLinkFlags(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple); +enum class ReadTPMode { + Invalid, + Soft, + Cp15, +}; + enum class FloatABI { Invalid, Soft, SoftFP, Hard, }; FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args); +ReadTPMode getReadTPMode(const ToolChain &TC, const llvm::opt::ArgList &Args); bool useAAPCSForMachO(const llvm::Triple &T); void getARMArchCPUFromArgs(const llvm::opt::ArgList &Args, Index: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp === --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp @@ -131,6 +131,26 @@ T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T); } +// Select mode for reading thread pointer (-mtp=soft/cp15). +arm::ReadTPMode arm::getReadTPMode(const ToolChain &TC, const ArgList &Args) { + if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) { +const Driver &D = TC.getDriver(); +arm::ReadTPMode ThreadPointer = +llvm::StringSwitch(A->getValue()) +.Case("cp15", ReadTPMode::Cp15) +.Case("soft", ReadTPMode::Soft) +.Default(ReadTPMode::Invalid); +if (ThreadPointer != ReadTPMode::Invalid) + return ThreadPointer; +if (StringRef(A->getValue()).empty()) + D.Diag(diag::err_drv_missing_arg_mtp) << A->getAsString(Args); +else + D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args); +return ReadTPMode::Invalid; + } + return ReadTPMode::Soft; +} + // Select the float ABI as determined by -msoft-float, -mhard-float, and // -mfloat-abi=. arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { @@ -262,6 +282,7 @@ bool KernelOrKext = Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext); arm::FloatABI ABI = arm::getARMFloatABI(TC, Args); + arm::ReadTPMode ThreadPointer = arm::getReadTPMode(TC, Args); const Arg *WaCPU = nullptr, *WaFPU = nullptr; const Arg *WaHDiv = nullptr, *WaArch = nullptr; @@ -303,6 +324,9 @@ } } + if (ThreadPointer == arm::ReadTPMode::Cp15) +Features.push_back("+read-tp-hard"); + // Check -march. ClangAs gives preference to -Wa,-march=. const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ); StringRef ArchName; Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1689,6 +1689,8 @@ HelpText<"Disallow generation of data access to code sections (ARM only)">; def mno_execute_only : Flag<["-"], "mno-execute-only">, Group, HelpText<"Allow generation of data access to code sections (ARM only)">; +def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, Values<"soft, cp15">, + HelpText<"Read thread pointer from coprocessor register (ARM only)">; def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for GCC compatibility def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias; def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group; Index: cfe/trunk/include/clang/Driver/CC1Options.td === --- cfe/trunk/include/clang/Driver/CC1Options.td +++ cfe/trunk/include/clang/Driver/CC1Options.td @@ -257,6 +257,8 @@ "precision">; def mfloat_abi : Separate<["-"], "mfloat-abi">, HelpText<"The float ABI to use">; +def mtp : Separate<["-"], "mtp">, + HelpText<"Mode for reading thread pointer">; def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, HelpText<"Limit float precision to the given value">; def split_stacks : Flag<["-"], "split-stacks">, Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td @@ -101,6 +101,10 @@ "fai
r313018 - [ARM] Option for reading thread pointer from coprocessor register
Author: spetrovic Date: Tue Sep 12 03:40:58 2017 New Revision: 313018 URL: http://llvm.org/viewvc/llvm-project?rev=313018&view=rev Log: [ARM] Option for reading thread pointer from coprocessor register This patch enables option for reading thread pointer directly from coprocessor register (-mtp=soft/cp15). Differential Revision: https://reviews.llvm.org/D34878 Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h cfe/trunk/test/Driver/clang-translation.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=313018&r1=313017&r2=313018&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Sep 12 03:40:58 2017 @@ -101,6 +101,10 @@ def err_drv_force_crash : Error< "failing because %select{environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH' is set|'-gen-reproducer' is used}0">; def err_drv_invalid_mfloat_abi : Error< "invalid float ABI '%0'">; +def err_drv_invalid_mtp : Error< + "invalid thread pointer reading mode '%0'">; +def err_drv_missing_arg_mtp : Error< + "missing argument to '%0'">; def err_drv_invalid_libcxx_deployment : Error< "invalid deployment target for -stdlib=libc++ (requires %0 or later)">; def err_drv_invalid_argument_to_fdebug_prefix_map : Error< Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=313018&r1=313017&r2=313018&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Sep 12 03:40:58 2017 @@ -257,6 +257,8 @@ def menable_unsafe_fp_math : Flag<["-"], "precision">; def mfloat_abi : Separate<["-"], "mfloat-abi">, HelpText<"The float ABI to use">; +def mtp : Separate<["-"], "mtp">, + HelpText<"Mode for reading thread pointer">; def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, HelpText<"Limit float precision to the given value">; def split_stacks : Flag<["-"], "split-stacks">, Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=313018&r1=313017&r2=313018&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Sep 12 03:40:58 2017 @@ -1689,6 +1689,8 @@ def mexecute_only : Flag<["-"], "mexecut HelpText<"Disallow generation of data access to code sections (ARM only)">; def mno_execute_only : Flag<["-"], "mno-execute-only">, Group, HelpText<"Allow generation of data access to code sections (ARM only)">; +def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, Values<"soft, cp15">, + HelpText<"Read thread pointer from coprocessor register (ARM only)">; def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for GCC compatibility def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias; def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group; Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=313018&r1=313017&r2=313018&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Tue Sep 12 03:40:58 2017 @@ -131,6 +131,26 @@ bool arm::useAAPCSForMachO(const llvm::T T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T); } +// Select mode for reading thread pointer (-mtp=soft/cp15). +arm::ReadTPMode arm::getReadTPMode(const ToolChain &TC, const ArgList &Args) { + if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) { +const Driver &D = TC.getDriver(); +arm::ReadTPMode ThreadPointer = +llvm::StringSwitch(A->getValue()) +.Case("cp15", ReadTPMode::Cp15) +.Case("soft", ReadTPMode::Soft) +.Default(ReadTPMode::Invalid); +if (ThreadPointer != ReadTPMode::Invalid) + return ThreadPointer; +if (StringRef(A->getValue()).empty()) + D.Diag(diag::err_drv_missing_arg_mtp) << A->getAsString(Args); +else + D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args); +return ReadTPMode::Invalid; + } + return ReadTPMode::Soft; +} + // Select the float ABI as determined by -msoft-float, -mhard-float, and // -mfloat-abi=. arm::FloatABI arm::getARMFloatABI
[PATCH] D37727: Driver: Remove custom MinGW linker detection
mstorsjo added a comment. Actually, after testing this a bit more and looking at it, I withdraw my earlier complaints - this does indeed seem to work fine with my test setup. The generic `TC.GetLinkerPath()` picks up `-fuse-ld=lld` correctly and converts it into `ld.lld` which should be equivalent to `lld -flavor gnu`, at least in my linux cross compilation setup. And the extra `AddLibGCC()` call doesn't seem harmful for the lld setup. Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33620: [CodeGenCXX] do not default to dllimport storage for mingw-w64
mstorsjo added a comment. Does this break things for current users of clang as a drop-in replacement for gcc in mingw setups, while using e.g. a gcc provided `libstdc++-6.dll`? OTOH, removing dllimport usually isn't too much of an issue - the calls go via thunks which is non-ideal and theoretically slower but not much of an issue in practice. Repository: rL LLVM https://reviews.llvm.org/D33620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
martell added a comment. In https://reviews.llvm.org/D37727#867627, @mstorsjo wrote: > I'm not sure I like this direction. In my setups, a build-time default isn't > right since I'm using the same clang builds for both native-on-linux building > (with the default `ld` as linker) and cross-building targeting windows (using > `ldd`), and keeping the code that reads `-fuse-ld=` is essential. The `GetLinkerPath` function in `lib/Driver/ToolChain.cpp` that I replaced this with already checks `-fuse-ld` and does everything we need correctly. > I haven't followed the changes closely on how this works with the build-time > `CLANG_DEFAULT_LINKER`, but can't we just make the current code check this > define if `-fuse-ld` isn't set? If you specifically want a toolchain that uses lld by default for MINGW but ld for the platform and or host you should override the `getDefaultLinker` function in the Mingw driver with an out of tree patch. This is now what I do in my own builds since applying this patch. Hopefully when the MinGW driver becomes more stable such a patch can land in tree :) If you are happy with all being lld or all ld you should set CLANG_DEFAULT_LINKER. Note that `GetLinkerPath` also gives us the extra option to pass `-fuse-ld=platform` to use the platform default instead of the compile time default. Comment at: lib/Driver/ToolChains/MinGW.cpp:107 - StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "lld"); - if (LinkerName.equals_lower("lld")) { mstorsjo wrote: > This diff isn't based on the current master version, where this defaults to > `ld` Yeah the line was supposed to read `StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");` It was applied on top a commit for clang that changed ld -> lld here. The reason I want to merge this is so that I can stop doing that :) For the review because I am removing the line it does not matter much, I will update the diff to remove the extra `l` in the next revision. Comment at: lib/Driver/ToolChains/MinGW.cpp:236 CmdArgs.push_back("--end-group"); - else if (!LinkerName.equals_lower("lld")) + else AddLibGCC(Args, CmdArgs); mstorsjo wrote: > So if you do a clang build that defaults to `lld`, this should suddenly be > included? The previous check was if not lld so it would include it if it was ld or anything else. The MINGW lld driver does not complain about this, the behaviour should be the same for both. Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313019 - [MS-InlineAsm] Fix cast assertion with vector spills (PR34021)
Author: rksimon Date: Tue Sep 12 04:05:42 2017 New Revision: 313019 URL: http://llvm.org/viewvc/llvm-project?rev=313019&view=rev Log: [MS-InlineAsm] Fix cast assertion with vector spills (PR34021) Differential Revision: https://reviews.llvm.org/D37448 Added: cfe/trunk/test/CodeGen/pr34021.c Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=313019&r1=313018&r2=313019&view=diff == --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Sep 12 04:05:42 2017 @@ -2194,7 +2194,7 @@ void CodeGenFunction::EmitAsmStmt(const llvm::IntegerType::get(getLLVMContext(), (unsigned)TmpSize)); Tmp = Builder.CreateTrunc(Tmp, TruncTy); } else if (TruncTy->isIntegerTy()) { -Tmp = Builder.CreateTrunc(Tmp, TruncTy); +Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy); } else if (TruncTy->isVectorTy()) { Tmp = Builder.CreateBitCast(Tmp, TruncTy); } Added: cfe/trunk/test/CodeGen/pr34021.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr34021.c?rev=313019&view=auto == --- cfe/trunk/test/CodeGen/pr34021.c (added) +++ cfe/trunk/test/CodeGen/pr34021.c Tue Sep 12 04:05:42 2017 @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X64 + +typedef int v4si __attribute__ ((vector_size (16))); +v4si rep() { +// X86-LABEL: define <4 x i32> @rep +// X86: %retval = alloca <4 x i32>, align 16 +// X86-NEXT: %res = alloca <4 x i32>, align 16 +// X86-NEXT: %0 = bitcast <4 x i32>* %retval to i128* +// X86-NEXT: %1 = call i64 asm sideeffect inteldialect "", "=A,~{dirflag},~{fpsr},~{flags}"() +// X86-NEXT: %2 = zext i64 %1 to i128 +// X86-NEXT: store i128 %2, i128* %0, align 16 +// X86-NEXT: %3 = load <4 x i32>, <4 x i32>* %res, align 16 +// X86-NEXT: ret <4 x i32> %3 +// +// X64-LABEL: define <4 x i32> @rep +// X64: %res = alloca <4 x i32>, align 16 +// X64-NEXT: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() +// X64-NEXT: %0 = load <4 x i32>, <4 x i32>* %res, align 16 +// X64-NEXT: ret <4 x i32> %0 + v4si res; + __asm {} + return res; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37448: Fix cast assertion on MS inline assembly with vector spills (PR34021)
This revision was automatically updated to reflect the committed changes. Closed by commit rL313019: [MS-InlineAsm] Fix cast assertion with vector spills (PR34021) (authored by RKSimon). Changed prior to commit: https://reviews.llvm.org/D37448?vs=114569&id=114794#toc Repository: rL LLVM https://reviews.llvm.org/D37448 Files: cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/test/CodeGen/pr34021.c Index: cfe/trunk/lib/CodeGen/CGStmt.cpp === --- cfe/trunk/lib/CodeGen/CGStmt.cpp +++ cfe/trunk/lib/CodeGen/CGStmt.cpp @@ -2194,7 +2194,7 @@ llvm::IntegerType::get(getLLVMContext(), (unsigned)TmpSize)); Tmp = Builder.CreateTrunc(Tmp, TruncTy); } else if (TruncTy->isIntegerTy()) { -Tmp = Builder.CreateTrunc(Tmp, TruncTy); +Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy); } else if (TruncTy->isVectorTy()) { Tmp = Builder.CreateBitCast(Tmp, TruncTy); } Index: cfe/trunk/test/CodeGen/pr34021.c === --- cfe/trunk/test/CodeGen/pr34021.c +++ cfe/trunk/test/CodeGen/pr34021.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X64 + +typedef int v4si __attribute__ ((vector_size (16))); +v4si rep() { +// X86-LABEL: define <4 x i32> @rep +// X86: %retval = alloca <4 x i32>, align 16 +// X86-NEXT: %res = alloca <4 x i32>, align 16 +// X86-NEXT: %0 = bitcast <4 x i32>* %retval to i128* +// X86-NEXT: %1 = call i64 asm sideeffect inteldialect "", "=A,~{dirflag},~{fpsr},~{flags}"() +// X86-NEXT: %2 = zext i64 %1 to i128 +// X86-NEXT: store i128 %2, i128* %0, align 16 +// X86-NEXT: %3 = load <4 x i32>, <4 x i32>* %res, align 16 +// X86-NEXT: ret <4 x i32> %3 +// +// X64-LABEL: define <4 x i32> @rep +// X64: %res = alloca <4 x i32>, align 16 +// X64-NEXT: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() +// X64-NEXT: %0 = load <4 x i32>, <4 x i32>* %res, align 16 +// X64-NEXT: ret <4 x i32> %0 + v4si res; + __asm {} + return res; +} Index: cfe/trunk/lib/CodeGen/CGStmt.cpp === --- cfe/trunk/lib/CodeGen/CGStmt.cpp +++ cfe/trunk/lib/CodeGen/CGStmt.cpp @@ -2194,7 +2194,7 @@ llvm::IntegerType::get(getLLVMContext(), (unsigned)TmpSize)); Tmp = Builder.CreateTrunc(Tmp, TruncTy); } else if (TruncTy->isIntegerTy()) { -Tmp = Builder.CreateTrunc(Tmp, TruncTy); +Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy); } else if (TruncTy->isVectorTy()) { Tmp = Builder.CreateBitCast(Tmp, TruncTy); } Index: cfe/trunk/test/CodeGen/pr34021.c === --- cfe/trunk/test/CodeGen/pr34021.c +++ cfe/trunk/test/CodeGen/pr34021.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X64 + +typedef int v4si __attribute__ ((vector_size (16))); +v4si rep() { +// X86-LABEL: define <4 x i32> @rep +// X86: %retval = alloca <4 x i32>, align 16 +// X86-NEXT: %res = alloca <4 x i32>, align 16 +// X86-NEXT: %0 = bitcast <4 x i32>* %retval to i128* +// X86-NEXT: %1 = call i64 asm sideeffect inteldialect "", "=A,~{dirflag},~{fpsr},~{flags}"() +// X86-NEXT: %2 = zext i64 %1 to i128 +// X86-NEXT: store i128 %2, i128* %0, align 16 +// X86-NEXT: %3 = load <4 x i32>, <4 x i32>* %res, align 16 +// X86-NEXT: ret <4 x i32> %3 +// +// X64-LABEL: define <4 x i32> @rep +// X64: %res = alloca <4 x i32>, align 16 +// X64-NEXT: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() +// X64-NEXT: %0 = load <4 x i32>, <4 x i32>* %res, align 16 +// X64-NEXT: ret <4 x i32> %0 + v4si res; + __asm {} + return res; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
mstorsjo added a comment. In https://reviews.llvm.org/D37727#867753, @martell wrote: > In https://reviews.llvm.org/D37727#867627, @mstorsjo wrote: > > > I'm not sure I like this direction. In my setups, a build-time default > > isn't right since I'm using the same clang builds for both native-on-linux > > building (with the default `ld` as linker) and cross-building targeting > > windows (using `ldd`), and keeping the code that reads `-fuse-ld=` is > > essential. > > > The `GetLinkerPath` function in `lib/Driver/ToolChain.cpp` that I replaced > this with already checks `-fuse-ld` and does everything we need correctly. Yup, figured it out later after reading it more thorhoughly later. >> I haven't followed the changes closely on how this works with the build-time >> `CLANG_DEFAULT_LINKER`, but can't we just make the current code check this >> define if `-fuse-ld` isn't set? > > If you specifically want a toolchain that uses lld by default for MINGW but > ld for the platform and or host you should override the `getDefaultLinker` > function in the Mingw driver with an out of tree patch. > This is now what I do in my own builds since applying this patch. I do the same by adding `-rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments` in the frontend script wrapper (a wrapper named `-w64-mingw32-clang` that just calls `clang -target -w64-mingw32 -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments`. Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
martell updated this revision to Diff 114801. martell added a comment. update tests Repository: rL LLVM https://reviews.llvm.org/D37727 Files: lib/Driver/ToolChains/MinGW.cpp test/Driver/mingw-useld.c Index: test/Driver/mingw-useld.c === --- test/Driver/mingw-useld.c +++ test/Driver/mingw-useld.c @@ -1,19 +1,19 @@ -// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s -// CHECK_LD_32: ld{{(.exe)?}}" +// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=platform 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s +// CHECK_LD_32: "{{[^"]*}}ld{{(.exe)?}}" // CHECK_LD_32: "i386pe" -// CHECK_LD_32-NOT: "-flavor" "gnu" +// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}" // RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s // CHECK_LLD_32-NOT: invalid linker name in argument -// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_32: "i386pe" // RUN: %clang -### -target x86_64-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s // CHECK_LLD_64-NOT: invalid linker name in argument -// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_64: "i386pep" // RUN: %clang -### -target arm-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s // CHECK_LLD_ARM-NOT: invalid linker name in argument -// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_ARM: "thumb2pe" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -104,14 +104,6 @@ // handled somewhere else. Args.ClaimAllArgs(options::OPT_w); - StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld"); - if (LinkerName.equals_lower("lld")) { -CmdArgs.push_back("-flavor"); -CmdArgs.push_back("gnu"); - } else if (!LinkerName.equals_lower("ld")) { -D.Diag(diag::err_drv_unsupported_linker) << LinkerName; - } - if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); @@ -241,7 +233,7 @@ if (Args.hasArg(options::OPT_static)) CmdArgs.push_back("--end-group"); - else if (!LinkerName.equals_lower("lld")) + else AddLibGCC(Args, CmdArgs); } @@ -252,7 +244,7 @@ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o"))); } } - const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data())); + const char *Exec = Args.MakeArgString(TC.GetLinkerPath()); C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } Index: test/Driver/mingw-useld.c === --- test/Driver/mingw-useld.c +++ test/Driver/mingw-useld.c @@ -1,19 +1,19 @@ -// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s -// CHECK_LD_32: ld{{(.exe)?}}" +// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=platform 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s +// CHECK_LD_32: "{{[^"]*}}ld{{(.exe)?}}" // CHECK_LD_32: "i386pe" -// CHECK_LD_32-NOT: "-flavor" "gnu" +// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}" // RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s // CHECK_LLD_32-NOT: invalid linker name in argument -// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_32: "i386pe" // RUN: %clang -### -target x86_64-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s // CHECK_LLD_64-NOT: invalid linker name in argument -// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_64: "i386pep" // RUN: %clang -### -target arm-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s // CHECK_LLD_ARM-NOT: invalid linker name in argument -// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_ARM: "thumb2pe" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -1
r313024 - Limit test to x86 targets
Author: rksimon Date: Tue Sep 12 05:16:35 2017 New Revision: 313024 URL: http://llvm.org/viewvc/llvm-project?rev=313024&view=rev Log: Limit test to x86 targets Modified: cfe/trunk/test/CodeGen/pr34021.c Modified: cfe/trunk/test/CodeGen/pr34021.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr34021.c?rev=313024&r1=313023&r2=313024&view=diff == --- cfe/trunk/test/CodeGen/pr34021.c (original) +++ cfe/trunk/test/CodeGen/pr34021.c Tue Sep 12 05:16:35 2017 @@ -1,3 +1,4 @@ +// REQUIRES: x86-registered-target // RUN: %clang_cc1 -fms-extensions %s -triple=i686-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X86 // RUN: %clang_cc1 -fms-extensions %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s --check-prefix=X64 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
mstorsjo added a comment. Looks good to me (but maybe someone else should approve it as well) Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37727: Driver: Remove custom MinGW linker detection
martell added a comment. In https://reviews.llvm.org/D37727#867751, @mstorsjo wrote: > I do the same by adding -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld > -Qunused-arguments in the frontend script wrapper (a wrapper named > -w64-mingw32-clang that just calls clang -target -w64-mingw32 > -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments. I used to do this also but I didn't want to just disable warnings for unused arguments which left me with problems. The following should work for that if you are happy with it being the default for your linux target also -DCLANG_DEFAULT_RTLIB=compiler-rt -DCLANG_DEFAULT_CXX_STDLIB=libc++ -CLANG_DEFAULT_LINKER=lld Though adding something like this to `Driver/MinGW.h` RuntimeLibType GetDefaultRuntimeLibType() const override { return RuntimeLibType::RLT_CompilerRT; } CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override { return ToolChain::CST_Libcxx; } const char *getDefaultLinker() const override { return "lld"; } should work for what you want more. > Yup, figured it out later after reading it more thorhoughly later. We posted at roughly the same time so I missed it :) > Actually, after testing this a bit more and looking at it, I withdraw my > earlier complaints - this does indeed seem to work fine with my test setup. > The generic `TC.GetLinkerPath()` picks up `-fuse-ld=lld` correctly and > converts it into `ld.lld` which should be equivalent to `lld -flavor gnu`, at > least in my linux cross compilation setup. And the extra `AddLibGCC()` call > doesn't seem harmful for the lld setup. Great, I'll just wait for reid or peter to approve and merge then. Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
This revision was automatically updated to reflect the committed changes. Closed by commit rL313025: [refactor] add a refactoring action rule that returns symbol occurrences (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D36574?vs=114309&id=114806#toc Repository: rL LLVM https://reviews.llvm.org/D36574 Files: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Index: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h === --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Tooling/Refactoring/AtomicChange.h" +#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h" #include "llvm/Support/Error.h" namespace clang { @@ -34,6 +35,10 @@ defaultResultHandler(); } + /// Handles the symbol occurrences that are found by an interactive + /// refactoring action. + virtual void handle(SymbolOccurrences Occurrences) { defaultResultHandler(); } + private: void defaultResultHandler() { handleError(llvm::make_error( Index: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp === --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp @@ -11,6 +11,7 @@ #include "RewriterTestContext.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/RefactoringActionRules.h" +#include "clang/Tooling/Refactoring/Rename/SymbolName.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "gtest/gtest.h" @@ -175,4 +176,49 @@ EXPECT_EQ(Message, "bad selection"); } +Optional findOccurrences(RefactoringActionRule &Rule, +RefactoringRuleContext &Context) { + class Consumer final : public RefactoringResultConsumer { +void handleError(llvm::Error) override {} +void handle(SymbolOccurrences Occurrences) override { + Result = std::move(Occurrences); +} + + public: +Optional Result; + }; + + Consumer C; + Rule.invoke(C, Context); + return std::move(C.Result); +} + +TEST_F(RefactoringActionRulesTest, ReturnSymbolOccurrences) { + auto Rule = createRefactoringRule( + [](selection::SourceSelectionRange Selection) + -> Expected { +SymbolOccurrences Occurrences; +Occurrences.push_back(SymbolOccurrence( +SymbolName("test"), SymbolOccurrence::MatchingSymbol, +Selection.getRange().getBegin())); +return Occurrences; + }, + requiredSelection( + selection::identity())); + + RefactoringRuleContext RefContext(Context.Sources); + SourceLocation Cursor = + Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); + RefContext.setSelectionRange({Cursor, Cursor}); + Optional Result = findOccurrences(*Rule, RefContext); + + ASSERT_FALSE(!Result); + SymbolOccurrences Occurrences = std::move(*Result); + EXPECT_EQ(Occurrences.size(), 1u); + EXPECT_EQ(Occurrences[0].getKind(), SymbolOccurrence::MatchingSymbol); + EXPECT_EQ(Occurrences[0].getNameRanges().size(), 1u); + EXPECT_EQ(Occurrences[0].getNameRanges()[0], +SourceRange(Cursor, Cursor.getLocWithOffset(strlen("test"; +} + } // end anonymous namespace Index: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h === --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Tooling/Refactoring/AtomicChange.h" +#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h" #include "llvm/Support/Error.h" namespace clang { @@ -34,6 +35,10 @@ defaultResultHandler(); } + /// Handles the symbol occurrences that are found by an interactive + /// refactoring action. + virtual void handle(SymbolOccurrences Occurrences) { defaultResultHandler(); } + private: void defaultResultHandler() { handleError(llvm::make_error( Index: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp === --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp @@ -11,6 +11,7 @@ #include "RewriterTestContext.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/RefactoringActionRules.h" +#include "clang/Tooling/Refactoring/Rename/SymbolName.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "gtest/gtest.h" @@
r313025 - [refactor] add a refactoring action rule that returns symbol occurrences
Author: arphaman Date: Tue Sep 12 05:48:37 2017 New Revision: 313025 URL: http://llvm.org/viewvc/llvm-project?rev=313025&view=rev Log: [refactor] add a refactoring action rule that returns symbol occurrences Differential Revision: https://reviews.llvm.org/D36574 Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h?rev=313025&r1=313024&r2=313025&view=diff == --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h (original) +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h Tue Sep 12 05:48:37 2017 @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Tooling/Refactoring/AtomicChange.h" +#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h" #include "llvm/Support/Error.h" namespace clang { @@ -34,6 +35,10 @@ public: defaultResultHandler(); } + /// Handles the symbol occurrences that are found by an interactive + /// refactoring action. + virtual void handle(SymbolOccurrences Occurrences) { defaultResultHandler(); } + private: void defaultResultHandler() { handleError(llvm::make_error( Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=313025&r1=313024&r2=313025&view=diff == --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original) +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Tue Sep 12 05:48:37 2017 @@ -11,6 +11,7 @@ #include "RewriterTestContext.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/RefactoringActionRules.h" +#include "clang/Tooling/Refactoring/Rename/SymbolName.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "gtest/gtest.h" @@ -175,4 +176,49 @@ TEST_F(RefactoringActionRulesTest, Retur EXPECT_EQ(Message, "bad selection"); } +Optional findOccurrences(RefactoringActionRule &Rule, +RefactoringRuleContext &Context) { + class Consumer final : public RefactoringResultConsumer { +void handleError(llvm::Error) override {} +void handle(SymbolOccurrences Occurrences) override { + Result = std::move(Occurrences); +} + + public: +Optional Result; + }; + + Consumer C; + Rule.invoke(C, Context); + return std::move(C.Result); +} + +TEST_F(RefactoringActionRulesTest, ReturnSymbolOccurrences) { + auto Rule = createRefactoringRule( + [](selection::SourceSelectionRange Selection) + -> Expected { +SymbolOccurrences Occurrences; +Occurrences.push_back(SymbolOccurrence( +SymbolName("test"), SymbolOccurrence::MatchingSymbol, +Selection.getRange().getBegin())); +return Occurrences; + }, + requiredSelection( + selection::identity())); + + RefactoringRuleContext RefContext(Context.Sources); + SourceLocation Cursor = + Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); + RefContext.setSelectionRange({Cursor, Cursor}); + Optional Result = findOccurrences(*Rule, RefContext); + + ASSERT_FALSE(!Result); + SymbolOccurrences Occurrences = std::move(*Result); + EXPECT_EQ(Occurrences.size(), 1u); + EXPECT_EQ(Occurrences[0].getKind(), SymbolOccurrence::MatchingSymbol); + EXPECT_EQ(Occurrences[0].getNameRanges().size(), 1u); + EXPECT_EQ(Occurrences[0].getNameRanges()[0], +SourceRange(Cursor, Cursor.getLocWithOffset(strlen("test"; +} + } // end anonymous namespace ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
arphaman reopened this revision. arphaman added a comment. This revision is now accepted and ready to land. Oops, I've put in the wrong diff link for r313025. This patch is still not committed. Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37210: [refactor] add a refactoring action rule that returns symbol occurrences
arphaman closed this revision. arphaman added a comment. Committed in r313025 Repository: rL LLVM https://reviews.llvm.org/D37210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313027 - Fix GCC build error and warnings from r313025
Author: arphaman Date: Tue Sep 12 06:03:42 2017 New Revision: 313027 URL: http://llvm.org/viewvc/llvm-project?rev=313027&view=rev Log: Fix GCC build error and warnings from r313025 Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=313027&r1=313026&r2=313027&view=diff == --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original) +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Tue Sep 12 06:03:42 2017 @@ -42,6 +42,9 @@ createReplacements(const std::unique_ptr void handle(AtomicChanges SourceReplacements) override { Result = std::move(SourceReplacements); } +void handle(SymbolOccurrences Occurrences) override { + RefactoringResultConsumer::handle(std::move(Occurrences)); +} public: Optional> Result; @@ -183,6 +186,9 @@ Optional findOccurren void handle(SymbolOccurrences Occurrences) override { Result = std::move(Occurrences); } +void handle(AtomicChanges Changes) override { + RefactoringResultConsumer::handle(std::move(Changes)); +} public: Optional Result; @@ -201,7 +207,7 @@ TEST_F(RefactoringActionRulesTest, Retur Occurrences.push_back(SymbolOccurrence( SymbolName("test"), SymbolOccurrence::MatchingSymbol, Selection.getRange().getBegin())); -return Occurrences; +return std::move(Occurrences); }, requiredSelection( selection::identity())); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37577: [libclang] add 'clang_getCursorTLSKind'
frutiger updated this revision to Diff 114818. frutiger added a comment. Expand the acronym 'TLS' to 'thread-local storage' in documentation. https://reviews.llvm.org/D37577 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_tls_kind.py include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -189,6 +189,7 @@ clang_getCursorResultType clang_getCursorSemanticParent clang_getCursorSpelling +clang_getCursorTLSKind clang_getCursorType clang_getCursorUSR clang_getCursorVisibility Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -7412,6 +7412,22 @@ return CXLanguage_Invalid; } +CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { + const Decl *D = cxcursor::getCursorDecl(cursor); + if (const VarDecl *VD = dyn_cast(D)) { +switch (VD->getTLSKind()) { +case VarDecl::TLS_None: + return CXTLS_None; +case VarDecl::TLS_Dynamic: + return CXTLS_Dynamic; +case VarDecl::TLS_Static: + return CXTLS_Static; +} + } + + return CXTLS_None; +} + /// \brief If the given cursor is the "templated" declaration /// descibing a class or function template, return the class or /// function template. Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -2836,6 +2836,22 @@ */ CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); +/** + * \brief Describe the "thread-local storage (TLS) kind" of the declaration + * referred to by a cursor. + */ +enum CXTLSKind { + CXTLS_None = 0, + CXTLS_Dynamic, + CXTLS_Static +}; + +/** + * \brief Determine the "thread-local storage (TLS) kind" of the declaration + * referred to by a cursor. + */ +CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor); + /** * \brief Returns the translation unit that a cursor originated from. */ Index: bindings/python/tests/cindex/test_tls_kind.py === --- /dev/null +++ bindings/python/tests/cindex/test_tls_kind.py @@ -0,0 +1,37 @@ + +from clang.cindex import TLSKind +from clang.cindex import Cursor +from clang.cindex import TranslationUnit + +from .util import get_cursor +from .util import get_tu + +def test_tls_kind(): +"""Ensure that thread-local storage kinds are available on cursors.""" + +tu = get_tu(""" +int tls_none; +thread_local int tls_dynamic; +_Thread_local int tls_static; +""", lang = 'cpp') + +tls_none = get_cursor(tu.cursor, 'tls_none') +assert tls_none.tls_kind == TLSKind.NONE; + +tls_dynamic = get_cursor(tu.cursor, 'tls_dynamic') +assert tls_dynamic.tls_kind == TLSKind.DYNAMIC + +tls_static = get_cursor(tu.cursor, 'tls_static') +assert tls_static.tls_kind == TLSKind.STATIC + +# The following case tests '__declspec(thread)'. Since it is a Microsoft +# specific extension, specific flags are required for the parser to pick +# these up. +flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32'] +tu = get_tu(""" +__declspec(thread) int tls_declspec; +""", lang = 'cpp', flags=flags) + +tls_declspec = get_cursor(tu.cursor, 'tls_declspec') +assert tls_declspec.tls_kind == TLSKind.STATIC + Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -1548,6 +1548,14 @@ return self._loc +@property +def tls_kind(self): +"""Return the thread-local storage (TLS) kind of this cursor.""" +if not hasattr(self, '_tls_kind'): +self._tls_kind = conf.lib.clang_getCursorTLSKind(self) + +return TLSKind.from_id(self._tls_kind) + @property def extent(self): """ @@ -2061,6 +2069,23 @@ RefQualifierKind.LVALUE = RefQualifierKind(1) RefQualifierKind.RVALUE = RefQualifierKind(2) +class TLSKind(BaseEnumeration): +"""Describes the kind of thread-local storage (TLS) of a cursor.""" + +# The unique kind objects, indexed by id. +_kinds = [] +_name_map = None + +def from_param(self): +return self.value + +def __repr__(self): +return 'TLSKind.%s' % (self.name,) + +TLSKind.NONE = TLSKind(0) +TLSKind.DYNAMIC = TLSKind(1) +TLSKind.STATIC = TLSKind(2) + class Type(Structure): """ The type of an element in the abstract syntax tree. @@ -4066,6 +4091,7 @@ 'Index', 'SourceLocation', 'SourceRange', +'TLSKind', 'TokenKind', 'Token', 'TranslationUnitLoadError', ___ cfe-commits mailin
[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available
mibintc updated this revision to Diff 114820. mibintc added a comment. I heard that @jyknight is still interested in this functionality, updating the patch to latest sources, to do this i needed to make a small change to a couple of driver tests. Other than that it's the same as previous submission. https://reviews.llvm.org/D34158 Files: include/clang/Driver/CC1Options.td include/clang/Lex/PreprocessorOptions.h lib/Driver/Job.cpp lib/Driver/ToolChains/Linux.cpp lib/Driver/ToolChains/Linux.h lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitPreprocessor.cpp test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h test/Driver/clang_cpp.c test/Driver/crash-report-header.h test/Driver/crash-report-spaces.c test/Driver/crash-report.c test/Driver/rewrite-legacy-objc.m test/Driver/rewrite-map-in-diagnostics.c test/Driver/rewrite-objc.m test/Driver/stdc-predef.c test/Driver/stdc-predef.i test/Index/IBOutletCollection.m test/Index/annotate-macro-args.m test/Index/annotate-tokens-pp.c test/Index/annotate-tokens.c test/Index/c-index-getCursor-test.m test/Index/get-cursor-macro-args.m test/Index/get-cursor.cpp test/Preprocessor/ignore-pragmas.c unittests/Tooling/TestVisitor.h Index: lib/Driver/ToolChains/Linux.h === --- lib/Driver/ToolChains/Linux.h +++ lib/Driver/ToolChains/Linux.h @@ -31,6 +31,8 @@ void addLibStdCxxIncludePaths( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + void AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const; void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -705,6 +705,8 @@ addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); + + AddGnuIncludeArgs(DriverArgs, CC1Args); } static std::string DetectLibcxxIncludePath(StringRef base) { @@ -743,6 +745,17 @@ return ""; } +void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const { + if (!DriverArgs.hasArg(options::OPT_ffreestanding)) { +// For gcc compatibility, clang will preinclude +// -ffreestanding suppresses this behavior. +CC1Args.push_back("-fsystem-include-if-exists"); +CC1Args.push_back("stdc-predef.h"); + } +} + + void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { // We need a detected GCC installation on Linux to provide libstdc++'s Index: lib/Driver/Job.cpp === --- lib/Driver/Job.cpp +++ lib/Driver/Job.cpp @@ -63,7 +63,7 @@ .Cases("-internal-externc-isystem", "-iprefix", true) .Cases("-iwithprefixbefore", "-isystem", "-iquote", true) .Cases("-isysroot", "-I", "-F", "-resource-dir", true) -.Cases("-iframework", "-include-pch", true) +.Cases("-iframework", "-include-pch", "-fsystem-include-if-exists", true) .Default(false); if (IsInclude) return HaveCrashVFS ? false : true; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2563,6 +2563,10 @@ for (const Arg *A : Args.filtered(OPT_chain_include)) Opts.ChainedIncludes.emplace_back(A->getValue()); + // Add the ordered list of -fsystem-include-if-exists. + for (const Arg *A : Args.filtered(OPT_fsystem_include_if_exists)) +Opts.FSystemIncludeIfExists.emplace_back(A->getValue()); + for (const Arg *A : Args.filtered(OPT_remap_file)) { std::pair Split = StringRef(A->getValue()).split(';'); Index: lib/Frontend/InitPreprocessor.cpp === --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -70,6 +70,15 @@ Builder.append(Twine("#include \"") + File + "\""); } +/// AddImplicitSystemIncludeIfExists - Add an implicit system \#include of the +/// specified file to the predefines buffer: precheck with __has_include. +static void AddImplicitSystemIncludeIfExists(MacroBuilder &Builder, + StringRef File) { + Builder.append(Twine("#if __has_include( <") + File + ">)"); + Builder.append(Twine("#include <") + File + ">"); + Builder.append(Twine("#endif")); +} + static void AddImplicitIncludeMacros(MacroBui
[PATCH] D37416: Use the VFS from the CompilerInvocation by default
teemperor updated this revision to Diff 114823. teemperor added a comment. - Rebased with the correct diff... https://reviews.llvm.org/D37416 Files: include/clang/Frontend/CompilerInstance.h lib/Frontend/CompilerInstance.cpp lib/Frontend/FrontendAction.cpp unittests/Frontend/CMakeLists.txt unittests/Frontend/CompilerInstanceTest.cpp Index: unittests/Frontend/CompilerInstanceTest.cpp === --- /dev/null +++ unittests/Frontend/CompilerInstanceTest.cpp @@ -0,0 +1,74 @@ +//===- unittests/Frontend/CompilerInstanceTest.cpp - CI tests -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/CompilerInvocation.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/ToolOutputFile.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) { + // Create a temporary VFS overlay yaml file. + int FD; + SmallString<256> FileName; + ASSERT_FALSE(sys::fs::createTemporaryFile("vfs", "yaml", FD, FileName)); + tool_output_file File(FileName, FD); + + SmallString<256> CurrentPath; + sys::fs::current_path(CurrentPath); + sys::fs::make_absolute(CurrentPath, FileName); + + // Mount the VFS file itself on the path 'virtual.file'. Makes this test + // a bit shorter than creating a new dummy file just for this purpose. + const std::string CurrentPathStr = CurrentPath.str(); + const std::string FileNameStr = FileName.str(); + const char *VFSYaml = "{ 'version': 0, 'roots': [\n" +" { 'name': '%s',\n" +"'type': 'directory',\n" +"'contents': [\n" +" { 'name': 'vfs-virtual.file', 'type': 'file',\n" +"'external-contents': '%s'\n" +" }\n" +"]\n" +" }\n" +"]}\n"; + File.os() << format(VFSYaml, CurrentPathStr.c_str(), FileName.c_str()); + File.os().flush(); + + // Create a CompilerInvocation that uses this overlay file. + const std::string VFSArg = "-ivfsoverlay" + FileNameStr; + const char *Args[] = {"clang", VFSArg.c_str(), "-xc++", "-"}; + + IntrusiveRefCntPtr Diags = + CompilerInstance::createDiagnostics(new DiagnosticOptions()); + + std::shared_ptr CInvok = + createInvocationFromCommandLine(Args, Diags); + + if (!CInvok) +FAIL() << "could not create compiler invocation"; + // Create a minimal CompilerInstance which should use the VFS we specified + // in the CompilerInvocation (as we don't explicitly set our own). + CompilerInstance Instance; + Instance.setDiagnostics(Diags.get()); + Instance.setInvocation(CInvok); + Instance.createFileManager(); + + // Check if the virtual file exists which means that our VFS is used by the + // CompilerInstance. + ASSERT_TRUE(Instance.getFileManager().getFile("vfs-virtual.file")); +} + +} // anonymous namespace Index: unittests/Frontend/CMakeLists.txt === --- unittests/Frontend/CMakeLists.txt +++ unittests/Frontend/CMakeLists.txt @@ -4,6 +4,7 @@ add_clang_unittest(FrontendTests ASTUnitTest.cpp + CompilerInstanceTest.cpp FrontendActionTest.cpp CodeGenActionTest.cpp PCHPreambleTest.cpp Index: lib/Frontend/FrontendAction.cpp === --- lib/Frontend/FrontendAction.cpp +++ lib/Frontend/FrontendAction.cpp @@ -633,18 +633,12 @@ return true; } - if (!CI.hasVirtualFileSystem()) { -if (IntrusiveRefCntPtr VFS = - createVFSFromCompilerInvocation(CI.getInvocation(), - CI.getDiagnostics())) - CI.setVirtualFileSystem(VFS); -else + // Set up the file and source managers, if needed. + if (!CI.hasFileManager()) { +if (!CI.createFileManager()) { goto failure; +} } - - // Set up the file and source managers, if needed. - if (!CI.hasFileManager()) -CI.createFileManager(); if (!CI.hasSourceManager()) CI.createSourceManager(CI.getFileManager()); Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -300,12 +300,16 @@ // File Manager -void CompilerInstance::createFileManager() { +FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { -// TODO: choose the virtual file system based on the CompilerInvocation. -se
[PATCH] D37742: Add more tests for OpenCL atomic builtin functions
yaxunl created this revision. Add tests for different address spaces and insert some blank lines to make them more readable. https://reviews.llvm.org/D37742 Files: test/CodeGenOpenCL/atomic-ops-libcall.cl test/CodeGenOpenCL/atomic-ops.cl Index: test/CodeGenOpenCL/atomic-ops.cl === --- test/CodeGenOpenCL/atomic-ops.cl +++ test/CodeGenOpenCL/atomic-ops.cl @@ -34,10 +34,13 @@ // CHECK-LABEL: @fi1 // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst int x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group); + // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} syncscope("agent") seq_cst x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_device); + // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} seq_cst x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_all_svm_devices); + // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} syncscope("subgroup") seq_cst x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_sub_group); } @@ -48,16 +51,32 @@ __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group); } +void test_addr(global atomic_int *ig, private atomic_int *ip, local atomic_int *il) { + // CHECK-LABEL: @test_addr + // CHECK: store atomic i32 %{{[.0-9A-Z_a-z]+}}, i32 addrspace(1)* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst + __opencl_atomic_store(ig, 1, memory_order_seq_cst, memory_scope_work_group); + + // CHECK: store atomic i32 %{{[.0-9A-Z_a-z]+}}, i32* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst + __opencl_atomic_store(ip, 1, memory_order_seq_cst, memory_scope_work_group); + + // CHECK: store atomic i32 %{{[.0-9A-Z_a-z]+}}, i32 addrspace(3)* %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst + __opencl_atomic_store(il, 1, memory_order_seq_cst, memory_scope_work_group); +} + void fi3(atomic_int *i, atomic_uint *ui) { // CHECK-LABEL: @fi3 // CHECK: atomicrmw and i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst int x = __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group); + // CHECK: atomicrmw min i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst x = __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group); + // CHECK: atomicrmw max i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst x = __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group); + // CHECK: atomicrmw umin i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst x = __opencl_atomic_fetch_min(ui, 1, memory_order_seq_cst, memory_scope_work_group); + // CHECK: atomicrmw umax i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}}, i32 %{{[.0-9A-Z_a-z]+}} syncscope("workgroup") seq_cst x = __opencl_atomic_fetch_max(ui, 1, memory_order_seq_cst, memory_scope_work_group); } Index: test/CodeGenOpenCL/atomic-ops-libcall.cl === --- test/CodeGenOpenCL/atomic-ops-libcall.cl +++ test/CodeGenOpenCL/atomic-ops-libcall.cl @@ -18,39 +18,64 @@ #endif } memory_scope; -void f(atomic_int *i, atomic_uint *ui, int cmp, int order, int scope) { +void f(atomic_int *i, global atomic_int *gi, local atomic_int *li, private atomic_int *pi, atomic_uint *ui, int cmp, int order, int scope) { int x; // SPIR: {{%[^ ]*}} = call i32 @__opencl_atomic_load_4(i8 addrspace(4)* {{%[0-9]+}}, i32 5, i32 1) // ARM: {{%[^ ]*}} = call i32 @__opencl_atomic_load_4(i8* {{%[0-9]+}}, i32 5, i32 1) x = __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group); + // SPIR: call void @__opencl_atomic_store_4(i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) // ARM: call void @__opencl_atomic_store_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group); + + // SPIR: %[[GP:[0-9]+]] = addrspacecast i8 addrspace(1)* {{%[0-9]+}} to i8 addrspace(4)* + // SPIR: call void @__opencl_atomic_store_4(i8 addrspace(4)* %[[GP]], i32 {{%[0-9]+}}, i32 5, i32 1) + // ARM: call void @__opencl_atomic_store_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) + __opencl_atomic_store(gi, 1, memory_order_seq_cst, memory_scope_work_group); + + // SPIR: %[[GP:[0-9]+]] = addrspacecast i8 addrspace(3)* {{%[0-9]+}} to i8 addrspace(4)* + // SPIR: call void @__opencl_atomic_store_4(i8 addrspace(4)* %[[GP]], i32 {{%[0-9]+}}, i32 5, i32 1) + // ARM: call void @__opencl_atomic_store_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) + __opencl_atomic_store(li, 1, memory_order_seq_cst, memory_scope_work_group); + + // SPIR: %[[GP:[0-9]+]] = addrspacecast i8* {{%[0-9]+}} to i8 addrspace(4)* + // SPIR: call void @__open
[PATCH] D37254: [Sema] Disallow assigning record lvalues with nested const-qualified fields.
bjope added a comment. This patch looks good to me now. But I'm currently working in the same out-of-tree project as the author, so it would be nice if someone else could have a look as well and accept this. https://reviews.llvm.org/D37254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r313029 - [clangd] Add support for snippet completions
Author: ibiryukov Date: Tue Sep 12 06:57:14 2017 New Revision: 313029 URL: http://llvm.org/viewvc/llvm-project?rev=313029&view=rev Log: [clangd] Add support for snippet completions Enhances CompletionItemsCollector in such a way that snippet completions can be presented to the client. Enable snippet completion items by specifying -enable-snippets while invoking the clangd executable. See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#completion-request See: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/browser/snippet.md Patch by Raoul Wols. Added: clang-tools-extra/trunk/test/clangd/completion-snippet.test - copied, changed from r312948, clang-tools-extra/trunk/test/clangd/completion.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/ClangdUnit.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/authority-less-uri.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/protocol.test clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=313029&r1=313028&r2=313029&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Sep 12 06:57:14 2017 @@ -221,9 +221,11 @@ void ClangdLSPServer::LSPProtocolCallbac } ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount, + bool SnippetCompletions, llvm::Optional ResourceDir) : Out(Out), DiagConsumer(*this), - Server(CDB, DiagConsumer, FSProvider, AsyncThreadsCount, ResourceDir) {} + Server(CDB, DiagConsumer, FSProvider, AsyncThreadsCount, + SnippetCompletions, ResourceDir) {} void ClangdLSPServer::run(std::istream &In) { assert(!IsDone && "Run was called before"); Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=313029&r1=313028&r2=313029&view=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Sep 12 06:57:14 2017 @@ -27,6 +27,7 @@ class JSONOutput; class ClangdLSPServer { public: ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount, + bool SnippetCompletions, llvm::Optional ResourceDir); /// Run LSP server loop, receiving input for it from \p In. \p In must be Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313029&r1=313028&r2=313029&view=diff == --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Sep 12 06:57:14 2017 @@ -144,12 +144,13 @@ ClangdScheduler::~ClangdScheduler() { ClangdServer::ClangdServer(GlobalCompilationDatabase &CDB, DiagnosticsConsumer &DiagConsumer, FileSystemProvider &FSProvider, - unsigned AsyncThreadsCount, + unsigned AsyncThreadsCount, bool SnippetCompletions, llvm::Optional ResourceDir) : CDB(CDB), DiagConsumer(DiagConsumer), FSProvider(FSProvider), ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()), PCHs(std::make_shared()), - WorkScheduler(AsyncThreadsCount) {} + WorkScheduler(AsyncThreadsCount), SnippetCompletions(SnippetCompletions) { +} std::future ClangdServer::addDocument(PathRef File, StringRef Contents) { DocVersion Version = DraftMgr.updateDraft(File, Contents); @@ -206,10 +207,10 @@ ClangdServer::codeComplete(PathRef File, assert(Resources && "Calling completion on non-added file"); auto Preamble = Resources->getPossiblyStalePreamble(); - std::vector Result = - clangd::codeComplete(File, Resources->getCompileCommand(), - Preamble ? &Preamble->Preamble : nullptr, - *OverridenCon
[PATCH] D37101: [clangd] Add support for snippet completions
ilya-biryukov added a comment. Done. It's now in. Thanks for the contribution! Had to make a few changes before committing. - Fix compilation of tests. - Update VSCode "engine" dependency in vscode toy client. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36150: [clangd] LSP extension to switch between source/header file
ilya-biryukov requested changes to this revision. ilya-biryukov added a comment. This revision now requires changes to proceed. Overall looks good, but still needs at least a few tests. https://reviews.llvm.org/D36150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
aaron.ballman added a comment. In https://reviews.llvm.org/D37436#867287, @rsmith wrote: > If this is just supposed to be an experiment to get feedback on the feature, > then I don't think we should be treating it as a different attribute syntax > at all. Rather, I think we > just want to permit C++11 attributes to be parsed in other language modes. > If/when this becomes part of some future C working draft, I think that's the > time to have a > separate attribute syntax with a distinct set of valid unqualified attribute > names. I do not think that's the correct approach. These are not C++ attributes (for instance, no `using` insanity is allowed, `::` is a new lexing token in C, etc). Also, I don't think it's a good idea to enable all C++11-style attributes in C mode without giving each attribute some appropriate thought (what does `abi_tag` *do* in C mode? What happens with _Noreturn vs [[noreturn]] etc). Also, I'm not comfortable adding a bunch of vendor-specific `gnu::` attributes that GCC does not implement in C yet. The goal of this is to get a working implementation of the attribute syntax that WG14 has shown strong support for including in C2x (F: 16, N: 3, A: 1) with this syntax (F: 12, N: 3, A: 4). The experimental part where I need feedback is whether the paper needs to change because of implementation experience. So far, that's not been required. The more we drift from what's proposed in N2137, the less useful the implementation experience will be (esp if we basically turn this into a simple "enable C++ attributes everywhere" flag). I can understand not adding a C2x language mode due to the lack of a working draft, but that lack should not be what drives internal implementation details for the feature -- I think the separation of concerns in this patch is valuable. Comment at: include/clang/Basic/LangOptions.def:140 +LANGOPT(CAttributes , 1, 0, "'[[]]' attributes extension to C") + rsmith wrote: > Can we give this a more general name, then enable it under `CPlusPlus` too? > That's what we do for other similar features. I'm not keen on naming it 'Attributes', but the other names are worse (`GeneralAttributes`, `StandardAttributes`). Do you have a suggestion? Comment at: include/clang/Driver/Options.td:607 +def fc_attributes : Flag<["-"], "fc-attributes">, Group, + Flags<[DriverOption, CC1Option]>, HelpText<"Enable '[[]]' attributes in C">; rsmith wrote: > Hmm. On reflection, if we're going to have a flag to enable C++11 attributes > in other language modes, it should probably work in C++98 mode too, so > calling this `-fc-attributes` is probably not the best idea. > `-fc++11-attributes` might make sense, though. I can't think of a reason why you'd want to control C and C++ attributes separately, so I think it makes sense to add a more general name for this. I'm definitely not keen on that flag name. I wouldn't be opposed to `-fattributes`, but that may lead to confusion about other vendor-specific attributes (which we could always decide to use flags like `-fdeclspec-attributes` etc). What should happen if a user compiles with `-std=c++11 -fno--attributes`? Do we want to support such a construct? Comment at: lib/Parse/ParseDecl.cpp:4219 + +// Attributes are prohibited in this location in C2x (and forward +// declarations are prohibited in C++). rsmith wrote: > I don't think we can reasonably say what C2x will do. Also, doesn't this > reject valid code such as: > ``` > struct __attribute__((deprecated)) Foo; > ``` > ? Sorry for the lack of context in the patch (TortoiseSVN doesn't make this easy). This has to do with enum specifiers, not struct or unions -- it will reject `enum __attribute__((deprecated)) Foo;` as not allowing an attribute list *and* as being a forward reference in C++ mode, but accepts in C mode. Comment at: lib/Parse/ParseDeclCXX.cpp:3939-3940 SourceLocation *endLoc) { - if (Tok.is(tok::kw_alignas)) { + bool CXXAttr = getLangOpts().CPlusPlus11; + if (CXXAttr && Tok.is(tok::kw_alignas)) { Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas); rsmith wrote: > This change is unnecessary. `kw_alignas` is not produced by the lexer in > modes where we should not parse it. Ah, good to know. I'll remove. Comment at: lib/Parse/ParseDeclCXX.cpp:3956 IdentifierInfo *CommonScopeName = nullptr; - if (Tok.is(tok::kw_using)) { + if (CXXAttr && Tok.is(tok::kw_using)) { Diag(Tok.getLocation(), getLangOpts().CPlusPlus1z rsmith wrote: > Likewise. I'll add a test for this to ensure we don't accidentally allow it in C mode. https://reviews.llvm.org/D37436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailma
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
aaron.ballman updated this revision to Diff 114827. aaron.ballman marked 3 inline comments as done. aaron.ballman added a comment. Updates based on review feedback. https://reviews.llvm.org/D37436 Files: include/clang/Basic/Attr.td include/clang/Basic/Attributes.h include/clang/Basic/LangOptions.def include/clang/Driver/Options.td include/clang/Parse/Parser.h include/clang/Sema/AttributeList.h lib/Frontend/CompilerInvocation.cpp lib/Lex/Lexer.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseTentative.cpp lib/Sema/AttributeList.cpp test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp test/Misc/ast-dump-c-attr.c test/Parser/c2x-attributes.c test/Parser/cxx0x-attributes.cpp test/Sema/attr-deprecated-c2x.c utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -58,7 +58,7 @@ assert(V != "GCC" && "Given a GCC spelling, which means this hasn't been" "flattened!"); -if (V == "CXX11" || V == "Pragma") +if (V == "CXX11" || V == "C2x" || V == "Pragma") NS = Spelling.getValueAsString("Namespace"); bool Unset; K = Spelling.getValueAsBitOrUnset("KnownToGCC", Unset); @@ -1326,7 +1326,7 @@ if (Variety == "GNU") { Prefix = " __attribute__(("; Suffix = "))"; -} else if (Variety == "CXX11") { +} else if (Variety == "CXX11" || Variety == "C2x") { Prefix = " [["; Suffix = "]]"; std::string Namespace = Spellings[I].nameSpace(); @@ -2716,10 +2716,14 @@ // If this is the C++11 variety, also add in the LangOpts test. if (Variety == "CXX11") Test += " && LangOpts.CPlusPlus11"; + else if (Variety == "C2x") +Test += " && LangOpts.CAttributes"; } else if (Variety == "CXX11") // C++11 mode should be checked against LangOpts, which is presumed to be // present in the caller. Test = "LangOpts.CPlusPlus11"; +else if (Variety == "C2x") + Test = "LangOpts.CAttributes"; std::string TestStr = !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : "1"; @@ -2740,7 +2744,7 @@ // and declspecs. Then generate a big switch statement for each of them. std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); std::vector Declspec, Microsoft, GNU, Pragma; - std::map> CXX; + std::map> CXX, C2x; // Walk over the list of all attributes, and split them out based on the // spelling variety. @@ -2756,6 +2760,8 @@ Microsoft.push_back(R); else if (Variety == "CXX11") CXX[SI.nameSpace()].push_back(R); + else if (Variety == "C2x") +C2x[SI.nameSpace()].push_back(R); else if (Variety == "Pragma") Pragma.push_back(R); } @@ -2775,20 +2781,25 @@ OS << "case AttrSyntax::Pragma:\n"; OS << " return llvm::StringSwitch(Name)\n"; GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma"); - OS << "case AttrSyntax::CXX: {\n"; - // C++11-style attributes are further split out based on the Scope. - for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) { -if (I != CXX.begin()) - OS << " else "; -if (I->first.empty()) - OS << "if (!Scope || Scope->getName() == \"\") {\n"; -else - OS << "if (Scope->getName() == \"" << I->first << "\") {\n"; -OS << " return llvm::StringSwitch(Name)\n"; -GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first); -OS << "}"; - } - OS << "\n}\n"; + auto fn = [&OS](const char *Spelling, const char *Variety, + const std::map> &List) { +OS << "case AttrSyntax::" << Variety << ": {\n"; +// C++11-style attributes are further split out based on the Scope. +for (auto I = List.cbegin(), E = List.cend(); I != E; ++I) { + if (I != List.cbegin()) +OS << " else "; + if (I->first.empty()) +OS << "if (!Scope || Scope->getName() == \"\") {\n"; + else +OS << "if (Scope->getName() == \"" << I->first << "\") {\n"; + OS << " return llvm::StringSwitch(Name)\n"; + GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first); + OS << "}"; +} +OS << "\n}\n"; + }; + fn("CXX11", "CXX", CXX); + fn("C2x", "C", C2x); OS << "}\n"; } @@ -2809,10 +2820,11 @@ << StringSwitch(Spellings[I].variety()) .Case("GNU", 0) .Case("CXX11", 1) -.Case("Declspec", 2) -.Case("Microsoft", 3) -.Case("Keyword", 4) -.Case("Pragma", 5) +.Case("C2x", 2) +.Case("Declspec", 3) +.Case("Microsoft", 4) +.Case("Keyword", 5) +.Case("Pragma", 6) .Default(0) << " && Scope == \"" << Spellings[I].nameSpace() << "\")\n" << "
[PATCH] D37101: [clangd] Add support for snippet completions
ilya-biryukov closed this revision. ilya-biryukov added a comment. Marking as closed, had to commit by hand without `arc patch` as it couldn't find base revision to apply the patch on. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR
jina.nahias updated this revision to Diff 114836. https://reviews.llvm.org/D37668 Files: include/clang/Basic/BuiltinsX86.def include/clang/Basic/BuiltinsX86_64.def lib/Headers/avx512bwintrin.h lib/Headers/avx512fintrin.h lib/Headers/avx512vlbwintrin.h lib/Headers/avx512vlintrin.h test/CodeGen/avx512bw-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c test/CodeGen/avx512vlbw-builtins.c Index: test/CodeGen/avx512vlbw-builtins.c === --- test/CodeGen/avx512vlbw-builtins.c +++ test/CodeGen/avx512vlbw-builtins.c @@ -2602,28 +2602,195 @@ // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}} return _mm256_maskz_broadcastw_epi16(__M, __A); } +__m128i test_mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A){ + // CHECK-LABEL: @test_mm_mask_set1_epi8 + // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15 + // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}} + return _mm_mask_set1_epi8(__O, __M, __A); +} +__m128i test_mm_maskz_set1_epi8 ( __mmask16 __M, char __A){ + // CHECK-LABEL: @test_mm_maskz_set1_epi8 + // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14 + // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15 + // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}} + return _mm_maskz_set1_epi8( __M, __A); +} + +__m256i test_mm256_mask_set1_epi8(__m256i __O, __mmask32 __M, char __A) { + // CHECK-LABEL: @test_mm256_mask_set1_epi8 + // CHECK: insertelement <32 x i8> undef, i8 %{{.*}}, i32 0 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 1 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 2 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 3 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 4 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 5 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 6 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 7 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 8 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 9 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 10 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 11 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 12 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 13 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 14 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 15 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 16 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 17 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 18 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 19 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 20 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 21 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 22 + // CHECK: insertelement <32 x i8> %{{.*}}, i8 %{{.*}}, i32 23 + // CHECK: insertelemen
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov added inline comments. Comment at: clangd/GlobalCompilationDatabase.cpp:75 + if (CachedIt != CompilationDatabases.end()) +return (CachedIt->second.get()); + auto CDB = tooling::CompilationDatabase::loadFromDirectory(File, Error); Parentheses seem redundant. Comment at: clangd/GlobalCompilationDatabase.cpp:78 + if (CDB && Error.empty()) { +auto result = CDB.get(); +CompilationDatabases.insert(std::make_pair(File, std::move(CDB))); Code style: local variable are `UpperCamelCase` Comment at: clangd/GlobalCompilationDatabase.cpp:96 + if (!CompileCommandsDir.empty()) { +auto CDB = tryLoadDatabaseFromPath(CompileCommandsDir); +return CDB; Even better: `return tryLoadDatabaseFromPath(CompileCommandsDir); ` Comment at: clangd/GlobalCompilationDatabase.h:50 + llvm::Optional NewCompileCommandsDir) + : CompileCommandsDir(NewCompileCommandsDir.getValue()) {} std::vector `getValue()` will fail if NewCompileCommandsDir does not have a value. The original suggestion was to change type of the field 'CompileCommandsDir` to `llvm::Optional` and check if `Optional` has a value instead of checking for empty string. Comment at: clangd/GlobalCompilationDatabase.h:58 tooling::CompilationDatabase *getCompilationDatabase(PathRef File); + Path CompileCommandsDir; + tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File); Could you please move this to other fields? Mixing functions and fields is a bit confusing. Comment at: clangd/tool/ClangdMain.cpp:52 + if (!llvm::sys::fs::exists(CompileCommandsDir)) { +Out.log("Path specified by --compile-commands-dir. The argument will be " +"ignored.\n"); Message does not mention that path does not exist. Probably incidental. Comment at: clangd/tool/ClangdMain.cpp:59 // Change stdin to binary to not lose \r\n on windows. llvm::sys::ChangeStdinToBinary(); + if (CompileCommandsDir.empty()) Could you please move this out of the logic that validates `CompileCommandsDir` parameter? It's very easy to miss while reading the code. Probably ok to put it right after `JSONOutput Out(...` line https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r313031 - Make pbump (internally) handle sizes bigger than MAX_INT. Fixes PR#33725 - thanks to Jonathan Wakely for the report
Author: marshall Date: Tue Sep 12 08:00:43 2017 New Revision: 313031 URL: http://llvm.org/viewvc/llvm-project?rev=313031&view=rev Log: Make pbump (internally) handle sizes bigger than MAX_INT. Fixes PR#33725 - thanks to Jonathan Wakely for the report Added: libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp Modified: libcxx/trunk/include/fstream libcxx/trunk/include/locale libcxx/trunk/include/sstream libcxx/trunk/include/streambuf libcxx/trunk/src/strstream.cpp Modified: libcxx/trunk/include/fstream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=313031&r1=313030&r2=313031&view=diff == --- libcxx/trunk/include/fstream (original) +++ libcxx/trunk/include/fstream Tue Sep 12 08:00:43 2017 @@ -315,7 +315,7 @@ basic_filebuf<_CharT, _Traits>::basic_fi else this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase())); -this->pbump(__rhs. pptr() - __rhs.pbase()); +this->__pbump(__rhs. pptr() - __rhs.pbase()); } else if (__rhs.eback()) { @@ -434,7 +434,7 @@ basic_filebuf<_CharT, _Traits>::swap(bas ptrdiff_t __e = this->epptr() - this->pbase(); this->setp((char_type*)__extbuf_min_, (char_type*)__extbuf_min_ + __e); -this->pbump(__n); +this->__pbump(__n); } if (__rhs.eback() == (char_type*)__extbuf_min_) { @@ -450,7 +450,7 @@ basic_filebuf<_CharT, _Traits>::swap(bas ptrdiff_t __e = __rhs.epptr() - __rhs.pbase(); __rhs.setp((char_type*)__rhs.__extbuf_min_, (char_type*)__rhs.__extbuf_min_ + __e); -__rhs.pbump(__n); +__rhs.__pbump(__n); } } @@ -724,7 +724,7 @@ basic_filebuf<_CharT, _Traits>::overflow if (__r == codecvt_base::partial) { this->setp(const_cast(__e), this->pptr()); -this->pbump(this->epptr() - this->pbase()); +this->__pbump(this->epptr() - this->pbase()); } } else Modified: libcxx/trunk/include/locale URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=313031&r1=313030&r2=313031&view=diff == --- libcxx/trunk/include/locale (original) +++ libcxx/trunk/include/locale Tue Sep 12 08:00:43 2017 @@ -4110,7 +4110,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::o if (__r == codecvt_base::partial) { this->setp(const_cast(__e), this->pptr()); -this->pbump(this->epptr() - this->pbase()); +this->__pbump(this->epptr() - this->pbase()); } } else Modified: libcxx/trunk/include/sstream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/sstream?rev=313031&r1=313030&r2=313031&view=diff == --- libcxx/trunk/include/sstream (original) +++ libcxx/trunk/include/sstream Tue Sep 12 08:00:43 2017 @@ -289,7 +289,7 @@ basic_stringbuf<_CharT, _Traits, _Alloca if (__bout != -1) { this->setp(__p + __bout, __p + __eout); -this->pbump(__nout); +this->__pbump(__nout); } __hm_ = __hm == -1 ? nullptr : __p + __hm; __p = const_cast(__rhs.__str_.data()); @@ -332,7 +332,7 @@ basic_stringbuf<_CharT, _Traits, _Alloca if (__bout != -1) { this->setp(__p + __bout, __p + __eout); -this->pbump(__nout); +this->__pbump(__nout); } else this->setp(nullptr, nullptr); @@ -403,7 +403,7 @@ basic_stringbuf<_CharT, _Traits, _Alloca if (__rbout != -1) { this->setp(__p + __rbout, __p + __reout); -this->pbump(__rnout); +this->__pbump(__rnout); } else this->setp(nullptr, nullptr); @@ -416,7 +416,7 @@ basic_stringbuf<_CharT, _Traits, _Alloca if (__lbout != -1) { __rhs.setp(__p + __lbout, __p + __leout); -__rhs.pbump(__lnout); +__rhs.__pbump(__lnout); } else __rhs.setp(nullptr, nullptr); @@ -471,7 +471,15 @@ basic_stringbuf<_CharT, _Traits, _Alloca this->setp(const_cast(__str_.data()), const_cast(__str_.data()) + __str_.size()); if (__mode_ & (ios_base::app | ios_base::ate)) -this->pbump(__sz); +{ +while (__sz > INT_MAX) +{ + this->pbump(INT_MAX); + __sz -= INT_MAX; +} +if (__sz > 0) + this->pbump(__sz); + } } } @@ -536,7 +544,7 @@ basic_stringbuf<_CharT,
r313034 - Fix PR34021 test on non-x86 build targets
Author: rksimon Date: Tue Sep 12 08:04:04 2017 New Revision: 313034 URL: http://llvm.org/viewvc/llvm-project?rev=313034&view=rev Log: Fix PR34021 test on non-x86 build targets Modified: cfe/trunk/test/CodeGen/pr34021.c Modified: cfe/trunk/test/CodeGen/pr34021.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr34021.c?rev=313034&r1=313033&r2=313034&view=diff == --- cfe/trunk/test/CodeGen/pr34021.c (original) +++ cfe/trunk/test/CodeGen/pr34021.c Tue Sep 12 08:04:04 2017 @@ -5,20 +5,20 @@ typedef int v4si __attribute__ ((vector_size (16))); v4si rep() { // X86-LABEL: define <4 x i32> @rep -// X86: %retval = alloca <4 x i32>, align 16 -// X86-NEXT: %res = alloca <4 x i32>, align 16 -// X86-NEXT: %0 = bitcast <4 x i32>* %retval to i128* -// X86-NEXT: %1 = call i64 asm sideeffect inteldialect "", "=A,~{dirflag},~{fpsr},~{flags}"() -// X86-NEXT: %2 = zext i64 %1 to i128 -// X86-NEXT: store i128 %2, i128* %0, align 16 -// X86-NEXT: %3 = load <4 x i32>, <4 x i32>* %res, align 16 -// X86-NEXT: ret <4 x i32> %3 +// X86: %[[ALLOCA0:.*]] = alloca <4 x i32>, align 16 +// X86: %[[ALLOCA1:.*]] = alloca <4 x i32>, align 16 +// X86: %[[BITCAST:.*]] = bitcast <4 x i32>* %[[ALLOCA0]] to i128* +// X86: %[[ASM:.*]] = call i64 asm sideeffect inteldialect "", "=A,~{dirflag},~{fpsr},~{flags}"() +// X86: %[[ZEXT:.*]] = zext i64 %[[ASM]] to i128 +// X86: store i128 %[[ZEXT]], i128* %[[BITCAST]], align 16 +// X86: %[[LOAD:.*]] = load <4 x i32>, <4 x i32>* %[[ALLOCA1]], align 16 +// X86: ret <4 x i32> %[[LOAD]] // // X64-LABEL: define <4 x i32> @rep -// X64: %res = alloca <4 x i32>, align 16 -// X64-NEXT: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() -// X64-NEXT: %0 = load <4 x i32>, <4 x i32>* %res, align 16 -// X64-NEXT: ret <4 x i32> %0 +// X64: %[[ALLOCA:.*]] = alloca <4 x i32>, align 16 +// X64: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() +// X64: %[[LOAD:.*]] = load <4 x i32>, <4 x i32>* %[[ALLOCA]], align 16 +// X64: ret <4 x i32> %[[LOAD]] v4si res; __asm {} return res; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37577: [libclang] add 'clang_getCursorTLSKind'
compnerd added a comment. Do you have commit rights or would you like me to commit this on your behalf? https://reviews.llvm.org/D37577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37577: [libclang] add 'clang_getCursorTLSKind'
frutiger added a comment. I do not have commit rights - please commit this yourself, thanks! https://reviews.llvm.org/D37577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
aaron.ballman added inline comments. Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:141 + assert(CheckExecuted && + "Non of the subroutines executed, logic error in matcher!"); +} Non -> None Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:294 + + // Classes, that contains owners, but do not declare destructors + if (BadClass) { Missing a full stop at the end of the sentence. Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:39 + return new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a 'gsl::owner<>' from a function but not declaring it; return type is 'int *' +} JonasToth wrote: > aaron.ballman wrote: > > JonasToth wrote: > > > aaron.ballman wrote: > > > > This diagnostic confuses me -- there's no gsl::owner<> involved > > > > anywhere; am I missing something? > > > `owner<>` is not involved, but the guidelines say, that `new` must be > > > assigned to an owner. > > > > > > This is in line with the resource semantics. Everything that creates an > > > resource, that must be released (no RAII available) shall be annotated. > > > > > > The diagnostic is bad, though. > > > > > > `Returning a newly created resource from function 'functionname', without > > > declaring it as 'gsl::owner<>'; type is '...'` > > Okay, that makes more sense to me. I don't think the name of the function > > helps all that much in the diagnostic, however. What about: > > > > `"returning a newly created resource of type %0 from a function whose > > return type is not 'gsl::owner<>'"` > There is a minor issue with the diagnostic in general, since it is emitted > for values of type `gsl::owner<>` and values that are known to be an owner > like `new int(42)`. > > There is no easy way to distinguish between a recognized resource or an > annotated resource, without complicating the matchers (what i dont want, > since there is already a lot happening). > > Mixing both cases in the diagnostic would help, but go in the direction of > `recognized resource`, that was decided against earlier. > > Would the following modification be acceptable as well? > `returning a newly created resource of type %0 or value of type > 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>'` > or > `returning a newly created resource of type %0 or value of type > 'gsl::owner<>' without annotating the return type of the function as > 'gsl::owner<>'`. > > This general problem holds true for other cases, since i want to match for > `IsConsideredOwner`, which wraps cases like `new`, functions returning > `owner<>` and variables of type `owner<>`. > I want to expand this further to functions that should return `owner<>` but > can't, like `malloc`. > Splitting up the matchers instead of using `IsConsideredOwner` would be a > burden including a lot of code duplication. > Would the following modification be acceptable as well? > `returning a newly created resource of type %0 or value of type > 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>'` I would rephrase slightly to: `returning a newly created resource of type %0 or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>'` https://reviews.llvm.org/D36354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare
aaron.ballman added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8602 - if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) - << "< 0" << "false" << HasEnumType(LHS) - << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) - << ">= 0" << "true" << HasEnumType(LHS) - << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_true_comparison) - << "0 >" << "false" << HasEnumType(RHS) - << LHS->getSourceRange() << RHS->getSourceRange(); - } else if (op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_true_comparison) - << "0 <=" << "true" << HasEnumType(RHS) - << LHS->getSourceRange() << RHS->getSourceRange(); - } else -Match = false; + const std::array TautologicalComparisons = {{ + {LHS, I don't think this is an improvement over the old code. Repository: rL LLVM https://reviews.llvm.org/D37629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
aaron.ballman added a comment. In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: > > > There is an exception to the general rule (EXP36-C-EX2), stating that the > > result of `malloc` and friends is allowed to be casted to stricter > > alignments, since the pointer is known to be of correct alignment. > > > Quote for the reference: > > > EXP36-C-EX2: If a pointer is known to be correctly aligned to the target > > type, then a cast to that type is permitted. There are several cases where > > a pointer is known to be correctly aligned to the target type. The pointer > > could point to an object declared with a suitable alignment specifier. It > > could point to an object returned by aligned_alloc(), calloc(), malloc(), > > or realloc(), as per the C standard, section 7.22.3, paragraph 1 [ISO/IEC > > 9899:2011]. > > For plain `calloc(), malloc(), or realloc()`, i would guess it's related to > `max_align_t` / `std::max_align_t` / `__STDCPP_DEFAULT_NEW_ALIGNMENT__`, > which is generally just `16` bytes. It's a requirement from the C standard that malloc, calloc, and realloc return a suitably-aligned pointer for *any* type. >> Could you add a testcase for this case, i think there would currenlty be a >> false positive. >> >> And is there a general way of knowing when the pointer is of correct >> alignment, or is it necessary to keep a list of functions like `malloc` that >> are just known? >> If yes, i think it would be nice if this list is configurable (maybe like >> in cppcoreguidelines-no-malloc, where that functionality could be refactored >> out). Agreed, this should be a configurable list, but is should be pre-populated with the listed functions from the CERT standard. Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
aaron.ballman added a comment. In https://reviews.llvm.org/D33826#867155, @rjmccall wrote: > In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: > > > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: > > > > > There is an exception to the general rule (EXP36-C-EX2), stating that the > > > result of `malloc` and friends is allowed to be casted to stricter > > > alignments, since the pointer is known to be of correct alignment. > > > > > In practice, are there any malloc declarations still in use that return char* > instead of void*? I assume this does not complain when the source is void*. FWIW, I've not found any malloc declarations that return `char *` instead of `void *`, but if someone knows of one, I'd be curious to hear of it. Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34695: _Float16 preprocessor macro definitions
rogfer01 added inline comments. Comment at: lib/Headers/float.h:137 +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ My understanding is that, given that we support TS18661-2 by default, this macro should be predefined by clang and then there is no need to protect these macros. You may want to add a test for this in `test/Preprocessor/init.c`. Comment at: lib/Headers/float.h:139-142 +# define FLT16_DECIMAL_DIG __LT16_DECIMAL_DIG__ +# define FLT16_DIG __LT16_DIG__ +# define FLT16_MIN_EXP __LT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ There is a typo here, these macros should start with `__FLT16_`. Add a test for these names `test/Headers/float.c`. https://reviews.llvm.org/D34695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34695: _Float16 preprocessor macro definitions
scanon added inline comments. Comment at: lib/Headers/float.h:137 +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ rogfer01 wrote: > My understanding is that, given that we support TS18661-2 by default, this > macro should be predefined by clang and then there is no need to protect > these macros. > > You may want to add a test for this in `test/Preprocessor/init.c`. Where do you see that the `__STDC_WANT_IEC_60559_TYPES_EXT__` macro should be predefined by clang? https://reviews.llvm.org/D34695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
JonasToth updated this revision to Diff 114848. JonasToth added a comment. - address review comments, especially improve diagnostic for return types, that should be owner but arent https://reviews.llvm.org/D36354 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.h clang-tidy/utils/Matchers.h docs/ReleaseNotes.rst docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-owning-memory.cpp Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp @@ -0,0 +1,382 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t + +namespace gsl { +template +using owner = T; +} // namespace gsl + +template +class unique_ptr { +public: + unique_ptr(gsl::owner resource) : memory(resource) {} + unique_ptr(const unique_ptr &) = default; + + ~unique_ptr() { delete memory; } + +private: + gsl::owner memory; +}; + +void takes_owner(gsl::owner owned_int) { +} + +void takes_pointer(int *unowned_int) { +} + +void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) { +} + +template +void takes_templated_owner(gsl::owner owned_T) { +} + +gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok +gsl::owner returns_owner2() { return new int(42); }// Ok + +int *returns_no_owner1() { return nullptr; } +int *returns_no_owner2() { + return new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} +int *returns_no_owner3() { + int *should_be_owner = new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + return should_be_owner; +} +int *returns_no_owner4() { + gsl::owner owner = new int(42); + return owner; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} + +unique_ptr returns_no_owner5() { + return unique_ptr(new int(42)); // Ok +} + +/// FIXME: CSA finds it, but the report is misleading. Ownersemantics can catch this +/// by flow analysis similar to misc-use-after-move. +void csa_not_finding_leak() { + gsl::owner o1 = new int(42); // Ok + + gsl::owner o2 = o1; // Ok + o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guidelines + + delete o2; + // actual leak occurs here, its found, but mixed + delete o1; +} + +void test_assignment_and_initialization() { + int stack_int1 = 15; + int stack_int2; + + gsl::owner owned_int1 = &stack_int1; // BAD + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected initialization with value of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int2; + owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected assignment source to be of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int3 = new int(42); // Good + owned_int3 = nullptr; // Good + + gsl::owner owned_int4(nullptr); // Ok + owned_int4 = new int(42); // Good + + gsl::owner owned_int5 = owned_int3; // Good + + gsl::owner owned_int6{nullptr}; // Ok + owned_int6 = owned_int4; // Good + + // FIXME:, flow analysis for the case of reassignment. Value must be released before + owned_int6 = owned_int3; // BAD, because reassignment without resource release + + auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *const' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + gsl::owner owned_int9 = returns_owner1(); // Ok + int *unowned_int3 = returns_owner1();// Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + + gsl::owner owned_int10; + owned_int10 = returns_owner1(); // Ok + + int *unowned_int4; + unowned_int4 = returns_owner1(); // Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created 'gsl::owner<>' to non-owner 'int *' + + gsl::owner owned_int11 = returns_no_owner1(); // Bad since no own
[PATCH] D37308: Interface class with uuid base record
aaron.ballman added inline comments. Comment at: lib/Sema/SemaDeclCXX.cpp:2376 +/// \brief Tests if the __interface base is public. +static bool IsDeclPublicInterface(const CXXRecordDecl *RD, The comment does not match the behavior of the function. Comment at: lib/Sema/SemaDeclCXX.cpp:2382 + +/// \brief Test if record is an uuid Unknown. +/// This is an MS SDK specific type that has a special uuid Unknown -> UUID for IUnknown Comment at: lib/Sema/SemaDeclCXX.cpp:2386 +static bool IsIUnknownType(const CXXRecordDecl *RD) { + auto *Uuid = RD->getAttr(); + This can be `const auto *` Comment at: lib/Sema/SemaDeclCXX.cpp:2389 + return RD->isStruct() && RD->getName() == "IUnknown" && RD->isEmpty() && + Uuid && Uuid->getGuid() =="---C000-0046" && + dyn_cast(RD->getDeclContext()); I would move the test for `Uuid` to be one of the first things tested, since it's the least expensive. Comment at: lib/Sema/SemaDeclCXX.cpp:2390 + Uuid && Uuid->getGuid() =="---C000-0046" && + dyn_cast(RD->getDeclContext()); +} erichkeane wrote: > @aaron.ballman This logic we'd like you to particularly check on. Does this > ensure it isn't in a namespace? > > Zahira: since you don't need the value, "isa" is more > appropriate here. I would skip the casts entirely and use `RD->getDeclContext()->isTranslationUnit()` https://reviews.llvm.org/D37308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, with a few last typos. Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:354 + +// FIXME: Same typededcution problems +template typededuction -> type deduction (here and elsewhere) Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:372 + Owner1.setVal(stack_ptr1);// Bad since non-owner assignment + //Owner1.setVal(new int(42)); // Ok, but since typededuction is wrong, this one is considered harmfull + harmfull -> harmful Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:374 + + int *stack_ptr2 = Owner1.getVal(); // Bad, initializing nonowner with owner + nonowner -> non-owner (here and elsewhere) https://reviews.llvm.org/D36354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
JonasToth updated this revision to Diff 114849. JonasToth added a comment. - fix typos https://reviews.llvm.org/D36354 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.h clang-tidy/utils/Matchers.h docs/ReleaseNotes.rst docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-owning-memory.cpp Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp @@ -0,0 +1,382 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t + +namespace gsl { +template +using owner = T; +} // namespace gsl + +template +class unique_ptr { +public: + unique_ptr(gsl::owner resource) : memory(resource) {} + unique_ptr(const unique_ptr &) = default; + + ~unique_ptr() { delete memory; } + +private: + gsl::owner memory; +}; + +void takes_owner(gsl::owner owned_int) { +} + +void takes_pointer(int *unowned_int) { +} + +void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) { +} + +template +void takes_templated_owner(gsl::owner owned_T) { +} + +gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok +gsl::owner returns_owner2() { return new int(42); }// Ok + +int *returns_no_owner1() { return nullptr; } +int *returns_no_owner2() { + return new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} +int *returns_no_owner3() { + int *should_be_owner = new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + return should_be_owner; +} +int *returns_no_owner4() { + gsl::owner owner = new int(42); + return owner; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} + +unique_ptr returns_no_owner5() { + return unique_ptr(new int(42)); // Ok +} + +/// FIXME: CSA finds it, but the report is misleading. Ownersemantics can catch this +/// by flow analysis similar to misc-use-after-move. +void csa_not_finding_leak() { + gsl::owner o1 = new int(42); // Ok + + gsl::owner o2 = o1; // Ok + o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guidelines + + delete o2; + // actual leak occurs here, its found, but mixed + delete o1; +} + +void test_assignment_and_initialization() { + int stack_int1 = 15; + int stack_int2; + + gsl::owner owned_int1 = &stack_int1; // BAD + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected initialization with value of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int2; + owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected assignment source to be of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int3 = new int(42); // Good + owned_int3 = nullptr; // Good + + gsl::owner owned_int4(nullptr); // Ok + owned_int4 = new int(42); // Good + + gsl::owner owned_int5 = owned_int3; // Good + + gsl::owner owned_int6{nullptr}; // Ok + owned_int6 = owned_int4; // Good + + // FIXME:, flow analysis for the case of reassignment. Value must be released before + owned_int6 = owned_int3; // BAD, because reassignment without resource release + + auto owned_int7 = returns_owner1(); // Bad, since type deduction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + const auto owned_int8 = returns_owner2(); // Bad, since type deduction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *const' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + gsl::owner owned_int9 = returns_owner1(); // Ok + int *unowned_int3 = returns_owner1();// Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + + gsl::owner owned_int10; + owned_int10 = returns_owner1(); // Ok + + int *unowned_int4; + unowned_int4 = returns_owner1(); // Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created 'gsl::owner<>' to non-owner 'int *' + + gsl::owner owned_int11 = returns_no_owner1(); // Bad since no owner + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected initialization with value of type '
[PATCH] D34695: _Float16 preprocessor macro definitions
rogfer01 added inline comments. Comment at: lib/Headers/float.h:137 +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ scanon wrote: > rogfer01 wrote: > > My understanding is that, given that we support TS18661-2 by default, this > > macro should be predefined by clang and then there is no need to protect > > these macros. > > > > You may want to add a test for this in `test/Preprocessor/init.c`. > Where do you see that the `__STDC_WANT_IEC_60559_TYPES_EXT__` macro should be > predefined by clang? Hi Steve, certainly you're right, the TS says > The new identifiers added to C11 library headers by this part of ISO/IEC > TS-18661 are defined or declared by their respective headers only if > `__STDC_WANT_IEC_60559_TYPES_EXT__` is defined as a macro at the point in the > source file where the appropriate header is first included. so (if I read this right) these identifiers are only available if such macro is defined when including `float.h`. Can I assume from your comment that someone else should define it? Perhaps the `float.h` header itself, some other file in the C-library implementation or the user of the compiler via some `-D__STDC_WANT_IEC_60559_TYPES_EXT__`, but not be predefined by the compiler? If this is the case, then the macros still have to be guarded conditionally (as they were in the original patch). Does this make sense? Thanks. https://reviews.llvm.org/D34695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34695: _Float16 preprocessor macro definitions
scanon added inline comments. Comment at: lib/Headers/float.h:137 +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ rogfer01 wrote: > scanon wrote: > > rogfer01 wrote: > > > My understanding is that, given that we support TS18661-2 by default, > > > this macro should be predefined by clang and then there is no need to > > > protect these macros. > > > > > > You may want to add a test for this in `test/Preprocessor/init.c`. > > Where do you see that the `__STDC_WANT_IEC_60559_TYPES_EXT__` macro should > > be predefined by clang? > Hi Steve, > > certainly you're right, the TS says > > > The new identifiers added to C11 library headers by this part of ISO/IEC > > TS-18661 are defined or declared by their respective headers only if > > `__STDC_WANT_IEC_60559_TYPES_EXT__` is defined as a macro at the point in > > the source file where the appropriate header is first included. > > so (if I read this right) these identifiers are only available if such macro > is defined when including `float.h`. > > Can I assume from your comment that someone else should define it? Perhaps > the `float.h` header itself, some other file in the C-library implementation > or the user of the compiler via some `-D__STDC_WANT_IEC_60559_TYPES_EXT__`, > but not be predefined by the compiler? If this is the case, then the macros > still have to be guarded conditionally (as they were in the original patch). > > Does this make sense? Thanks. I think we could justify defining it ourselves under non-strict compilation modes; alternatively, system headers might define it for users in non-strict modes. My reading of the TS is that in strict mode, these types and macros should be hidden unless the user explicitly requests them by defining `__STDC_WANT_IEC_60559_TYPES_EXT__` themselves. https://reviews.llvm.org/D34695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37742: Add more tests for OpenCL atomic builtin functions
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM generally, apart from I am not sure why address spaces are only tested for atomic stores... https://reviews.llvm.org/D37742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34695: _Float16 preprocessor macro definitions
SjoerdMeijer added inline comments. Comment at: lib/Headers/float.h:137 +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ scanon wrote: > rogfer01 wrote: > > scanon wrote: > > > rogfer01 wrote: > > > > My understanding is that, given that we support TS18661-2 by default, > > > > this macro should be predefined by clang and then there is no need to > > > > protect these macros. > > > > > > > > You may want to add a test for this in `test/Preprocessor/init.c`. > > > Where do you see that the `__STDC_WANT_IEC_60559_TYPES_EXT__` macro > > > should be predefined by clang? > > Hi Steve, > > > > certainly you're right, the TS says > > > > > The new identifiers added to C11 library headers by this part of ISO/IEC > > > TS-18661 are defined or declared by their respective headers only if > > > `__STDC_WANT_IEC_60559_TYPES_EXT__` is defined as a macro at the point in > > > the source file where the appropriate header is first included. > > > > so (if I read this right) these identifiers are only available if such > > macro is defined when including `float.h`. > > > > Can I assume from your comment that someone else should define it? Perhaps > > the `float.h` header itself, some other file in the C-library > > implementation or the user of the compiler via some > > `-D__STDC_WANT_IEC_60559_TYPES_EXT__`, but not be predefined by the > > compiler? If this is the case, then the macros still have to be guarded > > conditionally (as they were in the original patch). > > > > Does this make sense? Thanks. > I think we could justify defining it ourselves under non-strict compilation > modes; alternatively, system headers might define it for users in non-strict > modes. > > My reading of the TS is that in strict mode, these types and macros should be > hidden unless the user explicitly requests them by defining > `__STDC_WANT_IEC_60559_TYPES_EXT__` themselves. Thanks, very useful discussion and clarification. I will add some tests for this, which I indeed forgot. Cheers. https://reviews.llvm.org/D34695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
JonasToth updated this revision to Diff 114851. JonasToth added a comment. - fix, that deleted destructors are caught as problem as well - clarify one comment, duplicated avoid was misleading https://reviews.llvm.org/D36354 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tidy/cppcoreguidelines/OwningMemoryCheck.h clang-tidy/utils/Matchers.h docs/ReleaseNotes.rst docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-owning-memory.cpp Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp @@ -0,0 +1,388 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t + +namespace gsl { +template +using owner = T; +} // namespace gsl + +template +class unique_ptr { +public: + unique_ptr(gsl::owner resource) : memory(resource) {} + unique_ptr(const unique_ptr &) = default; + + ~unique_ptr() { delete memory; } + +private: + gsl::owner memory; +}; + +void takes_owner(gsl::owner owned_int) { +} + +void takes_pointer(int *unowned_int) { +} + +void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) { +} + +template +void takes_templated_owner(gsl::owner owned_T) { +} + +gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok +gsl::owner returns_owner2() { return new int(42); }// Ok + +int *returns_no_owner1() { return nullptr; } +int *returns_no_owner2() { + return new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} +int *returns_no_owner3() { + int *should_be_owner = new int(42); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + return should_be_owner; +} +int *returns_no_owner4() { + gsl::owner owner = new int(42); + return owner; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a newly created resource of type 'int *' or 'gsl::owner<>' from a function whose return type is not 'gsl::owner<>' +} + +unique_ptr returns_no_owner5() { + return unique_ptr(new int(42)); // Ok +} + +/// FIXME: CSA finds it, but the report is misleading. Ownersemantics can catch this +/// by flow analysis similar to misc-use-after-move. +void csa_not_finding_leak() { + gsl::owner o1 = new int(42); // Ok + + gsl::owner o2 = o1; // Ok + o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guidelines + + delete o2; + // actual leak occurs here, its found, but mixed + delete o1; +} + +void test_assignment_and_initialization() { + int stack_int1 = 15; + int stack_int2; + + gsl::owner owned_int1 = &stack_int1; // BAD + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected initialization with value of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int2; + owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expected assignment source to be of type 'gsl::owner<>'; got 'int *' + + gsl::owner owned_int3 = new int(42); // Good + owned_int3 = nullptr; // Good + + gsl::owner owned_int4(nullptr); // Ok + owned_int4 = new int(42); // Good + + gsl::owner owned_int5 = owned_int3; // Good + + gsl::owner owned_int6{nullptr}; // Ok + owned_int6 = owned_int4; // Good + + // FIXME:, flow analysis for the case of reassignment. Value must be released before + owned_int6 = owned_int3; // BAD, because reassignment without resource release + + auto owned_int7 = returns_owner1(); // Bad, since type deduction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + const auto owned_int8 = returns_owner2(); // Bad, since type deduction eliminates the owner wrapper + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *const' with a newly created 'gsl::owner<>' + // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner + + gsl::owner owned_int9 = returns_owner1(); // Ok + int *unowned_int3 = returns_owner1();// Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non-owner 'int *' with a newly created 'gsl::owner<>' + + gsl::owner owned_int10; + owned_int10 = returns_owner1(); // Ok + + int *unowned_int4; + unowned_int4 = returns_owner1(); // Bad + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created 'gsl::owner<>' to non-owner 'int *' + + gsl::owner owned_int11 = returns_no_owner1(); // Bad
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
aaron.ballman accepted this revision. aaron.ballman added a comment. Good catch on the deleted constructor -- LGTM still! https://reviews.llvm.org/D36354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r313043 - [clang-tidy] Implement type-based check for `gsl::owner`
Author: jonastoth Date: Tue Sep 12 09:20:51 2017 New Revision: 313043 URL: http://llvm.org/viewvc/llvm-project?rev=313043&view=rev Log: [clang-tidy] Implement type-based check for `gsl::owner` This check implements the typebased semantic of `gsl::owner`. Meaning, that - only `gsl::owner` is allowed to get `delete`d - `new` expression must be assigned to `gsl::owner` - function calls that expect `gsl::owner` as argument, must get either an owner or a newly created and recognized resource (in the moment only `new`ed memory) - assignment to `gsl::owner` must be either a resource or another owner - functions returning an `gsl::owner` are considered as factories, and their result must be assigned to an `gsl::owner` - classes that have an `gsl::owner`-member must declare a non-default destructor There are some problems that occur when typededuction is in place. For example `auto Var = function_that_returns_owner();` the type of `Var` will not be an `gsl::owner`. This case is catched, and explicitly noted. But cases like fully templated functions ``` template void f(T t) { delete t; } // ... f(gsl::owner(new int(42))); ``` Will created false positive (the deletion is problematic), since the type deduction removes the wrapping `typeAlias`. Please give your comments :) Added: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-owning-memory.cpp Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/trunk/clang-tidy/utils/Matchers.h clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=313043&r1=313042&r2=313043&view=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Tue Sep 12 09:20:51 2017 @@ -4,6 +4,7 @@ add_clang_library(clangTidyCppCoreGuidel CppCoreGuidelinesTidyModule.cpp InterfacesGlobalInitCheck.cpp NoMallocCheck.cpp + OwningMemoryCheck.cpp ProBoundsArrayToPointerDecayCheck.cpp ProBoundsConstantArrayIndexCheck.cpp ProBoundsPointerArithmeticCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=313043&r1=313042&r2=313043&view=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp Tue Sep 12 09:20:51 2017 @@ -13,6 +13,7 @@ #include "../misc/UnconventionalAssignOperatorCheck.h" #include "InterfacesGlobalInitCheck.h" #include "NoMallocCheck.h" +#include "OwningMemoryCheck.h" #include "ProBoundsArrayToPointerDecayCheck.h" #include "ProBoundsConstantArrayIndexCheck.h" #include "ProBoundsPointerArithmeticCheck.h" @@ -37,6 +38,8 @@ public: CheckFactories.registerCheck( "cppcoreguidelines-interfaces-global-init"); CheckFactories.registerCheck("cppcoreguidelines-no-malloc"); +CheckFactories.registerCheck( +"cppcoreguidelines-owning-memory"); CheckFactories.registerCheck( "cppcoreguidelines-pro-bounds-array-to-pointer-decay"); CheckFactories.registerCheck( Added: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp?rev=313043&view=auto == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp Tue Sep 12 09:20:51 2017 @@ -0,0 +1,315 @@ +//===--- OwningMemoryCheck.cpp - clang-tidy===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "OwningMemoryCheck.h" +#include "../utils/Matchers.h" +#include "../utils/OptionsUtils.h" +#include "cla
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
lebedev.ri added a comment. In https://reviews.llvm.org/D33826#868085, @aaron.ballman wrote: > In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: > > > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: > > > > > There is an exception to the general rule (EXP36-C-EX2), stating that the > > > result of `malloc` and friends is allowed to be casted to stricter > > > alignments, since the pointer is known to be of correct alignment. > > > > > > Quote for the reference: > > > > > EXP36-C-EX2: If a pointer is known to be correctly aligned to the target > > > type, then a cast to that type is permitted. There are several cases > > > where a pointer is known to be correctly aligned to the target type. The > > > pointer could point to an object declared with a suitable alignment > > > specifier. It could point to an object returned by aligned_alloc(), > > > calloc(), malloc(), or realloc(), as per the C standard, section 7.22.3, > > > paragraph 1 [ISO/IEC 9899:2011]. > > > > For plain `calloc(), malloc(), or realloc()`, i would guess it's related to > > `max_align_t` / `std::max_align_t` / `__STDCPP_DEFAULT_NEW_ALIGNMENT__`, > > which is generally just `16` bytes. > > > It's a requirement from the C standard that malloc, calloc, and realloc > return a suitably-aligned pointer for *any* type. We are probably arguing about the details, or i'm just misguided, but you mean any *standard* type, right? MALLOC(3) ... The malloc() and calloc() functions return a pointer to the allocated memory, which is suitably aligned for any built-in type. E.g. `__m256` needs to be 32-byte aligned, and user type, with the help of `alignas()`, can have different alignment requirements >>> Could you add a testcase for this case, i think there would currenlty be a >>> false positive. >>> >>> And is there a general way of knowing when the pointer is of correct >>> alignment, or is it necessary to keep a list of functions like `malloc` >>> that are just known? >>> If yes, i think it would be nice if this list is configurable (maybe like >>> in cppcoreguidelines-no-malloc, where that functionality could be >>> refactored out). > > Agreed, this should be a configurable list, but is should be pre-populated > with the listed functions from the CERT standard. Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
JonasToth added a comment. commited in https://reviews.llvm.org/rL313043 https://reviews.llvm.org/D36354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
aaron.ballman added a comment. In https://reviews.llvm.org/D33826#868167, @lebedev.ri wrote: > In https://reviews.llvm.org/D33826#868085, @aaron.ballman wrote: > > > In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: > > > > > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: > > > > > > > There is an exception to the general rule (EXP36-C-EX2), stating that > > > > the result of `malloc` and friends is allowed to be casted to stricter > > > > alignments, since the pointer is known to be of correct alignment. > > > > > > > > > Quote for the reference: > > > > > > > EXP36-C-EX2: If a pointer is known to be correctly aligned to the > > > > target type, then a cast to that type is permitted. There are several > > > > cases where a pointer is known to be correctly aligned to the target > > > > type. The pointer could point to an object declared with a suitable > > > > alignment specifier. It could point to an object returned by > > > > aligned_alloc(), calloc(), malloc(), or realloc(), as per the C > > > > standard, section 7.22.3, paragraph 1 [ISO/IEC 9899:2011]. > > > > > > For plain `calloc(), malloc(), or realloc()`, i would guess it's related > > > to `max_align_t` / `std::max_align_t` / > > > `__STDCPP_DEFAULT_NEW_ALIGNMENT__`, which is generally just `16` bytes. > > > > > > It's a requirement from the C standard that malloc, calloc, and realloc > > return a suitably-aligned pointer for *any* type. > > > We are probably arguing about the details, or i'm just misguided, but you > mean any *standard* type, right? > > MALLOC(3) >... >The malloc() and calloc() functions return a pointer to the allocated > memory, which is suitably aligned for any built-in type. > > > E.g. `__m256` needs to be 32-byte aligned, and user type, with the help of > `alignas()`, can have different alignment requirements C11 7.22.3p1 (in part): The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object with a fundamental alignment requirement and then used to access such an object or an array of such objects in the space allocated (until the space is explicitly deallocated). C11 6.2.8p2 defines fundamental alignment: A fundamental alignment is represented by an alignment less than or equal to the greatest alignment supported by the implementation in all contexts, which is equal to _Alignof (max_align_t). So I don't think this applies to only builtin types. Which makes sense, otherwise you couldn't rely on malloc to do the correct thing with `struct S { char c; int i; }; struct S s = (struct S *)malloc(sizeof(struct S));` However, you are correct that it doesn't need to return a suitably aligned pointer for *any* type. > > Could you add a testcase for this case, i think there would currenlty be a false positive. And is there a general way of knowing when the pointer is of correct alignment, or is it necessary to keep a list of functions like `malloc` that are just known? If yes, i think it would be nice if this list is configurable (maybe like in cppcoreguidelines-no-malloc, where that functionality could be refactored out). >> >> Agreed, this should be a configurable list, but is should be pre-populated >> with the listed functions from the CERT standard. Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR
RKSimon added a comment. some very minor whitespace/indentation issues please can you confirm @craig.topper's query about __builtin_ia32_pbroadcastq512_mem_mask Comment at: lib/Headers/avx512vlintrin.h:5727 +static __inline__ __m128i __DEFAULT_FN_ATTRS + _mm_mask_set1_epi32(__m128i __O, __mmask8 __M, int __A) { + return (__m128i)__builtin_ia32_selectd_128(__M, weird indentation? Comment at: lib/Headers/avx512vlintrin.h:5734 +static __inline__ __m128i __DEFAULT_FN_ATTRS + _mm_maskz_set1_epi32( __mmask8 __M, int __A) { + return (__m128i)__builtin_ia32_selectd_128(__M, weird indentation? Comment at: lib/Headers/avx512vlintrin.h:5741 +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_mask_set1_epi32(__m256i __O, __mmask8 __M, int __A) { + return (__m256i)__builtin_ia32_selectd_256(__M, weird indentation? Comment at: lib/Headers/avx512vlintrin.h:5748 +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_maskz_set1_epi32( __mmask8 __M, int __A) { + return (__m256i)__builtin_ia32_selectd_256(__M, weird indentation? Comment at: test/CodeGen/avx512f-builtins.c:7732 + // CHECK-LABEL: @test_mm512_mask_set1_epi32 +// CHECK: insertelement <16 x i32> undef, i32 %{{.*}}, i32 0 + // CHECK: insertelement <16 x i32> %{{.*}}, i32 %{{.*}}, i32 1 weird indentation? Comment at: test/CodeGen/avx512f-builtins.c:7755 + // CHECK-LABEL: @test_mm512_maskz_set1_epi32 +// CHECK: insertelement <16 x i32> undef, i32 %{{.*}}, i32 0 + // CHECK: insertelement <16 x i32> %{{.*}}, i32 %{{.*}}, i32 1 weird indentation? Comment at: test/CodeGen/avx512f-builtins.c:7966 //CHECK: insertelement{{.*}}i32 14 //CHECK: insertelement{{.*}}i32 15 return _mm512_setr_epi32( __A, __B, __C, __D,__E, __F, __G, __H, weird indentation? Comment at: test/CodeGen/avx512vl-builtins.c:4597 // CHECK-LABEL: @test_mm256_maskz_set1_epi64 - // CHECK: @llvm.x86.avx512.mask.pbroadcast.q.gpr.256 +// CHECK: insertelement <4 x i64> undef, i64 %{{.*}}, i32 0 + // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, i32 1 weird indentation? https://reviews.llvm.org/D37668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] Add support for snippet completions
rwols added a comment. Thanks! Thinking ahead now so we're on the same page, you will be implementing the client's initialize request, and I'll start work on textDocument/signatureHelp. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313049 - Use the VFS from the CompilerInvocation by default
Author: teemperor Date: Tue Sep 12 09:54:53 2017 New Revision: 313049 URL: http://llvm.org/viewvc/llvm-project?rev=313049&view=rev Log: Use the VFS from the CompilerInvocation by default Summary: The CompilerInstance should create its default VFS from its CompilerInvocation. Right now the user has to manually create the VFS before creating the FileManager even though `-ivfsoverlay file.yaml` was passed via the CompilerInvocation (which is exactly how we worked around this issue in `FrontendAction.cpp` so far). This patch uses the invocation's VFS by default and also tests this behavior now from the point of view of a program that uses the clang API. Reviewers: benlangmuir, v.g.vassilev Reviewed By: v.g.vassilev Subscribers: mgorny, cfe-commits, v.g.vassilev Differential Revision: https://reviews.llvm.org/D37416 Added: cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/unittests/Frontend/CMakeLists.txt Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original) +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Tue Sep 12 09:54:53 2017 @@ -640,7 +640,9 @@ public: const CodeGenOptions *CodeGenOpts = nullptr); /// Create the file manager and replace any existing one with it. - void createFileManager(); + /// + /// \return The new file manager on success, or null on failure. + FileManager *createFileManager(); /// Create the source manager and replace any existing one with it. void createSourceManager(FileManager &FileMgr); Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Sep 12 09:54:53 2017 @@ -300,12 +300,16 @@ CompilerInstance::createDiagnostics(Diag // File Manager -void CompilerInstance::createFileManager() { +FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { -// TODO: choose the virtual file system based on the CompilerInvocation. -setVirtualFileSystem(vfs::getRealFileSystem()); +if (IntrusiveRefCntPtr VFS = +createVFSFromCompilerInvocation(getInvocation(), getDiagnostics())) + setVirtualFileSystem(VFS); +else + return nullptr; } FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem); + return FileMgr.get(); } // Source Manager Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Sep 12 09:54:53 2017 @@ -633,18 +633,12 @@ bool FrontendAction::BeginSourceFile(Com return true; } - if (!CI.hasVirtualFileSystem()) { -if (IntrusiveRefCntPtr VFS = - createVFSFromCompilerInvocation(CI.getInvocation(), - CI.getDiagnostics())) - CI.setVirtualFileSystem(VFS); -else + // Set up the file and source managers, if needed. + if (!CI.hasFileManager()) { +if (!CI.createFileManager()) { goto failure; +} } - - // Set up the file and source managers, if needed. - if (!CI.hasFileManager()) -CI.createFileManager(); if (!CI.hasSourceManager()) CI.createSourceManager(CI.getFileManager()); Modified: cfe/trunk/unittests/Frontend/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CMakeLists.txt?rev=313049&r1=313048&r2=313049&view=diff == --- cfe/trunk/unittests/Frontend/CMakeLists.txt (original) +++ cfe/trunk/unittests/Frontend/CMakeLists.txt Tue Sep 12 09:54:53 2017 @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS add_clang_unittest(FrontendTests ASTUnitTest.cpp + CompilerInstanceTest.cpp FrontendActionTest.cpp CodeGenActionTest.cpp PCHPreambleTest.cpp Added: cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp?rev=313049&view=auto == --- cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp (added) +++
[PATCH] D37416: Use the VFS from the CompilerInvocation by default
This revision was automatically updated to reflect the committed changes. Closed by commit rL313049: Use the VFS from the CompilerInvocation by default (authored by teemperor). Changed prior to commit: https://reviews.llvm.org/D37416?vs=114823&id=114857#toc Repository: rL LLVM https://reviews.llvm.org/D37416 Files: cfe/trunk/include/clang/Frontend/CompilerInstance.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/unittests/Frontend/CMakeLists.txt cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp Index: cfe/trunk/lib/Frontend/FrontendAction.cpp === --- cfe/trunk/lib/Frontend/FrontendAction.cpp +++ cfe/trunk/lib/Frontend/FrontendAction.cpp @@ -633,18 +633,12 @@ return true; } - if (!CI.hasVirtualFileSystem()) { -if (IntrusiveRefCntPtr VFS = - createVFSFromCompilerInvocation(CI.getInvocation(), - CI.getDiagnostics())) - CI.setVirtualFileSystem(VFS); -else + // Set up the file and source managers, if needed. + if (!CI.hasFileManager()) { +if (!CI.createFileManager()) { goto failure; +} } - - // Set up the file and source managers, if needed. - if (!CI.hasFileManager()) -CI.createFileManager(); if (!CI.hasSourceManager()) CI.createSourceManager(CI.getFileManager()); Index: cfe/trunk/lib/Frontend/CompilerInstance.cpp === --- cfe/trunk/lib/Frontend/CompilerInstance.cpp +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp @@ -300,12 +300,16 @@ // File Manager -void CompilerInstance::createFileManager() { +FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { -// TODO: choose the virtual file system based on the CompilerInvocation. -setVirtualFileSystem(vfs::getRealFileSystem()); +if (IntrusiveRefCntPtr VFS = +createVFSFromCompilerInvocation(getInvocation(), getDiagnostics())) + setVirtualFileSystem(VFS); +else + return nullptr; } FileMgr = new FileManager(getFileSystemOpts(), VirtualFileSystem); + return FileMgr.get(); } // Source Manager Index: cfe/trunk/unittests/Frontend/CMakeLists.txt === --- cfe/trunk/unittests/Frontend/CMakeLists.txt +++ cfe/trunk/unittests/Frontend/CMakeLists.txt @@ -4,6 +4,7 @@ add_clang_unittest(FrontendTests ASTUnitTest.cpp + CompilerInstanceTest.cpp FrontendActionTest.cpp CodeGenActionTest.cpp PCHPreambleTest.cpp Index: cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp === --- cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp +++ cfe/trunk/unittests/Frontend/CompilerInstanceTest.cpp @@ -0,0 +1,74 @@ +//===- unittests/Frontend/CompilerInstanceTest.cpp - CI tests -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/CompilerInvocation.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/ToolOutputFile.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +TEST(CompilerInstance, DefaultVFSOverlayFromInvocation) { + // Create a temporary VFS overlay yaml file. + int FD; + SmallString<256> FileName; + ASSERT_FALSE(sys::fs::createTemporaryFile("vfs", "yaml", FD, FileName)); + tool_output_file File(FileName, FD); + + SmallString<256> CurrentPath; + sys::fs::current_path(CurrentPath); + sys::fs::make_absolute(CurrentPath, FileName); + + // Mount the VFS file itself on the path 'virtual.file'. Makes this test + // a bit shorter than creating a new dummy file just for this purpose. + const std::string CurrentPathStr = CurrentPath.str(); + const std::string FileNameStr = FileName.str(); + const char *VFSYaml = "{ 'version': 0, 'roots': [\n" +" { 'name': '%s',\n" +"'type': 'directory',\n" +"'contents': [\n" +" { 'name': 'vfs-virtual.file', 'type': 'file',\n" +"'external-contents': '%s'\n" +" }\n" +"]\n" +" }\n" +"]}\n"; + File.os() << format(VFSYaml, CurrentPathStr.c_str(), FileName.c_str()); + File.os().flush(); + + // Create a CompilerInvocation that uses this overlay file. + const std::string VFSArg = "-ivfsoverlay" + FileNameStr; + const char *Args[] = {"clang", VFSArg.c_str(), "-xc++", "-"}; + + IntrusiveRefCntPt
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
lebedev.ri added a comment. In https://reviews.llvm.org/D33826#868185, @aaron.ballman wrote: > In https://reviews.llvm.org/D33826#868167, @lebedev.ri wrote: > > > In https://reviews.llvm.org/D33826#868085, @aaron.ballman wrote: > > > > > In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: > > > > > > > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: > > > > > > > > > There is an exception to the general rule (EXP36-C-EX2), stating that > > > > > the result of `malloc` and friends is allowed to be casted to > > > > > stricter alignments, since the pointer is known to be of correct > > > > > alignment. > > > > > > > > > > > > Quote for the reference: > > > > > > > > > EXP36-C-EX2: If a pointer is known to be correctly aligned to the > > > > > target type, then a cast to that type is permitted. There are several > > > > > cases where a pointer is known to be correctly aligned to the target > > > > > type. The pointer could point to an object declared with a suitable > > > > > alignment specifier. It could point to an object returned by > > > > > aligned_alloc(), calloc(), malloc(), or realloc(), as per the C > > > > > standard, section 7.22.3, paragraph 1 [ISO/IEC 9899:2011]. > > > > > > > > For plain `calloc(), malloc(), or realloc()`, i would guess it's > > > > related to `max_align_t` / `std::max_align_t` / > > > > `__STDCPP_DEFAULT_NEW_ALIGNMENT__`, which is generally just `16` bytes. > > > > > > > > > It's a requirement from the C standard that malloc, calloc, and realloc > > > return a suitably-aligned pointer for *any* type. > > > > > > We are probably arguing about the details, or i'm just misguided, but you > > mean any *standard* type, right? > > > > MALLOC(3) > >... > >The malloc() and calloc() functions return a pointer to the allocated > > memory, which is suitably aligned for any built-in type. > > > > > > E.g. `__m256` needs to be 32-byte aligned, and user type, with the help of > > `alignas()`, can have different alignment requirements > > > C11 7.22.3p1 (in part): > > The pointer returned if the allocation succeeds is suitably aligned so that > it may be assigned to >a pointer to any type of object with a fundamental alignment requirement > and then used >to access such an object or an array of such objects in the space > allocated (until the space >is explicitly deallocated). > > C11 6.2.8p2 defines fundamental alignment: > > A fundamental alignment is represented by an alignment less than or equal > to the greatest >alignment supported by the implementation in all contexts, which is equal > to >_Alignof (max_align_t). > > So I don't think this applies to only builtin types. Which makes sense, > otherwise you couldn't rely on malloc to do the correct thing with `struct S > { char c; int i; }; struct S s = (struct S *)malloc(sizeof(struct S));` > However, you are correct that it doesn't need to return a suitably aligned > pointer for *any* type. I agree! Thus, my point being, *if* the cast in question is not from `void*` (if it is, i don't think it is possible to warn, or prevent the warning for that matter), shouldn't the alignment requirements of the target type be considered, even if the pointer was just returned by `malloc` and friends? >> >> > Could you add a testcase for this case, i think there would currenlty be > a false positive. > > And is there a general way of knowing when the pointer is of correct > alignment, or is it necessary to keep a list of functions like `malloc` > that are just known? > If yes, i think it would be nice if this list is configurable (maybe > like in cppcoreguidelines-no-malloc, where that functionality could be > refactored out). >>> >>> Agreed, this should be a configurable list, but is should be pre-populated >>> with the listed functions from the CERT standard. Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
On Tue, Sep 12, 2017 at 1:02 PM, Roman Lebedev via Phabricator wrote: > lebedev.ri added a comment. > > In https://reviews.llvm.org/D33826#868185, @aaron.ballman wrote: > >> In https://reviews.llvm.org/D33826#868167, @lebedev.ri wrote: >> >> > In https://reviews.llvm.org/D33826#868085, @aaron.ballman wrote: >> > >> > > In https://reviews.llvm.org/D33826#866170, @lebedev.ri wrote: >> > > >> > > > In https://reviews.llvm.org/D33826#866161, @JonasToth wrote: >> > > > >> > > > > There is an exception to the general rule (EXP36-C-EX2), stating >> > > > > that the result of `malloc` and friends is allowed to be casted to >> > > > > stricter alignments, since the pointer is known to be of correct >> > > > > alignment. >> > > > >> > > > >> > > > Quote for the reference: >> > > > >> > > > > EXP36-C-EX2: If a pointer is known to be correctly aligned to the >> > > > > target type, then a cast to that type is permitted. There are >> > > > > several cases where a pointer is known to be correctly aligned to >> > > > > the target type. The pointer could point to an object declared with >> > > > > a suitable alignment specifier. It could point to an object returned >> > > > > by aligned_alloc(), calloc(), malloc(), or realloc(), as per the C >> > > > > standard, section 7.22.3, paragraph 1 [ISO/IEC 9899:2011]. >> > > > >> > > > For plain `calloc(), malloc(), or realloc()`, i would guess it's >> > > > related to `max_align_t` / `std::max_align_t` / >> > > > `__STDCPP_DEFAULT_NEW_ALIGNMENT__`, which is generally just `16` bytes. >> > > >> > > >> > > It's a requirement from the C standard that malloc, calloc, and realloc >> > > return a suitably-aligned pointer for *any* type. >> > >> > >> > We are probably arguing about the details, or i'm just misguided, but you >> > mean any *standard* type, right? >> > >> > MALLOC(3) >> >... >> >The malloc() and calloc() functions return a pointer to the allocated >> > memory, which is suitably aligned for any built-in type. >> > >> > >> > E.g. `__m256` needs to be 32-byte aligned, and user type, with the help >> > of `alignas()`, can have different alignment requirements >> >> >> C11 7.22.3p1 (in part): >> >> The pointer returned if the allocation succeeds is suitably aligned so >> that it may be assigned to >>a pointer to any type of object with a fundamental alignment requirement >> and then used >>to access such an object or an array of such objects in the space >> allocated (until the space >>is explicitly deallocated). >> >> C11 6.2.8p2 defines fundamental alignment: >> >> A fundamental alignment is represented by an alignment less than or equal >> to the greatest >>alignment supported by the implementation in all contexts, which is equal >> to >>_Alignof (max_align_t). >> >> So I don't think this applies to only builtin types. Which makes sense, >> otherwise you couldn't rely on malloc to do the correct thing with `struct S >> { char c; int i; }; struct S s = (struct S *)malloc(sizeof(struct S));` >> However, you are correct that it doesn't need to return a suitably aligned >> pointer for *any* type. > > > I agree! > Thus, my point being, *if* the cast in question is not from `void*` (if it > is, i don't think it is possible to warn, or prevent the warning for that > matter), > shouldn't the alignment requirements of the target type be considered, even > if the pointer was just returned by `malloc` and friends? Ah, I think I'm catching on to the point you're raising (thank you for the patience). If the return type is void *, we don't have enough information to sensibly diagnose (not without data flow analysis to determine where the original value came from, anyway), and if the return type is not void *, we should be checking the alignment anyway. That suggests we don't need the exception in this check at all, unless we find extant implementations that return something other than void *. ~Aaron > >>> >>> >> Could you add a testcase for this case, i think there would currenlty be >> a false positive. >> >> And is there a general way of knowing when the pointer is of correct >> alignment, or is it necessary to keep a list of functions like `malloc` >> that are just known? >> If yes, i think it would be nice if this list is configurable (maybe >> like in cppcoreguidelines-no-malloc, where that functionality could be >> refactored out). Agreed, this should be a configurable list, but is should be pre-populated with the listed functions from the CERT standard. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D33826 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare
lebedev.ri updated this revision to Diff 114861. lebedev.ri added a comment. Aaaand revert back to dump approach with code duplication as requested :) (For the second part of the fix in another differential, if the reverted approach with struct turns out to be better, i guess i will use it) Repository: rL LLVM https://reviews.llvm.org/D37629 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/compare.c test/Sema/tautological-unsigned-enum-zero-compare.c Index: test/Sema/tautological-unsigned-enum-zero-compare.c === --- /dev/null +++ test/Sema/tautological-unsigned-enum-zero-compare.c @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s + +int main() { + enum A { A_foo, A_bar }; + enum A a; + +#ifdef TEST + if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} +return 0; + if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} +return 0; + if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} +return 0; + if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} +return 0; + if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} +return 0; + if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} +return 0; +#else + // expected-no-diagnostics + if (a < 0) +return 0; + if (a >= 0) +return 0; + if (0 <= a) +return 0; + if (0 > a) +return 0; + if (a < 0U) +return 0; + if (a >= 0U) +return 0; + if (0U <= a) +return 0; + if (0U > a) +return 0; +#endif + + return 1; +} Index: test/Sema/compare.c === --- test/Sema/compare.c +++ test/Sema/compare.c @@ -308,8 +308,59 @@ int rdar8511238() { enum A { A_foo, A_bar }; enum A a; + + if (a == 0) + return 0; + if (a != 0) + return 0; if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; + return 0; + if (a <= 0) + return 0; + if (a > 0) + return 0; + if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + return 0; + + if (0 == a) + return 0; + if (0 != a) + return 0; + if (0 < a) + return 0; + if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} + return 0; + if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} + return 0; + if (0 >= a) + return 0; + + if (a == 0U) + return 0; + if (a != 0U) + return 0; + if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} + return 0; + if (a <= 0U) + return 0; + if (a > 0U) + return 0; + if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + return 0; + + if (0U == a) + return 0; + if (0U != a) + return 0; + if (0U < a) + return 0; + if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} + return 0; + if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} + return 0; + if (0U >= a) + return 0; + return 20; } Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -8590,28 +8590,72 @@ Expr *LHS = E->getLHS(); Expr *RHS = E->getRHS(); - bool Match = true; + // is this a tautological comparison? if yes, than contains the always-result + llvm::Optional Result; + Expr *Value; // which one is the value, and not a constant? + const char *cmp; // the comparison used, as string if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) - << "< 0" << "false" << HasEnumType(LHS) - << LHS->getSourceRange() << RHS->getSourceRange(); +Result = false; +Value = LHS; +cmp = "< 0"; } else if (op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) { -S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) - << ">= 0" << "true" << HasEnumType(LHS) - << LHS->getSourceRange() << RHS->getSourceRange(); +Result = true; +Value =
[libcxx] r313056 - Apply D28224: 'Throw exception after too many steps' Fixes PR#20291. Thanks to Tim Shen for the patch
Author: marshall Date: Tue Sep 12 10:56:59 2017 New Revision: 313056 URL: http://llvm.org/viewvc/llvm-project?rev=313056&view=rev Log: Apply D28224: 'Throw exception after too many steps' Fixes PR#20291. Thanks to Tim Shen for the patch Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp Modified: libcxx/trunk/include/regex Modified: libcxx/trunk/include/regex URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=313056&r1=313055&r2=313056&view=diff == --- libcxx/trunk/include/regex (original) +++ libcxx/trunk/include/regex Tue Sep 12 10:56:59 2017 @@ -773,6 +773,8 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 + _LIBCPP_BEGIN_NAMESPACE_STD namespace regex_constants @@ -5552,8 +5554,14 @@ basic_regex<_CharT, _Traits>::__match_at __states.back().__node_ = __st; __states.back().__flags_ = __flags; __states.back().__at_first_ = __at_first; +int __counter = 0; +int __length = __last - __first; do { +++__counter; +if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && +__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); @@ -5627,8 +5635,14 @@ basic_regex<_CharT, _Traits>::__match_at __states.back().__flags_ = __flags; __states.back().__at_first_ = __at_first; bool __matched = false; +int __counter = 0; +int __length = __last - __first; do { +++__counter; +if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && +__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); @@ -5724,8 +5738,14 @@ basic_regex<_CharT, _Traits>::__match_at __states.back().__at_first_ = __at_first; const _CharT* __current = __first; bool __matched = false; +int __counter = 0; +int __length = __last - __first; do { +++__counter; +if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && +__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length) + __throw_regex_error(); __state& __s = __states.back(); if (__s.__node_) __s.__node_->__exec(__s); Added: libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp?rev=313056&view=auto == --- libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp (added) +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp Tue Sep 12 10:56:59 2017 @@ -0,0 +1,46 @@ +//===--===// +// +// 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. +// +//===--===// + +// + +// template +// bool +// regex_match(BidirectionalIterator first, BidirectionalIterator last, +// match_results& m, +// const basic_regex& e, +// regex_constants::match_flag_type flags = regex_constants::match_default); + +// Throw exception after spent too many cycles with respect to the length of the input string. + +#include +#include + +int main() { + for (std::regex_constants::syntax_option_type op : + {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, +std::regex::awk}) { +try { + std::regex_match( + "", + std::regex( + "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?", + op)); + assert(false); +} catch (const std::regex_error &e) { + assert(e.code() == std::regex_constants::error_complexity); +} + } + std::string s(10, 'a'); + for (std::regex_constants::syntax_option_type op : + {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, +std::regex::awk}) { +assert(std::regex_match(s, std::regex("a*", op))); + } + return 0; +} Added: libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp?rev=313056&view=a
[PATCH] D37727: Driver: Remove custom MinGW linker detection
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. Nice! IIUC, now that the gnu ld driver works on Windows we can remove this logic. Thanks! Repository: rL LLVM https://reviews.llvm.org/D37727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28224: [libcxx, regex] Throw exception after too many steps.
mclow.lists accepted this revision. mclow.lists added a comment. This revision is now accepted and ready to land. Applied as revision 313056 (with minor editing) https://reviews.llvm.org/D28224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37413: [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions
rnk added inline comments. Comment at: lib/Sema/SemaStmtAsm.cpp:617 +return; + } else if (Res->isRValue()) { +bool Enum = isa(T) && Res->EvaluateAsRValue(Eval, Context); RKSimon wrote: > (style) Split these instead of an if-elseif chain LLVM suggests early returns: https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code I don't particularly care here, up to you. I personally like to abuse the ability of C++ to return void to write things like this and skip braces, but maybe *I'm* too clever for my own good: if (T->isFunctionType() || T->isDependentType()) return Info.setLabel(Res); if (Res->isRValue()) { if (isa(T) && Res->EvaluateAsRValue(Eval, Context)) return Info.setEnum(Eval.Val.getInt().getSExtValue()); return Info.setLabel(Res); } Comment at: lib/Sema/SemaStmtAsm.cpp:620 +bool Enum = isa(T) && Res->EvaluateAsRValue(Eval, Context); +Enum ? Info.setEnum(Eval.Val.getInt().getSExtValue()) : Info.setLabel(Res); +return; This conditional expression is a bit too cute, I'd rather use a regular if. Repository: rL LLVM https://reviews.llvm.org/D37413 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check
lebedev.ri added a comment. In https://reviews.llvm.org/D33826#868185, @aaron.ballman wrote: > Ah, I think I'm catching on to the point you're raising (thank you for > the patience). If the return type is void *, we don't have enough > information to sensibly diagnose (not without data flow analysis to > determine where the original value came from, anyway), and if the > return type is not void *, we should be checking the alignment anyway. > > That suggests we don't need the exception in this check at all, unless > we find extant implementations that return something other than void Yes! And, more than that, in some rare cases, when casting the pointer that was *just* returned by `malloc`, i believe we *can* do this check too. (i.e. in `malloc` case, the target type should *not* have bigger alignment requirements than the `_Alignof (max_align_t)`.) Now i have fully explained my concerns :) Repository: rL LLVM https://reviews.llvm.org/D33826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
hfinkel added a comment. In https://reviews.llvm.org/D37436#867965, @aaron.ballman wrote: > In https://reviews.llvm.org/D37436#867287, @rsmith wrote: > > > If this is just supposed to be an experiment to get feedback on the > > feature, then I don't think we should be treating it as a different > > attribute syntax at all. Rather, I think we > > just want to permit C++11 attributes to be parsed in other language modes. > > If/when this becomes part of some future C working draft, I think that's > > the time to have a > > separate attribute syntax with a distinct set of valid unqualified > > attribute names. > > > I do not think that's the correct approach. These are not C++ attributes (for > instance, no `using` insanity is allowed, `::` is a new lexing token in C, > etc). Also, I don't think it's a good idea to enable all C++11-style > attributes in C mode without giving each attribute some appropriate thought > (what does `abi_tag` *do* in C mode? What happens with _Noreturn vs > [[noreturn]] etc). Also, I'm not comfortable adding a bunch of > vendor-specific `gnu::` attributes that GCC does not implement in C yet. On this last point, I disagree. Implementation experience is about all of the messy things that occur in production. In production, if we have this syntax, then we'll end up enabling it for a bunch of vendor-specific attributes. Do you think that we wouldn't? N2137 specifically talks about this as a use case. If so, this will include `gnu::` attributes that we have in Clang (even if GCC does not implement them). From my perspective, lack of consistency here between Clang's C and C++ modes is much more problematic than a lack of consistency between what Clang and GCC implement. https://reviews.llvm.org/D37436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r313011 - [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR
Hello Yael, It looks like this commit broke one of our builders: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/17121 . . . Failing Tests (1): Clang :: Modules/builtins.m Please have a look? Thanks Galina On Tue, Sep 12, 2017 at 12:46 AM, Yael Tsafrir via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ytsafrir > Date: Tue Sep 12 00:46:32 2017 > New Revision: 313011 > > URL: http://llvm.org/viewvc/llvm-project?rev=313011&view=rev > Log: > [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native > llvm IR > > Differential Revision: https://reviews.llvm.org/D37562 > > Modified: > cfe/trunk/include/clang/Basic/BuiltinsX86.def > cfe/trunk/lib/Headers/avx2intrin.h > cfe/trunk/lib/Headers/avx512bwintrin.h > cfe/trunk/lib/Headers/emmintrin.h > cfe/trunk/test/CodeGen/avx2-builtins.c > cfe/trunk/test/CodeGen/avx512bw-builtins.c > cfe/trunk/test/CodeGen/avx512vlbw-builtins.c > cfe/trunk/test/CodeGen/builtins-x86.c > cfe/trunk/test/CodeGen/sse2-builtins.c > > Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Basic/BuiltinsX86.def?rev=313011&r1=313010&r2=313011&view=diff > > == > --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) > +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Sep 12 00:46:32 2017 > @@ -266,8 +266,6 @@ TARGET_BUILTIN(__builtin_ia32_paddusw128 > TARGET_BUILTIN(__builtin_ia32_psubusb128, "V16cV16cV16c", "", "sse2") > TARGET_BUILTIN(__builtin_ia32_psubusw128, "V8sV8sV8s", "", "sse2") > TARGET_BUILTIN(__builtin_ia32_pmulhw128, "V8sV8sV8s", "", "sse2") > -TARGET_BUILTIN(__builtin_ia32_pavgb128, "V16cV16cV16c", "", "sse2") > -TARGET_BUILTIN(__builtin_ia32_pavgw128, "V8sV8sV8s", "", "sse2") > TARGET_BUILTIN(__builtin_ia32_pmaxub128, "V16cV16cV16c", "", "sse2") > TARGET_BUILTIN(__builtin_ia32_pmaxsw128, "V8sV8sV8s", "", "sse2") > TARGET_BUILTIN(__builtin_ia32_pminub128, "V16cV16cV16c", "", "sse2") > @@ -522,8 +520,6 @@ TARGET_BUILTIN(__builtin_ia32_paddusw256 > TARGET_BUILTIN(__builtin_ia32_psubusb256, "V32cV32cV32c", "", "avx2") > TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "", "avx2") > TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "", "avx2") > -TARGET_BUILTIN(__builtin_ia32_pavgb256, "V32cV32cV32c", "", "avx2") > -TARGET_BUILTIN(__builtin_ia32_pavgw256, "V16sV16sV16s", "", "avx2") > TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "", > "avx2") > TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "", "avx2") > TARGET_BUILTIN(__builtin_ia32_phaddd256, "V8iV8iV8i", "", "avx2") > @@ -1075,8 +1071,6 @@ TARGET_BUILTIN(__builtin_ia32_paddsb512_ > TARGET_BUILTIN(__builtin_ia32_paddsw512_mask, "V32sV32sV32sV32sUi", "", > "avx512bw") > TARGET_BUILTIN(__builtin_ia32_paddusb512_mask, "V64cV64cV64cV64cULLi", > "", "avx512bw") > TARGET_BUILTIN(__builtin_ia32_paddusw512_mask, "V32sV32sV32sV32sUi", "", > "avx512bw") > -TARGET_BUILTIN(__builtin_ia32_pavgb512_mask, "V64cV64cV64cV64cULLi", "", > "avx512bw") > -TARGET_BUILTIN(__builtin_ia32_pavgw512_mask, "V32sV32sV32sV32sUi", "", > "avx512bw") > TARGET_BUILTIN(__builtin_ia32_pmaxsb512_mask, "V64cV64cV64cV64cULLi", > "", "avx512bw") > TARGET_BUILTIN(__builtin_ia32_pmaxsw512_mask, "V32sV32sV32sV32sUi", "", > "avx512bw") > TARGET_BUILTIN(__builtin_ia32_pmaxub512_mask, "V64cV64cV64cV64cULLi", > "", "avx512bw") > > Modified: cfe/trunk/lib/Headers/avx2intrin.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ > avx2intrin.h?rev=313011&r1=313010&r2=313011&view=diff > > == > --- cfe/trunk/lib/Headers/avx2intrin.h (original) > +++ cfe/trunk/lib/Headers/avx2intrin.h Tue Sep 12 00:46:32 2017 > @@ -145,13 +145,21 @@ _mm256_andnot_si256(__m256i __a, __m256i > static __inline__ __m256i __DEFAULT_FN_ATTRS > _mm256_avg_epu8(__m256i __a, __m256i __b) > { > - return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b); > + typedef unsigned short __v32hu __attribute__((__vector_size__(64))); > + return (__m256i)__builtin_convertvector( > + ((__builtin_convertvector((__v32qu)__a, __v32hu) + > + __builtin_convertvector((__v32qu)__b, __v32hu)) + 1) > + >> 1, __v32qu); > } > > static __inline__ __m256i __DEFAULT_FN_ATTRS > _mm256_avg_epu16(__m256i __a, __m256i __b) > { > - return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b); > + typedef unsigned int __v16su __attribute__((__vector_size__(64))); > + return (__m256i)__builtin_convertvector( > + ((__builtin_convertvector((__v16hu)__a, __v16su) + > + __builtin_convertvector((__v16hu)__b, __v16su)) + 1) > + >> 1, __v16hu); > } > > static __inline__ __m256i __DEFAULT_FN_ATTRS > > Modified: cf
[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`
JonasToth reopened this revision. JonasToth added a comment. This revision is now accepted and ready to land. This Patch broke the buildbot for vs-2015. I will revert, when i figured out how to do this in svn :/ It does not emit a warning for line 311: here the log > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\tools\extra\test\clang-tidy\Output\cppcoreguidelines-owning-memory.cpp.tmp.cpp:290:3: > note: type deduction did not result in an owner > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\tools\extra\test\clang-tidy\Output\cppcoreguidelines-owning-memory.cpp.tmp.cpp:297:3: > warning: expected assignment source to be of type 'gsl::owner<>'; got > 'ArbitraryClass *' [cppcoreguidelines-owning-memory] > > Owner3 = &A;// Bad, > since assignment of non-owner to owner > ^ > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\tools\extra\test\clang-tidy\Output\cppcoreguidelines-owning-memory.cpp.tmp.cpp:343:3: > warning: expected initialization with value of type 'gsl::owner<>'; got 'int > *' [cppcoreguidelines-owning-memory] > > gsl::owner OwningPtr = Array1.data(); // Bad, since it does not > return the owner I have no idea how to debug this, since i dont have a visual studio installation, neither do i have windows. What could it be? https://reviews.llvm.org/D36354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
vivekvpandya added a comment. Why? That was inside BackendConsumer. I was getting incomplete type error. You can just save the old DiagHandler object instead. I don't think now we need to do that as per my understanding CodeGen i.e emitting LLVM IR is last phase in clang which will pass control to LLVMContext. LLVMContext will have Base class of DiagnosticHandler which will not handle diagnostic and return false so LLVMContext::diagnose() will print diagnostic with DiagnosticPrinterRawOStream DP(errs()); errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; DI.print(DP); errs() << "\n"; and clang's diagnostic handler also does similar thing so if we keep ClangDiagnosticHandler pointer in LLVMContext it should not break. https://reviews.llvm.org/D37196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33514: [WIP] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
vivekvpandya updated this revision to Diff 114869. vivekvpandya marked 3 inline comments as done. vivekvpandya added a comment. Update. https://reviews.llvm.org/D33514 Files: include/llvm/Analysis/OptimizationDiagnosticInfo.h include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h include/llvm/IR/DiagnosticHandler.h include/llvm/IR/DiagnosticInfo.h include/llvm/IR/LLVMContext.h include/llvm/LTO/Config.h include/llvm/LTO/legacy/LTOCodeGenerator.h lib/IR/CMakeLists.txt lib/IR/Core.cpp lib/IR/DiagnosticHandler.cpp lib/IR/DiagnosticInfo.cpp lib/IR/LLVMContext.cpp lib/IR/LLVMContextImpl.cpp lib/IR/LLVMContextImpl.h lib/LTO/LTOCodeGenerator.cpp lib/Transforms/Scalar/GVN.cpp lib/Transforms/Vectorize/LoopVectorize.cpp test/Transforms/GVN/opt-remarks.ll tools/llc/llc.cpp tools/llvm-dis/llvm-dis.cpp tools/llvm-link/llvm-link.cpp tools/llvm-lto/llvm-lto.cpp tools/lto/lto.cpp Index: tools/lto/lto.cpp === --- tools/lto/lto.cpp +++ tools/lto/lto.cpp @@ -75,20 +75,23 @@ static LLVMContext *LTOContext = nullptr; -static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { - if (DI.getSeverity() != DS_Error) { -DiagnosticPrinterRawOStream DP(errs()); -DI.print(DP); -errs() << '\n'; -return; - } - sLastErrorString = ""; - { -raw_string_ostream Stream(sLastErrorString); -DiagnosticPrinterRawOStream DP(Stream); -DI.print(DP); +struct LTOToolDiagnosticHandler : public DiagnosticHandler { + bool handleDiagnostics(const DiagnosticInfo &DI) override { +if (DI.getSeverity() != DS_Error) { + DiagnosticPrinterRawOStream DP(errs()); + DI.print(DP); + errs() << '\n'; + return true; +} +sLastErrorString = ""; +{ + raw_string_ostream Stream(sLastErrorString); + DiagnosticPrinterRawOStream DP(Stream); + DI.print(DP); +} +return true; } -} +}; // Initialize the configured targets if they have not been initialized. static void lto_initialize() { @@ -108,7 +111,8 @@ static LLVMContext Context; LTOContext = &Context; -LTOContext->setDiagnosticHandler(diagnosticHandler, nullptr, true); +LTOContext->setDiagnosticHandler( +llvm::make_unique(), true); initialized = true; } } @@ -274,7 +278,8 @@ // Create a local context. Ownership will be transferred to LTOModule. std::unique_ptr Context = llvm::make_unique(); - Context->setDiagnosticHandler(diagnosticHandler, nullptr, true); + Context->setDiagnosticHandler(llvm::make_unique(), +true); ErrorOr> M = LTOModule::createInLocalContext( std::move(Context), mem, length, Options, StringRef(path)); Index: tools/llvm-lto/llvm-lto.cpp === --- tools/llvm-lto/llvm-lto.cpp +++ tools/llvm-lto/llvm-lto.cpp @@ -235,34 +235,40 @@ } static std::string CurrentActivity; -static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { - raw_ostream &OS = errs(); - OS << "llvm-lto: "; - switch (DI.getSeverity()) { - case DS_Error: -OS << "error"; -break; - case DS_Warning: -OS << "warning"; -break; - case DS_Remark: -OS << "remark"; -break; - case DS_Note: -OS << "note"; -break; - } - if (!CurrentActivity.empty()) -OS << ' ' << CurrentActivity; - OS << ": "; - - DiagnosticPrinterRawOStream DP(OS); - DI.print(DP); - OS << '\n'; - if (DI.getSeverity() == DS_Error) -exit(1); -} +namespace { + struct LLVMLTODiagnosticHandler : public DiagnosticHandler { +bool handleDiagnostics(const DiagnosticInfo &DI) override { + raw_ostream &OS = errs(); + OS << "llvm-lto: "; + switch (DI.getSeverity()) { + case DS_Error: +OS << "error"; +break; + case DS_Warning: +OS << "warning"; +break; + case DS_Remark: +OS << "remark"; +break; + case DS_Note: +OS << "note"; +break; + } + if (!CurrentActivity.empty()) +OS << ' ' << CurrentActivity; + OS << ": "; + + DiagnosticPrinterRawOStream DP(OS); + DI.print(DP); + OS << '\n'; + + if (DI.getSeverity() == DS_Error) +exit(1); + return true; +} + }; + } static void error(const Twine &Msg) { errs() << "llvm-lto: " << Msg << '\n'; @@ -293,7 +299,8 @@ Buffer = std::move(BufferOrErr.get()); CurrentActivity = ("loading file '" + Path + "'").str(); std::unique_ptr Context = llvm::make_unique(); - Context->setDiagnosticHandler(diagnosticHandler, nullptr, true); + Context->setDiagnosticHandler(llvm::make_unique(), +true); ErrorOr> Ret = LTOModule::createInLocalContext( std::move(Context), Buffer->getBufferStart(), Buffer->getBufferSize(), Options, Path); @@ -837,7 +844,8 @@ unsigned BaseArg = 0; LLVMContext Context; -
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
aaron.ballman added a comment. In https://reviews.llvm.org/D37436#868295, @hfinkel wrote: > In https://reviews.llvm.org/D37436#867965, @aaron.ballman wrote: > > > In https://reviews.llvm.org/D37436#867287, @rsmith wrote: > > > > > If this is just supposed to be an experiment to get feedback on the > > > feature, then I don't think we should be treating it as a different > > > attribute syntax at all. Rather, I think we > > > just want to permit C++11 attributes to be parsed in other language > > > modes. If/when this becomes part of some future C working draft, I think > > > that's the time to have a > > > separate attribute syntax with a distinct set of valid unqualified > > > attribute names. > > > > > > I do not think that's the correct approach. These are not C++ attributes > > (for instance, no `using` insanity is allowed, `::` is a new lexing token > > in C, etc). Also, I don't think it's a good idea to enable all C++11-style > > attributes in C mode without giving each attribute some appropriate thought > > (what does `abi_tag` *do* in C mode? What happens with _Noreturn vs > > [[noreturn]] etc). Also, I'm not comfortable adding a bunch of > > vendor-specific `gnu::` attributes that GCC does not implement in C yet. > > > On this last point, I disagree. Implementation experience is about all of the > messy things that occur in production. In production, if we have this syntax, > then we'll end up enabling it for a bunch of vendor-specific attributes. Do > you think that we wouldn't? I'm sure we would. Also, FWIW, I was planning to traverse the attributes we implement to find which clang-specific C++ attributes would make sense to also enable as a follow-up patch once the syntax is in. > N2137 specifically talks about this as a use case. If so, this will include > `gnu::` attributes that we have in Clang (even if GCC does not implement > them). Eventually, yes, but it seems like a problem to implement something under that vendor namespace when the vendor themselves do not. I think it would be really unfortunate were GCC to add a C++ attribute named [[clang::frobble]] that Clang does not implement, and I don't see this case as being all that different. My belief is that GCC will eventually elect to make most of these attributes available in C mode and that's an appropriate time for us to do the same for their vendor namespace. > From my perspective, lack of consistency here between Clang's C and C++ modes > is much more problematic than a lack of consistency between what Clang and > GCC implement. From my perspective, they're both problems in their own right. To me (and maybe I'm weird with this line of reasoning), the only reasonable time to implement an attribute under another vendor's attribute namespace is when you are promising your users that you will attempt to match the owning vendor's semantics for that attribute. A case could be made here that the owning vendor *has* implemented that attribute (since they have in C++), but I'm not too comfortable *assuming* that the GCC folks are okay with this since they don't implement the feature syntax in C yet. That said, I'm happy to ask Jason at the meetings in Albuquerque to explore the idea -- but I don't think it should hold up this patch, especially since we have our own vendor attributes we can use for gaining experience. https://reviews.llvm.org/D37436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r313059 - [clang-tidy] Revert Implement type-based check for gsl::owner
Author: jonastoth Date: Tue Sep 12 11:35:54 2017 New Revision: 313059 URL: http://llvm.org/viewvc/llvm-project?rev=313059&view=rev Log: [clang-tidy] Revert Implement type-based check for gsl::owner This should unbreak the buildbot for visual studio 2015 for now. Removed: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-owning-memory.cpp Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tools-extra/trunk/clang-tidy/utils/Matchers.h clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=313059&r1=313058&r2=313059&view=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Tue Sep 12 11:35:54 2017 @@ -4,7 +4,6 @@ add_clang_library(clangTidyCppCoreGuidel CppCoreGuidelinesTidyModule.cpp InterfacesGlobalInitCheck.cpp NoMallocCheck.cpp - OwningMemoryCheck.cpp ProBoundsArrayToPointerDecayCheck.cpp ProBoundsConstantArrayIndexCheck.cpp ProBoundsPointerArithmeticCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=313059&r1=313058&r2=313059&view=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp Tue Sep 12 11:35:54 2017 @@ -13,7 +13,6 @@ #include "../misc/UnconventionalAssignOperatorCheck.h" #include "InterfacesGlobalInitCheck.h" #include "NoMallocCheck.h" -#include "OwningMemoryCheck.h" #include "ProBoundsArrayToPointerDecayCheck.h" #include "ProBoundsConstantArrayIndexCheck.h" #include "ProBoundsPointerArithmeticCheck.h" @@ -38,8 +37,6 @@ public: CheckFactories.registerCheck( "cppcoreguidelines-interfaces-global-init"); CheckFactories.registerCheck("cppcoreguidelines-no-malloc"); -CheckFactories.registerCheck( -"cppcoreguidelines-owning-memory"); CheckFactories.registerCheck( "cppcoreguidelines-pro-bounds-array-to-pointer-decay"); CheckFactories.registerCheck( Removed: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp?rev=313058&view=auto == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp (removed) @@ -1,315 +0,0 @@ -//===--- OwningMemoryCheck.cpp - clang-tidy===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#include "OwningMemoryCheck.h" -#include "../utils/Matchers.h" -#include "../utils/OptionsUtils.h" -#include "clang/AST/ASTContext.h" -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include -#include - -using namespace clang::ast_matchers; -using namespace clang::ast_matchers::internal; - -namespace clang { -namespace tidy { -namespace cppcoreguidelines { - -/// Match common cases, where the owner semantic is relevant, like function -/// calls, delete expressions and others. -void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { - if (!getLangOpts().CPlusPlus11) -return; - - const auto OwnerDecl = typeAliasTemplateDecl(hasName("::gsl::owner")); - const auto IsOwnerType = hasType(OwnerDecl); - const auto CreatesOwner = - anyOf(cxxNewExpr(), callExpr(callee(functionDecl( - returns(qualType(hasDeclaration(OwnerDecl))); - const auto ConsideredOwner = anyOf(IsOwnerType, CreatesOwner); - - // Find delete expressions that delete non-owners. - Finder->addMatcher( - cxxDeleteExpr( - hasDescendant( - declRefExpr(unless(ConsideredOwner)).bind("deleted_variab
r313060 - clang-format-vs: Update the VSIX ID.
Author: hans Date: Tue Sep 12 11:38:34 2017 New Revision: 313060 URL: http://llvm.org/viewvc/llvm-project?rev=313060&view=rev Log: clang-format-vs: Update the VSIX ID. We're moving the extension to a new account on the VS Marketplace, and apparently it's not possible to re-upload an extension with an existing ID on a new account. Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in?rev=313060&r1=313059&r2=313060&view=diff == --- cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in (original) +++ cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Tue Sep 12 11:38:34 2017 @@ -1,7 +1,7 @@  http://schemas.microsoft.com/developer/vsx-schema/2011"; xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011";> - + ClangFormat A tool to format C/C++/Obj-C code. http://clang.llvm.org/docs/ClangFormat.html ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits