[PATCH] D37668: [X86][intrinsics] lower _mm[256|512]_mask[z]_set1_epi[8|16|32|64] intrinsic to IR
jina.nahias 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") craig.topper wrote: > I think you patch removed the only use of > __builtin_ia32_pbroadcastq512_mem_mask right? Does your change work properly > in 32-bit mode? yes for both of the questions, i have deleted __builtin_ia32_pbroadcastq512_mem_mask you can see it in the new update. 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
ilya-biryukov added a comment. In https://reviews.llvm.org/D37101#868207, @rwols wrote: > 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. Sounds good. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313128 - clang/lib/Driver/ToolChains/Darwin.h: Add proper style to comments. [-Wdocumentation]
Author: chapuni Date: Wed Sep 13 00:58:46 2017 New Revision: 313128 URL: http://llvm.org/viewvc/llvm-project?rev=313128&view=rev Log: clang/lib/Driver/ToolChains/Darwin.h: Add proper style to comments. [-Wdocumentation] Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=313128&r1=313127&r2=313128&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.h (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.h Wed Sep 13 00:58:46 2017 @@ -174,16 +174,16 @@ public: /// Options to control how a runtime library is linked. enum RuntimeLinkOptions : unsigned { -// Link the library in even if it can't be found in the VFS. +/// Link the library in even if it can't be found in the VFS. RLO_AlwaysLink = 1 << 0, -// Use the embedded runtime from the macho_embedded directory. +/// Use the embedded runtime from the macho_embedded directory. RLO_IsEmbedded = 1 << 1, -// Emit rpaths for @executable_path as well as the resource directory. +/// Emit rpaths for @executable_path as well as the resource directory. RLO_AddRPath = 1 << 2, -//< Link the library in before any others. +/// Link the library in before any others. RLO_FirstLink = 1 << 3, }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37795: SplitEmptyFunction should be true in the Mozilla coding style
sylvestre.ledru created this revision. Herald added a subscriber: klimek. As defined here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes See for the downstream bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1399359 https://reviews.llvm.org/D37795 Files: lib/Format/Format.cpp Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -515,7 +515,7 @@ Expanded.BraceWrapping.AfterFunction = true; Expanded.BraceWrapping.AfterStruct = true; Expanded.BraceWrapping.AfterUnion = true; -Expanded.BraceWrapping.SplitEmptyFunction = false; +Expanded.BraceWrapping.SplitEmptyFunction = true; Expanded.BraceWrapping.SplitEmptyRecord = false; break; case FormatStyle::BS_Stroustrup: Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -515,7 +515,7 @@ Expanded.BraceWrapping.AfterFunction = true; Expanded.BraceWrapping.AfterStruct = true; Expanded.BraceWrapping.AfterUnion = true; -Expanded.BraceWrapping.SplitEmptyFunction = false; +Expanded.BraceWrapping.SplitEmptyFunction = true; Expanded.BraceWrapping.SplitEmptyRecord = false; break; case FormatStyle::BS_Stroustrup: ___ 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 updated this revision to Diff 114998. SjoerdMeijer added a comment. Fixed the typos, and added tests. https://reviews.llvm.org/D34695 Files: lib/Frontend/InitPreprocessor.cpp lib/Headers/float.h test/Headers/float16.c test/Preprocessor/init.c Index: test/Preprocessor/init.c === --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -301,6 +301,20 @@ // AARCH64:#define __DBL_MIN_EXP__ (-1021) // AARCH64:#define __DBL_MIN__ 2.2250738585072014e-308 // AARCH64:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ +// AARCH64:#define __FLT16_DECIMAL_DIG__ 5 +// AARCH64:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16 +// AARCH64:#define __FLT16_DIG__ 3 +// AARCH64:#define __FLT16_EPSILON__ 9.765625e-4F16 +// AARCH64:#define __FLT16_HAS_DENORM__ 1 +// AARCH64:#define __FLT16_HAS_INFINITY__ 1 +// AARCH64:#define __FLT16_HAS_QUIET_NAN__ 1 +// AARCH64:#define __FLT16_MANT_DIG__ 11 +// AARCH64:#define __FLT16_MAX_10_EXP__ 4 +// AARCH64:#define __FLT16_MAX_EXP__ 15 +// AARCH64:#define __FLT16_MAX__ 6.5504e+4F16 +// AARCH64:#define __FLT16_MIN_10_EXP__ (-13) +// AARCH64:#define __FLT16_MIN_EXP__ (-14) +// AARCH64:#define __FLT16_MIN__ 6.103515625e-5F16 // AARCH64:#define __FLT_DENORM_MIN__ 1.40129846e-45F // AARCH64:#define __FLT_DIG__ 6 // AARCH64:#define __FLT_EPSILON__ 1.19209290e-7F @@ -9071,7 +9085,7 @@ // WEBASSEMBLY32-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // WEBASSEMBLY32-NOT:#define __ELF__ // WEBASSEMBLY32-NEXT:#define __FINITE_MATH_ONLY__ 0 -// WEBASSEMBLY32-NEXT:#define __FLT_DECIMAL_DIG__ 9 +// WEBASSEMBLY32:#define __FLT_DECIMAL_DIG__ 9 // WEBASSEMBLY32-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F // WEBASSEMBLY32-NEXT:#define __FLT_DIG__ 6 // WEBASSEMBLY32-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F @@ -9402,7 +9416,7 @@ // WEBASSEMBLY64-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // WEBASSEMBLY64-NOT:#define __ELF__ // WEBASSEMBLY64-NEXT:#define __FINITE_MATH_ONLY__ 0 -// WEBASSEMBLY64-NEXT:#define __FLT_DECIMAL_DIG__ 9 +// WEBASSEMBLY64:#define __FLT_DECIMAL_DIG__ 9 // WEBASSEMBLY64-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F // WEBASSEMBLY64-NEXT:#define __FLT_DIG__ 6 // WEBASSEMBLY64-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F Index: test/Headers/float16.c === --- /dev/null +++ test/Headers/float16.c @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s +// expected-no-diagnostics + +#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include + +#ifndef FLT16_MIN_10_EXP +#error "Macro FLT16_MIN_10_EXP is missing." +#elif FLT16_MIN_10_EXP > -13 +#error "Macro FLT16_MIN_10_EXP is invalid." +#endif + +_Static_assert(FLT16_MIN_10_EXP == __FLT16_MIN_10_EXP__, ""); + +#ifndef FLT16_MIN_EXP +#error "Macro FLT16_MIN_EXP is missing." +#elif FLT16_MIN_EXP > -14 +#error "Macro FLT16_MIN_EXP is invalid." +#endif + +_Static_assert(FLT16_MIN_EXP == __FLT16_MIN_EXP__, ""); + +#ifndef FLT16_MAX_10_EXP +#error "Macro FLT16_MAX_10_EXP is missing." +#elif FLT16_MAX_10_EXP < 4 +#error "Macro FLT16_MAX_10_EXP is invalid." +#endif + +_Static_assert(FLT16_MAX_10_EXP == __FLT16_MAX_10_EXP__, ""); + +#ifndef FLT16_MAX_EXP +#error "Macro FLT16_MAX_EXP is missing." +#elif FLT16_MAX_EXP < 15 +#error "Macro FLT16_MAX_EXP is invalid." +#endif + +_Static_assert(FLT16_MAX_EXP == __FLT16_MAX_EXP__, ""); + +#ifndef FLT16_DECIMAL_DIG +#error "Macro FLT16_DECIMAL_DIG is missing." +#elif FLT16_DECIMAL_DIG < 5 +#error "Macro FLT16_DECIMAL_DIG is invalid." +#endif + +_Static_assert(FLT16_DECIMAL_DIG == __FLT16_DECIMAL_DIG__, ""); + +#ifndef FLT16_DIG +#error "Macro FLT16_DIG is missing." +#elif FLT16_DIG < 3 +#error "Macro FLT16_DIG is invalid." +#endif + +_Static_assert(FLT16_DIG == __FLT16_DIG__, ""); + +#ifndef FLT16_MANT_DIG +#error "Macro FLT16_MANT_DIG is missing." +#elif FLT16_MANT_DIG < 11 +#error "Macro FLT16_MANT_DIG is invalid." +#endif + +_Static_assert(FLT16_MANT_DIG == __FLT16_MANT_DIG__, ""); + Index: lib/Headers/float.h === --- lib/Headers/float.h +++ lib/Headers/float.h @@ -143,4 +143,18 @@ # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ #endif +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG__FLT16_MANT_DIG__ +# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ +# define FLT16_DIG __FLT16_DIG__ +# define FLT16_MIN_EXP __FLT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ +# define FLT16_MAX_EXP __FLT16_MAX_EXP__ +# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ +# define FLT16_MAX __FLT16_MAX
r313133 - [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang)
Author: uriel.k Date: Wed Sep 13 02:02:02 2017 New Revision: 313133 URL: http://llvm.org/viewvc/llvm-project?rev=313133&view=rev Log: [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang) This patch, together with a matching llvm patch (https://reviews.llvm.org/D37693), implements the lowering of X86 ABS intrinsics to IR. Differential Revision: https://reviews.llvm.org/D37694 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/avx2-builtins.c cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c cfe/trunk/test/CodeGen/ssse3-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=313133&r1=313132&r2=313133&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Sep 13 02:02:02 2017 @@ -7331,6 +7331,18 @@ static Value *EmitX86MaskedCompare(CodeG std::max(NumElts, 8U))); } +static Value *EmitX86Abs(CodeGenFunction &CGF, ArrayRef Ops) { + + llvm::Type *Ty = Ops[0]->getType(); + Value *Zero = llvm::Constant::getNullValue(Ty); + Value *Sub = CGF.Builder.CreateSub(Zero, Ops[0]); + Value *Cmp = CGF.Builder.CreateICmp(ICmpInst::ICMP_SGT, Ops[0], Zero); + Value *Res = CGF.Builder.CreateSelect(Cmp, Ops[0], Sub); + if (Ops.size() == 1) +return Res; + return EmitX86Select(CGF, Ops[2], Res, Ops[1]); +} + static Value *EmitX86MinMax(CodeGenFunction &CGF, ICmpInst::Predicate Pred, ArrayRef Ops) { Value *Cmp = CGF.Builder.CreateICmp(Pred, Ops[0], Ops[1]); @@ -8025,6 +8037,20 @@ Value *CodeGenFunction::EmitX86BuiltinEx Ops[1]); } + case X86::BI__builtin_ia32_pabsb128: + case X86::BI__builtin_ia32_pabsw128: + case X86::BI__builtin_ia32_pabsd128: + case X86::BI__builtin_ia32_pabsb256: + case X86::BI__builtin_ia32_pabsw256: + case X86::BI__builtin_ia32_pabsd256: + case X86::BI__builtin_ia32_pabsq128_mask: + case X86::BI__builtin_ia32_pabsq256_mask: + case X86::BI__builtin_ia32_pabsb512_mask: + case X86::BI__builtin_ia32_pabsw512_mask: + case X86::BI__builtin_ia32_pabsd512_mask: + case X86::BI__builtin_ia32_pabsq512_mask: +return EmitX86Abs(*this, Ops); + case X86::BI__builtin_ia32_pmaxsb128: case X86::BI__builtin_ia32_pmaxsw128: case X86::BI__builtin_ia32_pmaxsd128: Modified: cfe/trunk/test/CodeGen/avx2-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx2-builtins.c?rev=313133&r1=313132&r2=313133&view=diff == --- cfe/trunk/test/CodeGen/avx2-builtins.c (original) +++ cfe/trunk/test/CodeGen/avx2-builtins.c Wed Sep 13 02:02:02 2017 @@ -8,19 +8,25 @@ __m256i test_mm256_abs_epi8(__m256i a) { // CHECK-LABEL: test_mm256_abs_epi8 - // CHECK: call <32 x i8> @llvm.x86.avx2.pabs.b(<32 x i8> %{{.*}}) + // CHECK: [[SUB:%.*]] = sub <32 x i8> zeroinitializer, %{{.*}} + // CHECK: [[CMP:%.*]] = icmp sgt <32 x i8> %{{.*}}, zeroinitializer + // CHECK: select <32 x i1> [[CMP]], <32 x i8> %{{.*}}, <32 x i8> [[SUB]] return _mm256_abs_epi8(a); } __m256i test_mm256_abs_epi16(__m256i a) { // CHECK-LABEL: test_mm256_abs_epi16 - // CHECK: call <16 x i16> @llvm.x86.avx2.pabs.w(<16 x i16> %{{.*}}) + // CHECK: [[SUB:%.*]] = sub <16 x i16> zeroinitializer, %{{.*}} + // CHECK: [[CMP:%.*]] = icmp sgt <16 x i16> %{{.*}}, zeroinitializer + // CHECK: select <16 x i1> [[CMP]], <16 x i16> %{{.*}}, <16 x i16> [[SUB]] return _mm256_abs_epi16(a); } __m256i test_mm256_abs_epi32(__m256i a) { // CHECK-LABEL: test_mm256_abs_epi32 - // CHECK: call <8 x i32> @llvm.x86.avx2.pabs.d(<8 x i32> %{{.*}}) + // CHECK: [[SUB:%.*]] = sub <8 x i32> zeroinitializer, %{{.*}} + // CHECK: [[CMP:%.*]] = icmp sgt <8 x i32> %{{.*}}, zeroinitializer + // CHECK: select <8 x i1> [[CMP]], <8 x i32> %{{.*}}, <8 x i32> [[SUB]] return _mm256_abs_epi32(a); } Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=313133&r1=313132&r2=313133&view=diff == --- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original) +++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Wed Sep 13 02:02:02 2017 @@ -480,32 +480,48 @@ __m512i test_mm512_mask_blend_epi16(__mm } __m512i test_mm512_abs_epi8(__m512i __A) { // CHECK-LABEL: @test_mm512_abs_epi8 - // CHECK: @llvm.x86.avx512.mask.pabs.b.512 + // CHECK: [[SUB:%.*]] = sub <64 x i8> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <64 x i8> [[A]], zeroinitializer + // CHECK: select <64 x i1> [[CMP]], <64
[PATCH] D37694: [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang)
This revision was automatically updated to reflect the committed changes. Closed by commit rL313133: [X86] [PATCH] [intrinsics] Lowering X86 ABS intrinsics to IR. (clang) (authored by uriel.k). Changed prior to commit: https://reviews.llvm.org/D37694?vs=114613&id=115001#toc Repository: rL LLVM https://reviews.llvm.org/D37694 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/avx2-builtins.c cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c cfe/trunk/test/CodeGen/ssse3-builtins.c Index: cfe/trunk/test/CodeGen/avx512f-builtins.c === --- cfe/trunk/test/CodeGen/avx512f-builtins.c +++ cfe/trunk/test/CodeGen/avx512f-builtins.c @@ -8044,28 +8044,40 @@ __m512i test_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A) { // CHECK-LABEL: @test_mm512_mask_abs_epi64 - // CHECK: @llvm.x86.avx512.mask.pabs.q.512 + // CHECK: [[SUB:%.*]] = sub <8 x i64> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <8 x i64> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <8 x i1> [[CMP]], <8 x i64> [[A]], <8 x i64> [[SUB]] + // CHECK: select <8 x i1> %{{.*}}, <8 x i64> [[SEL]], <8 x i64> %{{.*}} return _mm512_mask_abs_epi64 (__W,__U,__A); } __m512i test_mm512_maskz_abs_epi64 (__mmask8 __U, __m512i __A) { // CHECK-LABEL: @test_mm512_maskz_abs_epi64 - // CHECK: @llvm.x86.avx512.mask.pabs.q.512 + // CHECK: [[SUB:%.*]] = sub <8 x i64> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <8 x i64> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <8 x i1> [[CMP]], <8 x i64> [[A]], <8 x i64> [[SUB]] + // CHECK: select <8 x i1> %{{.*}}, <8 x i64> [[SEL]], <8 x i64> %{{.*}} return _mm512_maskz_abs_epi64 (__U,__A); } __m512i test_mm512_mask_abs_epi32 (__m512i __W, __mmask16 __U, __m512i __A) { // CHECK-LABEL: @test_mm512_mask_abs_epi32 - // CHECK: @llvm.x86.avx512.mask.pabs.d.512 + // CHECK: [[SUB:%.*]] = sub <16 x i32> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <16 x i32> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i32> [[A]], <16 x i32> [[SUB]] + // CHECK: select <16 x i1> %{{.*}}, <16 x i32> [[SEL]], <16 x i32> %{{.*}} return _mm512_mask_abs_epi32 (__W,__U,__A); } __m512i test_mm512_maskz_abs_epi32 (__mmask16 __U, __m512i __A) { // CHECK-LABEL: @test_mm512_maskz_abs_epi32 - // CHECK: @llvm.x86.avx512.mask.pabs.d.512 + // CHECK: [[SUB:%.*]] = sub <16 x i32> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <16 x i32> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <16 x i1> [[CMP]], <16 x i32> [[A]], <16 x i32> [[SUB]] + // CHECK: select <16 x i1> %{{.*}}, <16 x i32> [[SEL]], <16 x i32> %{{.*}} return _mm512_maskz_abs_epi32 (__U,__A); } Index: cfe/trunk/test/CodeGen/avx512vl-builtins.c === --- cfe/trunk/test/CodeGen/avx512vl-builtins.c +++ cfe/trunk/test/CodeGen/avx512vl-builtins.c @@ -2502,56 +2502,82 @@ } __m128i test_mm_mask_abs_epi32(__m128i __W, __mmask8 __U, __m128i __A) { // CHECK-LABEL: @test_mm_mask_abs_epi32 - // CHECK: @llvm.x86.ssse3.pabs.d.128 - // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}} + // CHECK: [[SUB:%.*]] = sub <4 x i32> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <4 x i32> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <4 x i1> [[CMP]], <4 x i32> [[A]], <4 x i32> [[SUB]] + // CHECK: select <4 x i1> %{{.*}}, <4 x i32> [[SEL]], <4 x i32> %{{.*}} return _mm_mask_abs_epi32(__W,__U,__A); } __m128i test_mm_maskz_abs_epi32(__mmask8 __U, __m128i __A) { // CHECK-LABEL: @test_mm_maskz_abs_epi32 - // CHECK: @llvm.x86.ssse3.pabs.d.128 - // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}} + // CHECK: [[SUB:%.*]] = sub <4 x i32> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <4 x i32> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <4 x i1> [[CMP]], <4 x i32> [[A]], <4 x i32> [[SUB]] + // CHECK: select <4 x i1> %{{.*}}, <4 x i32> [[SEL]], <4 x i32> %{{.*}} return _mm_maskz_abs_epi32(__U,__A); } __m256i test_mm256_mask_abs_epi32(__m256i __W, __mmask8 __U, __m256i __A) { // CHECK-LABEL: @test_mm256_mask_abs_epi32 - // CHECK: @llvm.x86.avx2.pabs.d - // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}} + // CHECK: [[SUB:%.*]] = sub <8 x i32> zeroinitializer, [[A:%.*]] + // CHECK: [[CMP:%.*]] = icmp sgt <8 x i32> [[A]], zeroinitializer + // CHECK: [[SEL:%.*]] = select <8 x i1> [[CMP]], <8 x i32> [[A]], <8 x i32> [[SUB]] + // CHECK: select <8 x i1> %{{.*}}, <8 x i32> [[SEL]], <8 x i32> %{{.*}} return _mm256_mask_abs_epi32(__W,__U,__A); } __m256i test_mm256_maskz_abs_epi32(__mmask8 __U, __m256i __A) { // CHEC
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
hfinkel added a comment. In https://reviews.llvm.org/D37436#868333, @aaron.ballman wrote: > 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. I certainly understand your perspective, but this is an orthogonal concern. If this is something that Clang does, then it should do it consistently. If you'd like us not to support `gnu::` attributes that GCC itself does not support, and that's something that we currently do in C++, then please submit a patch to fix that for all language modes. It should not differ between language modes. Is the problem here that we're treating `gnu::`, not as a vendor prefix, but as generic escape hatch to get to anything generally provided via GCC-attribute syntax (which many compilers, including ours, have extended with attributes that GCC does not itself support)? https://reviews.llvm.org/D37436 ___ 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. Also, please post a full-context patch. https://reviews.llvm.org/D37436 ___ 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
krasimir added a comment. Patch looks good, but I also would like to see it splited. I would suggest to first get the statement macro part in, which requires less code. Then we can put the namespace macros on top of that. I really like the generality of this approach and would want to also add support for `class` macros eventually. Comment at: lib/Format/FormatTokenLexer.cpp:641 +auto it = std::find(Macros.begin(), Macros.end(), +FormatTok->Tok.getIdentifierInfo()); if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() && Please move this inside the following `if` statement, so that we only perform the search when we see a `tok::pp_define`. Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:56 +assert(Tok && Tok->is(tok::l_paren) && "expected an opening parenthesis"); +Tok = Tok ? Tok->getNextNonComment() : nullptr; +while (Tok && !Tok->isOneOf(tok::r_paren, tok::comma)) { I don't understand why you have a `Tok ? ...` after you `assert(Tok && ...)`? Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:82 +text += ")"; + // close brace if (AddNewline) What does this comment refer to? If it's about the line above, consider moving it up. Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:100 +StringRef NamespaceTokenText = Groups.size() > 4 ? Groups[4] : ""; +// The name of the macro must be used +if (NamespaceTokenText != NamespaceTok->TokenText) nit: end comment with `.` Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:105 + !kNamespaceCommentPattern.match(Comment->TokenText, &Groups)) { +// Comment does not match regex +return false; nit: end comment with `.` Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:155 const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First; - // Detect "(inline)? namespace" in the beginning of a line. - if (NamespaceTok->is(tok::kw_inline)) -NamespaceTok = NamespaceTok->getNextNonComment(); - if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace)) -return nullptr; - return NamespaceTok; + return NamespaceTok->getNamespaceToken(); +} What happened to the old `// Detect "(inline)? namespace" in the beginning of a line.` Comment at: unittests/Format/FormatTest.cpp:1588 + Style.NamespaceIndentation = FormatStyle::NI_All; + verifyFormat("TESTSUITE(A) {\n" + " int foo();\n" Hm, what would happen if you have a namespace macro with two or more parameters? https://reviews.llvm.org/D33440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313141 - [OPENMP] Allow all classes as mappable types.
Author: abataev Date: Wed Sep 13 04:12:35 2017 New Revision: 313141 URL: http://llvm.org/viewvc/llvm-project?rev=313141&view=rev Log: [OPENMP] Allow all classes as mappable types. According to upcoming OpenMP 5.0 all classes/structs are now considered as mappable, even polymorphic and with static members. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/declare_target_messages.cpp cfe/trunk/test/OpenMP/target_map_messages.cpp cfe/trunk/test/OpenMP/target_parallel_for_map_messages.cpp cfe/trunk/test/OpenMP/target_parallel_for_simd_map_messages.cpp cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp cfe/trunk/test/OpenMP/target_simd_map_messages.cpp cfe/trunk/test/OpenMP/target_teams_distribute_map_messages.cpp cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp cfe/trunk/test/OpenMP/target_teams_distribute_simd_map_messages.cpp cfe/trunk/test/OpenMP/target_teams_map_messages.cpp cfe/trunk/test/OpenMP/target_update_from_messages.cpp cfe/trunk/test/OpenMP/target_update_to_messages.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313141&r1=313140&r2=313141&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 13 04:12:35 2017 @@ -8837,16 +8837,10 @@ def err_omp_expected_base_var_name : Err "expected variable name as a base of the array %select{subscript|section}0">; def err_omp_map_shared_storage : Error< "variable already marked as mapped in current construct">; -def err_omp_not_mappable_type : Error< - "type %0 is not mappable to target">; def err_omp_invalid_map_type_for_directive : Error< "%select{map type '%1' is not allowed|map type must be specified}0 for '#pragma omp %2'">; def err_omp_no_clause_for_directive : Error< "expected at least one %0 clause for '#pragma omp %1'">; -def note_omp_polymorphic_in_target : Note< - "mappable type cannot be polymorphic">; -def note_omp_static_member_in_target : Note< - "mappable type cannot contain static members">; def err_omp_threadprivate_in_clause : Error< "threadprivate variables are not allowed in '%0' clause">; def err_omp_wrong_ordered_loop_count : Error< Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=313141&r1=313140&r2=313141&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Sep 13 04:12:35 2017 @@ -10574,56 +10574,12 @@ OMPClause *Sema::ActOnOpenMPDeviceClause return new (Context) OMPDeviceClause(ValExpr, StartLoc, LParenLoc, EndLoc); } -static bool IsCXXRecordForMappable(Sema &SemaRef, SourceLocation Loc, - DSAStackTy *Stack, CXXRecordDecl *RD) { - if (!RD || RD->isInvalidDecl()) -return true; - - auto QTy = SemaRef.Context.getRecordType(RD); - if (RD->isDynamicClass()) { -SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; -SemaRef.Diag(RD->getLocation(), diag::note_omp_polymorphic_in_target); -return false; - } - auto *DC = RD; - bool IsCorrect = true; - for (auto *I : DC->decls()) { -if (I) { - if (auto *MD = dyn_cast(I)) { -if (MD->isStatic()) { - SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; - SemaRef.Diag(MD->getLocation(), - diag::note_omp_static_member_in_target); - IsCorrect = false; -} - } else if (auto *VD = dyn_cast(I)) { -if (VD->isStaticDataMember()) { - SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; - SemaRef.Diag(VD->getLocation(), - diag::note_omp_static_member_in_target); - IsCorrect = false; -} - } -} - } - - for (auto &I : RD->bases()) { -if (!IsCXXRecordForMappable(SemaRef, I.getLocStart(), Stack, -I.getType()->getAsCXXRecordDecl())) - IsCorrect = false; - } - return IsCorrect; -} - static bool CheckTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef, DSAStackTy *Stack, QualType QTy) { NamedDecl *ND; if (QTy->isIncompleteType(&ND)) { SemaRef.Diag(SL, diag::err_incomplete_type) << QTy << SR; return false; - } else if (CXXRecordDecl *RD = dyn_cast_or_null(ND)) { -if (!RD->isInvalidDecl() && !IsCXXRecordForMappable(SemaRef, SL, Stack, RD)) - return false; } return true; } Modified: cfe/trunk/test/OpenMP/declare_target_messages.
RE: r313011 - [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR
Hello Galina, I tried to re-create the issue but with no success. I ran the test on versions before and after my commit, using your builder’s cmake properties, and the test passed each time. There doesn’t seem to be a connection between my commit’s changes and the failed test. We checked the test’s history and the message in https://reviews.llvm.org/rL259715 suggests that the last time this test was modified, there were buildbots failures – could those failures be related or similar to the failures we are seeing now? I’ve CC’d Ben Langmuir and Quentin Colombet as they dealt with rL259715. Is there anyone who could help or provide more details about the test failure? Thanks, Yael From: Galina Kistanova [mailto:gkistan...@gmail.com] Sent: Tuesday, September 12, 2017 21:16 To: Tsafrir, Yael Cc: cfe-commits Subject: 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 mailto: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__((__ve
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
aaron.ballman added a comment. In https://reviews.llvm.org/D37436#869350, @hfinkel wrote: > In https://reviews.llvm.org/D37436#868333, @aaron.ballman wrote: > > > 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. > > > I certainly understand your perspective, but this is an orthogonal concern. > If this is something that Clang does, then it should do it consistently. If > you'd like us not to support `gnu::` attributes that GCC itself does not > support, and that's something that we currently do in C++, then please submit > a patch to fix that for all language modes. It should not differ between > language modes. > > Is the problem here that we're treating `gnu::`, not as a vendor prefix, but > as generic escape hatch to get to anything generally provided via > GCC-attribute syntax (which many compilers, including ours, have extended > with attributes that GCC does not itself support)? I definitely agree that we want to be self-consistent, so thank you for helping me understand where you're coming from. I've been very consistent in rejecting patches that add C++ attributes to the gnu namespace unless GCC also implements them. This most often comes up as a misunderstanding of when to use the `GNU<>` (just provides support for `__attribute__(())`) spelling and when to use the GCC<> (provides support for both `__attribute__(())` and `[[gnu::]]`) spelling. If you know of any attributes that we've put into
[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy
mikhail.ramalho marked an inline comment as done. mikhail.ramalho added a comment. ping https://reviews.llvm.org/D36610 ___ 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 updated this revision to Diff 115015. aaron.ballman added a comment. Added full context, no other changes from previous patch. https://reviews.llvm.org/D37436 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/Attributes.h clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/AttributeList.h clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Lex/Lexer.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Parse/ParseTentative.cpp clang/lib/Sema/AttributeList.cpp clang/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp clang/test/Misc/ast-dump-c-attr.c clang/test/Parser/c2x-attributes.c clang/test/Parser/cxx0x-attributes.cpp clang/test/Sema/attr-deprecated-c2x.c clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp === --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/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)
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
hfinkel added a comment. In https://reviews.llvm.org/D37436#869445, @aaron.ballman wrote: > In https://reviews.llvm.org/D37436#869350, @hfinkel wrote: > > > In https://reviews.llvm.org/D37436#868333, @aaron.ballman wrote: > > > > > 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. > > > > > > I certainly understand your perspective, but this is an orthogonal concern. > > If this is something that Clang does, then it should do it consistently. If > > you'd like us not to support `gnu::` attributes that GCC itself does not > > support, and that's something that we currently do in C++, then please > > submit a patch to fix that for all language modes. It should not differ > > between language modes. > > > > Is the problem here that we're treating `gnu::`, not as a vendor prefix, > > but as generic escape hatch to get to anything generally provided via > > GCC-attribute syntax (which many compilers, including ours, have extended > > with attributes that GCC does not itself support)? > > > I definitely agree that we want to be self-consistent, so thank you for > helping me understand where you're coming from. > > I've been very consistent in rejecting patches that add C++ attributes to the > gnu namespace unless GCC also implements them. This most often comes up as a > misunderstan
[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)
aaron.ballman added a comment. In https://reviews.llvm.org/D37436#869462, @hfinkel wrote: > I think that I misunderstood your concern. Let me see if I can summarize your > position: You believe that, when GCC implements this syntax in C, they will > audit their attributes and not support all of their existing `gnu::` > attributes in C. You only want us to support these when we know what that > list will be (which we don't yet). Is that correct? Yes, that is correct. https://reviews.llvm.org/D37436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37663: [AST] Make RecursiveASTVisitor visit CXXOperatorCallExpr in source order
johannes updated this revision to Diff 115018. johannes added a comment. use CXXOperatorCallExpr::isPrefixOp() to determine whether it's infix or postfix directly traverse statement children instead of copying https://reviews.llvm.org/D37663 Files: include/clang/AST/ExprCXX.h include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h include/clang/AST/RecursiveASTVisitor.h lib/AST/ExprCXX.cpp Index: lib/AST/ExprCXX.cpp === --- lib/AST/ExprCXX.cpp +++ lib/AST/ExprCXX.cpp @@ -41,6 +41,12 @@ } } +bool CXXOperatorCallExpr::isPrefixOp() const { + return getNumArgs() == 1 && getOperator() != OO_Call && + getOperator() != OO_Arrow; +} + + bool CXXTypeidExpr::isPotentiallyEvaluated() const { if (isTypeOperand()) return false; Index: include/clang/AST/RecursiveASTVisitor.h === --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -315,8 +315,6 @@ // Methods on Stmts - Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } - private: template struct has_same_member_pointer_type : std::false_type {}; @@ -2080,15 +2078,26 @@ TRY_TO(WalkUpFrom##STMT(S)); \ { CODE; } \ if (ShouldVisitChildren) { \ - for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \ -TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \ + auto ChildIterator = S->child_begin(); \ + /* Make the operator come second for infix and postfix overloaded\ + * operators. */ \ + if (auto *CE = dyn_cast(S)) { \ +if (CE->isInfixBinaryOp() || !CE->isPrefixOp()) { \ + Stmt *Operator = *ChildIterator; \ + TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(*++ChildIterator); \ + TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Operator); \ + ++ChildIterator; \ +} \ + }\ + for (auto ChildEnd = S->child_end(); ChildIterator != ChildEnd; \ + ++ChildIterator) { \ +TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(*ChildIterator); \ }\ } \ if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) \ TRY_TO(WalkUpFrom##STMT(S)); \ return ReturnValue;\ } - DEF_TRAVERSE_STMT(GCCAsmStmt, { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString()); for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) { Index: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h === --- include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h +++ include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h @@ -111,33 +111,6 @@ return true; } - Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } - - SmallVector getStmtChildren(CXXOperatorCallExpr *CE) { -SmallVector Children(CE->children()); -bool Swap; -// Switch the operator and the first operand for all infix and postfix -// operations. -switch (CE->getOperator()) { -case OO_Arrow: -case OO_Call: -case OO_Subscript: - Swap = true; - break; -case OO_PlusPlus: -case OO_MinusMinus: - // These are postfix unless there is exactly one argument. - Swap = Children.size() != 2; - break; -default: - Swap = CE->isInfixBinaryOp(); - break; -} -if (Swap && Children.size() > 1) - std::swap(Children[0], Children[1]); -return Children; - } - private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the Index: include/clang/AST/ExprCXX.h === --- include/clang/AST/ExprCXX.h +++ include/clang/AST/ExprCXX.h @@ -87,6 +87,8 @@ /// \brief Is this written as an infix binary operator? bool isInfixBinaryOp() const; + bool isPrefixOp() const; + /// \brief Returns the location of the operator symbol in the expression. /// /// When \c getOperator()==O
[PATCH] D37663: [AST] Make RecursiveASTVisitor visit CXXOperatorCallExpr in source order
johannes added inline comments. Comment at: include/clang/AST/RecursiveASTVisitor.h:327 + + SmallVector getStmtChildren(CXXOperatorCallExpr *CE) { +SmallVector Children(CE->children()); rsmith wrote: > The copy here is more expensive than I'd like. Instead of returning a list of > children, please make this function *traverse* the children (which is what > its one and only caller is going to do anyway) to avoid the copy. I wasn't sure whether there is a way to do this in a function without writing a custom iterator that checks whether it should be swapped; I used a different approach. Comment at: include/clang/AST/RecursiveASTVisitor.h:334 +case OO_Arrow: +case OO_Call: +case OO_Subscript: rsmith wrote: > johannes wrote: > > klimek wrote: > > > Why do we need to swap for calls? > > The idea is that the opening parenthesis/bracket comes after the caller, > > for example in this call with two arguments. > > > > ``` > > `-CXXOperatorCallExpr > > |-ImplicitCastExpr > > | `-DeclRefExpr operator() > > |-DeclRefExpr caller > > |-IntegerLiteral > > `-IntegerLiteral > > ``` > > > > Of course we fail to capture the fact that there is also a closing > > parenthesis or bracket. So this is no perfect solution. > > Of course we fail to capture the fact that there is also a closing > > parenthesis or bracket. > > One way we could handle this would be to effectively order by the start > location for preorder traversal, and by the end location for postorder > traversal. So for a case like your `caller(1,2)`, we would visit > `CXXOperatorCallExpr`, `caller`, `operator()`, `1`, then `2` when doing > preorder visitation, and `caller`, `1`, `2`, `operator()`, then > `CXXOperatorCallExpr` when doing postorder visitation (because the notional > source location for the `operator()` invocation extends across both `1` and > `2` subexpressions). > > But I think it's probably not worthwhile to go to this level of detail, and > treating the `(` as the location of the `operator()` call and ignoring the > `)` seems like a reasonable approach to me. Yeah, we can do that if someone needs it. Another way would be to model the operator as parent of the operands, although I assume that this would not compose well. I don't expect it to be feasible but I imagine CXXOperatorCallExpr could also inherit from DeclRefExpr. https://reviews.llvm.org/D37663 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS
nik added a comment. Ping https://reviews.llvm.org/D37554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment
Anastasia created this revision. Added missing `addrspacecast` case in alignment computation logic of pointer type emission in IR generation. https://reviews.llvm.org/D37804 Files: lib/CodeGen/CGExpr.cpp test/CodeGenOpenCL/vectorLoadStore.cl Index: test/CodeGenOpenCL/vectorLoadStore.cl === --- test/CodeGenOpenCL/vectorLoadStore.cl +++ test/CodeGenOpenCL/vectorLoadStore.cl @@ -1,9 +1,23 @@ // RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s -typedef char char3 __attribute((ext_vector_type(3)));; +typedef char char2 __attribute((ext_vector_type(2))); +typedef char char3 __attribute((ext_vector_type(3))); +typedef char char8 __attribute((ext_vector_type(8))); +typedef float float4 __attribute((ext_vector_type(4))); +; // Check for optimized vec3 load/store which treats vec3 as vec4. void foo(char3 *P, char3 *Q) { *P = *Q; // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x i32> } + +// CHECK: define spir_func void @alignment() +void alignment() { + __private char2 data_generic[100]; + __private char8 data_private[100]; + + // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, align 2 + // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8 + ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2]; +} Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -924,6 +924,7 @@ // Non-converting casts (but not C's implicit conversion from void*). case CK_BitCast: case CK_NoOp: +case CK_AddressSpaceConversion: if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) { if (PtrTy->getPointeeType()->isVoidType()) break; @@ -953,7 +954,8 @@ CE->getLocStart()); } -return Builder.CreateBitCast(Addr, ConvertType(E->getType())); +return Builder.CreatePointerBitCastOrAddrSpaceCast( +Addr, ConvertType(E->getType())); } break; Index: test/CodeGenOpenCL/vectorLoadStore.cl === --- test/CodeGenOpenCL/vectorLoadStore.cl +++ test/CodeGenOpenCL/vectorLoadStore.cl @@ -1,9 +1,23 @@ // RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s -typedef char char3 __attribute((ext_vector_type(3)));; +typedef char char2 __attribute((ext_vector_type(2))); +typedef char char3 __attribute((ext_vector_type(3))); +typedef char char8 __attribute((ext_vector_type(8))); +typedef float float4 __attribute((ext_vector_type(4))); +; // Check for optimized vec3 load/store which treats vec3 as vec4. void foo(char3 *P, char3 *Q) { *P = *Q; // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x i32> } + +// CHECK: define spir_func void @alignment() +void alignment() { + __private char2 data_generic[100]; + __private char8 data_private[100]; + + // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, align 2 + // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8 + ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2]; +} Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -924,6 +924,7 @@ // Non-converting casts (but not C's implicit conversion from void*). case CK_BitCast: case CK_NoOp: +case CK_AddressSpaceConversion: if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) { if (PtrTy->getPointeeType()->isVoidType()) break; @@ -953,7 +954,8 @@ CE->getLocStart()); } -return Builder.CreateBitCast(Addr, ConvertType(E->getType())); +return Builder.CreatePointerBitCastOrAddrSpaceCast( +Addr, ConvertType(E->getType())); } break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37805: [analyzer] PthreadLock: add printState().
NoQ created this revision. The self-debugging method to add dumps of the checker's internal state to program state dumps and exploded graphs. I'm looking into enabling this checker by default, so more patches would follow. https://reviews.llvm.org/D37805 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -81,6 +81,8 @@ public: void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; + void printState(raw_ostream &Out, ProgramStateRef State, + const char *NL, const char *Sep) const override; void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, bool isTryLock, enum LockingSemantics semantics) const; @@ -184,6 +186,39 @@ return state; } +void PthreadLockChecker::printState(raw_ostream &Out, ProgramStateRef State, +const char *NL, const char *Sep) const { + LockMapTy LM = State->get(); + if (!LM.isEmpty()) { +Out << Sep << "Mutex states:" << NL; +for (auto I : LM) { + I.first->dumpToStream(Out); + if (I.second.isLocked()) +Out << ": locked"; + else if (I.second.isUnlocked()) +Out << ": unlocked"; + else if (I.second.isDestroyed()) +Out << ": destroyed"; + else if (I.second.isUntouchedAndPossiblyDestroyed()) +Out << ": not tracked, possibly destroyed"; + else if (I.second.isUnlockedAndPossiblyDestroyed()) +Out << ": unlocked, possibly destroyed"; + Out << NL; +} + } + + LockSetTy LS = State->get(); + if (!LS.isEmpty()) { +Out << Sep << "Mutex lock order:" << NL; +for (auto I: LS) { + I->dumpToStream(Out); + Out << NL; +} + } + + // TODO: Dump destroyed mutex symbols? +} + void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, bool isTryLock, enum LockingSemantics semantics) const { Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -81,6 +81,8 @@ public: void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; + void printState(raw_ostream &Out, ProgramStateRef State, + const char *NL, const char *Sep) const override; void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, bool isTryLock, enum LockingSemantics semantics) const; @@ -184,6 +186,39 @@ return state; } +void PthreadLockChecker::printState(raw_ostream &Out, ProgramStateRef State, +const char *NL, const char *Sep) const { + LockMapTy LM = State->get(); + if (!LM.isEmpty()) { +Out << Sep << "Mutex states:" << NL; +for (auto I : LM) { + I.first->dumpToStream(Out); + if (I.second.isLocked()) +Out << ": locked"; + else if (I.second.isUnlocked()) +Out << ": unlocked"; + else if (I.second.isDestroyed()) +Out << ": destroyed"; + else if (I.second.isUntouchedAndPossiblyDestroyed()) +Out << ": not tracked, possibly destroyed"; + else if (I.second.isUnlockedAndPossiblyDestroyed()) +Out << ": unlocked, possibly destroyed"; + Out << NL; +} + } + + LockSetTy LS = State->get(); + if (!LS.isEmpty()) { +Out << Sep << "Mutex lock order:" << NL; +for (auto I: LS) { + I->dumpToStream(Out); + Out << NL; +} + } + + // TODO: Dump destroyed mutex symbols? +} + void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, bool isTryLock, enum LockingSemantics semantics) const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37806: [analyzer] PthreadLock: Fix return values of XNU lock functions.
NoQ created this revision. `lck_mtx_lock()` returns `void`. The analyzer failed to model its effect because he was surprised that the return value is `Unknown`. Prepare for the aforementioned surprise and fix the tests accordingly. https://reviews.llvm.org/D37806 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -22,7 +22,9 @@ extern int pthread_mutex_trylock(pthread_mutex_t *); extern int pthread_mutex_destroy(pthread_mutex_t *); extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); -extern int lck_mtx_lock(lck_mtx_t *); -extern int lck_mtx_unlock(lck_mtx_t *); -extern int lck_mtx_try_lock(lck_mtx_t *); + +typedef int boolean_t; +extern void lck_mtx_lock(lck_mtx_t *); +extern void lck_mtx_unlock(lck_mtx_t *); +extern boolean_t lck_mtx_try_lock(lck_mtx_t *); extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -230,12 +230,6 @@ if (sym) state = resolvePossiblyDestroyedMutex(state, lockR, sym); - SVal X = state->getSVal(CE, C.getLocationContext()); - if (X.isUnknownOrUndef()) -return; - - DefinedSVal retVal = X.castAs(); - if (const LockState *LState = state->get(lockR)) { if (LState->isLocked()) { if (!BT_doublelock) @@ -258,25 +252,35 @@ ProgramStateRef lockSucc = state; if (isTryLock) { // Bifurcate the state, and allow a mode where the lock acquisition fails. -ProgramStateRef lockFail; -switch (semantics) { -case PthreadSemantics: - std::tie(lockFail, lockSucc) = state->assume(retVal); - break; -case XNUSemantics: - std::tie(lockSucc, lockFail) = state->assume(retVal); - break; -default: - llvm_unreachable("Unknown tryLock locking semantics"); +SVal RetVal = state->getSVal(CE, C.getLocationContext()); +if (auto DefinedRetVal = RetVal.getAs()) { + ProgramStateRef lockFail; + switch (semantics) { + case PthreadSemantics: +std::tie(lockFail, lockSucc) = state->assume(*DefinedRetVal); +break; + case XNUSemantics: +std::tie(lockSucc, lockFail) = state->assume(*DefinedRetVal); +break; + default: +llvm_unreachable("Unknown tryLock locking semantics"); + } + assert(lockFail && lockSucc); + C.addTransition(lockFail); } -assert(lockFail && lockSucc); -C.addTransition(lockFail); - +// We might want to handle the case when the mutex lock function was inlined +// and returned an Unknown or Undefined value. } else if (semantics == PthreadSemantics) { // Assume that the return value was 0. -lockSucc = state->assume(retVal, false); -assert(lockSucc); - +SVal RetVal = state->getSVal(CE, C.getLocationContext()); +if (auto DefinedRetVal = RetVal.getAs()) { + // FIXME: If the lock function was inlined and returned true, + // we need to behave sanely - at least generate sink. + lockSucc = state->assume(*DefinedRetVal, false); + assert(lockSucc); +} +// We might want to handle the case when the mutex lock function was inlined +// and returned an Unknown or Undefined value. } else { // XNU locking semantics return void on non-try locks assert((semantics == XNUSemantics) && "Unknown locking semantics"); Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -22,7 +22,9 @@ extern int pthread_mutex_trylock(pthread_mutex_t *); extern int pthread_mutex_destroy(pthread_mutex_t *); extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); -extern int lck_mtx_lock(lck_mtx_t *); -extern int lck_mtx_unlock(lck_mtx_t *); -extern int lck_mtx_try_lock(lck_mtx_t *); + +typedef int boolean_t; +extern void lck_mtx_lock(lck_mtx_t *); +extern void lck_mtx_unlock(lck_mtx_t *); +extern boolean_t lck_mtx_try_lock(lck_mtx_t *); extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -230,12 +230,6 @@ if (sym) state = resolvePossiblyDest
[PATCH] D37807: [analyzer] PthreadLock: Add the other XNU rwlock unlock functions.
NoQ created this revision. It turns out that XNU rwlocks, locked by `lck_rw_lock_shared()` and `lck_rw_lock_exclusive()`, can be unlocked through either the "unspecific" `lck_rw_done()` or the "specific" `lck_rw_unlock_shared()` and `lck_rw_unlock_exclusive()` calls. Add the two "specific" unlock functions to the checker. https://reviews.llvm.org/D37807 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h test/Analysis/pthreadlock.c Index: test/Analysis/pthreadlock.c === --- test/Analysis/pthreadlock.c +++ test/Analysis/pthreadlock.c @@ -8,6 +8,7 @@ pthread_mutex_t *pmtx; lck_mtx_t lck1, lck2; lck_grp_t grp1; +lck_rw_t rw; #define NULL 0 @@ -213,6 +214,13 @@ } } +void ok29(void) { + lck_rw_lock_shared(&rw); + lck_rw_unlock_shared(&rw); + lck_rw_lock_exclusive(&rw); // no-warning + lck_rw_unlock_exclusive(&rw); // no-warning +} + void bad1(void) { @@ -471,3 +479,10 @@ if (ret != 0) pthread_mutex_lock(&mtx1); } + +void bad32(void) { + lck_rw_lock_shared(&rw); + lck_rw_unlock_exclusive(&rw); // FIXME: warn - should be shared? + lck_rw_lock_exclusive(&rw); + lck_rw_unlock_shared(&rw); // FIXME: warn - should be exclusive? +} Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -15,6 +15,10 @@ void*foo; } lck_grp_t; +typedef struct { + void *foo; +} lck_rw_t; + typedef pthread_mutex_t lck_mtx_t; extern int pthread_mutex_lock(pthread_mutex_t *); @@ -28,3 +32,8 @@ extern void lck_mtx_unlock(lck_mtx_t *); extern boolean_t lck_mtx_try_lock(lck_mtx_t *); extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); + +extern void lck_rw_lock_exclusive(lck_rw_t *lck); +extern void lck_rw_unlock_exclusive(lck_rw_t *lck); +extern void lck_rw_lock_shared(lck_rw_t *lck); +extern void lck_rw_unlock_shared(lck_rw_t *lck); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -141,6 +141,8 @@ else if (FName == "pthread_mutex_unlock" || FName == "pthread_rwlock_unlock" || FName == "lck_mtx_unlock" || + FName == "lck_rw_unlock_exclusive" || + FName == "lck_rw_unlock_shared" || FName == "lck_rw_done") ReleaseLock(C, CE, state->getSVal(CE->getArg(0), LCtx)); else if (FName == "pthread_mutex_destroy") Index: test/Analysis/pthreadlock.c === --- test/Analysis/pthreadlock.c +++ test/Analysis/pthreadlock.c @@ -8,6 +8,7 @@ pthread_mutex_t *pmtx; lck_mtx_t lck1, lck2; lck_grp_t grp1; +lck_rw_t rw; #define NULL 0 @@ -213,6 +214,13 @@ } } +void ok29(void) { + lck_rw_lock_shared(&rw); + lck_rw_unlock_shared(&rw); + lck_rw_lock_exclusive(&rw); // no-warning + lck_rw_unlock_exclusive(&rw); // no-warning +} + void bad1(void) { @@ -471,3 +479,10 @@ if (ret != 0) pthread_mutex_lock(&mtx1); } + +void bad32(void) { + lck_rw_lock_shared(&rw); + lck_rw_unlock_exclusive(&rw); // FIXME: warn - should be shared? + lck_rw_lock_exclusive(&rw); + lck_rw_unlock_shared(&rw); // FIXME: warn - should be exclusive? +} Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -15,6 +15,10 @@ void *foo; } lck_grp_t; +typedef struct { + void *foo; +} lck_rw_t; + typedef pthread_mutex_t lck_mtx_t; extern int pthread_mutex_lock(pthread_mutex_t *); @@ -28,3 +32,8 @@ extern void lck_mtx_unlock(lck_mtx_t *); extern boolean_t lck_mtx_try_lock(lck_mtx_t *); extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); + +extern void lck_rw_lock_exclusive(lck_rw_t *lck); +extern void lck_rw_unlock_exclusive(lck_rw_t *lck); +extern void lck_rw_lock_shared(lck_rw_t *lck); +extern void lck_rw_unlock_shared(lck_rw_t *lck); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -141,6 +141,8 @@ else if (FName == "pthread_mutex_unlock" || FName == "pthread_rwlock_unlock" || FName == "lck_mtx_unlock" || + FName == "lck_rw_unlock_exclusive" || + FName == "lck_rw_unlock_shared" || FName == "lck_rw_done") ReleaseLock(C, CE, state->getSVal(C
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth added a comment. I added a clarifying comment for some outcommented code still in the patch. I would like to have a bit of discussion on it. Maybe some parts of the check could be warning-area, i just implemented it here to have it on one place. Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:47 + + /// This option is noise, therefore matching is configurable. + if (WarnOnMissingElse) { s/noise/noisy/ Comment at: clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp:68-78 +#if 0 +/// Get the number of different values for the Type T, that is switched on. +std::size_t getNumberOfPossibleValues(const Type *T, + const ASTContext &Context) { + // This Assertion fails in clang and llvm, when matching on enum types. + assert(T->isIntegralType(Context) && + "expecting integral type for discrete set of values"); I originally tried to implement some logic, that will realize when all paths are covered explicitly. It didn't work and i think it is irrelevant anyway, since manually covering all paths for integertypes is IMHO unrealistic. Iam willing to remove the code i currently commented out, just wanted it to be there if there is explicit need for a 'is everything covered'-check. Comment at: docs/clang-tidy/checks/list.rst:41 cert-oop11-cpp (redirects to misc-move-constructor-init) - cppcoreguidelines-c-copy-assignment-signature + cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) cppcoreguidelines-interfaces-global-init remove Comment at: test/clang-tidy/hicpp-multiway-paths-covered.cpp:7 +int return_integer() { return 42; } + +void problematic_switch(int i) { explicitly test, that the warnings for `else` do not occur here. Repository: rL LLVM https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.
MontyKutyi added a comment. Ping. https://reviews.llvm.org/D34030 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37809: [analyzer] PthreadLock: Refactor, use PostCall API. NFC.
NoQ created this revision. Use `CallEvent` and `CallDescription` everywhere. Unhardcode argument numbers in AcquireLock() etc. Have a list of supported functions in one place. Other misc cleanup. No functional change intended anywhere. https://reviews.llvm.org/D37809 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -4,36 +4,49 @@ #pragma clang system_header typedef struct { - void *foo; -} pthread_mutex_t; - -typedef struct { - void *foo; -} pthread_mutexattr_t; - -typedef struct { - void *foo; -} lck_grp_t; - -typedef struct { void *foo; -} lck_rw_t; +} OpaqueThing; + +// Pthread. +typedef OpaqueThing pthread_mutex_t; +typedef OpaqueThing pthread_rwlock_t; +typedef OpaqueThing pthread_mutexattr_t; + +// XNU. +typedef OpaqueThing lck_mtx_t; +typedef OpaqueThing lck_rw_t; +typedef OpaqueThing lck_grp_t; +typedef OpaqueThing lck_attr_t; +typedef int boolean_t; -typedef pthread_mutex_t lck_mtx_t; +// Init. +extern int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutexattr); +// Acquire. extern int pthread_mutex_lock(pthread_mutex_t *); -extern int pthread_mutex_unlock(pthread_mutex_t *); -extern int pthread_mutex_trylock(pthread_mutex_t *); -extern int pthread_mutex_destroy(pthread_mutex_t *); -extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); - -typedef int boolean_t; +// TODO: pthread_rwlock_rdlock. +// TODO: pthread_rwlock_wrlock. extern void lck_mtx_lock(lck_mtx_t *); -extern void lck_mtx_unlock(lck_mtx_t *); +extern void lck_rw_lock_exclusive(lck_rw_t *lck); +extern void lck_rw_lock_shared(lck_rw_t *lck); + +// Try. +extern int pthread_mutex_trylock(pthread_mutex_t *); +// TODO: pthread_rwlock_tryrdlock. +// TODO: pthread_rwlock_trywrlock. extern boolean_t lck_mtx_try_lock(lck_mtx_t *); -extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); +// TODO: lck_rw_try_lock_exclusive. +// TODO: lck_rw_try_lock_shared. -extern void lck_rw_lock_exclusive(lck_rw_t *lck); +// Release. +extern int pthread_mutex_unlock(pthread_mutex_t *); +// TODO: pthread_rwlock_tryrdlock. +// TODO: pthread_rwlock_trywrlock. +extern void lck_mtx_unlock(lck_mtx_t *); extern void lck_rw_unlock_exclusive(lck_rw_t *lck); -extern void lck_rw_lock_shared(lck_rw_t *lck); extern void lck_rw_unlock_shared(lck_rw_t *lck); + +// Destroy. +extern int pthread_mutex_destroy(pthread_mutex_t *); +extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -17,7 +17,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" using namespace clang; using namespace ento; @@ -67,7 +67,7 @@ }; class PthreadLockChecker -: public Checker, check::DeadSymbols> { +: public Checker { mutable std::unique_ptr BT_doublelock; mutable std::unique_ptr BT_doubleunlock; mutable std::unique_ptr BT_destroylock; @@ -78,23 +78,54 @@ PthreadSemantics, XNUSemantics }; -public: - void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; - void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; - void printState(raw_ostream &Out, ProgramStateRef State, - const char *NL, const char *Sep) const override; - void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, - bool isTryLock, enum LockingSemantics semantics) const; + typedef void (PthreadLockChecker::*FnCheck)(const CallEvent &Call, + CheckerContext &C) const; + struct SupportedAPI { +CallDescription Name; +FnCheck Callback; + }; + typedef SmallVector SupportedAPIList; + SupportedAPIList SupportedAPIs; - void ReleaseLock(CheckerContext &C, const CallExpr *CE, SVal lock) const; - void DestroyLock(CheckerContext &C, const CallExpr *CE, SVal Lock, - enum LockingSemantics semantics) const; - void InitLock(CheckerContext &C, const CallExpr *CE, SVal Lock) const; - void reportUseDestroyedBug(CheckerContext &C, const CallExpr *CE) const; ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef state, const MemRegion *lockR
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth updated this revision to Diff 115037. JonasToth marked 3 inline comments as done. JonasToth added a comment. - fix the first issues i found https://reviews.llvm.org/D37808 Files: clang-tidy/hicpp/CMakeLists.txt clang-tidy/hicpp/HICPPTidyModule.cpp clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp clang-tidy/hicpp/MultiwayPathsCoveredCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst docs/clang-tidy/checks/list.rst test/clang-tidy/hicpp-multiway-paths-covered-else.cpp test/clang-tidy/hicpp-multiway-paths-covered.cpp Index: test/clang-tidy/hicpp-multiway-paths-covered.cpp === --- /dev/null +++ test/clang-tidy/hicpp-multiway-paths-covered.cpp @@ -0,0 +1,406 @@ +// RUN: %check_clang_tidy %s hicpp-multiway-paths-covered %t + +enum OS { Mac, + Windows, + Linux }; + +/// All of these cases will not emit a warning per default, but with explicit activation. +void problematic_if(int i, enum OS os) { + if (i > 0) { +return; + } else if (i < 0) { +return; + } + + if (os == Mac) { +return; + } else if (os == Linux) { +if (true) { + return; +} else if (false) { + return; +} +return; + } else { +/* unreachable */ +if (true) // check if the parent would match here as well + return; + } + + // Ok, because all paths are covered + if (i > 0) { +return; + } else if (i < 0) { +return; + } else { +/* error, maybe precondition failed */ + } +} + +int return_integer() { return 42; } + +void problematic_switch(int i) { + // No default in this switch + switch (i) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 0: +break; + case 1: +break; + case 2: +break; + } + + // degenerate, maybe even warning + switch (i) { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerate switch statement without any cases found; add cases and a default branch + } + + switch (int j = return_integer()) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 0: + case 1: + case 2: +break; + } + + // Degenerated, only default branch. + switch (i) { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch stmt found; only the default branch exists + default: +break; + } + + // Degenerated, only one case label and default branch -> Better as if-stmt. + switch (i) { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch case could be better written with single if stmt + case 0: +break; + default: +break; + } + + unsigned long long BigNumber = 0; + switch (BigNumber) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 0: + case 1: +break; + } + + const int &IntRef = i; + switch (IntRef) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 0: + case 1: +break; + } + + char C = 'A'; + switch (C) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 'A': +break; + case 'B': +break; + } +} + +void unproblematic_switch(unsigned char c) { + // The switch stmt covers all paths explicitly. + // FIXME: False positive, determine the count of different possible values correctly. + // On the other hand, char is not defined to be one byte big, so there could be + // architectural differences, which would make the 'default:' case more portable. + switch (c) { + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered codepath found; add a default branch + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + case 38: + case 39: + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + case 58: + case 59: + case 60: + case 61: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + case 74: + case 75: + case 76: + case 77: + case 78: + case 79: + case 80: + case 81: + case 82: + case 83: + case 84: + case 85: + case 86: + case 87: + case 88: + case 89: + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + case 98: + case 99: + case 100: + case 101: + case 102: +
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth added a comment. fixed first stuff, sorry for noise. https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
Eugene.Zelenko added a comment. I think will be good idea to extend -Wswitch diagnostics. https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37809: [analyzer] PthreadLock: Refactor, use PostCall API. NFC.
NoQ updated this revision to Diff 115042. NoQ added a comment. Don't forget to check that the function is a global C function in post-call. https://reviews.llvm.org/D37809 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -4,36 +4,49 @@ #pragma clang system_header typedef struct { - void *foo; -} pthread_mutex_t; - -typedef struct { - void *foo; -} pthread_mutexattr_t; - -typedef struct { - void *foo; -} lck_grp_t; - -typedef struct { void *foo; -} lck_rw_t; +} OpaqueThing; + +// Pthread. +typedef OpaqueThing pthread_mutex_t; +typedef OpaqueThing pthread_rwlock_t; +typedef OpaqueThing pthread_mutexattr_t; + +// XNU. +typedef OpaqueThing lck_mtx_t; +typedef OpaqueThing lck_rw_t; +typedef OpaqueThing lck_grp_t; +typedef OpaqueThing lck_attr_t; +typedef int boolean_t; -typedef pthread_mutex_t lck_mtx_t; +// Init. +extern int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutexattr); +// Acquire. extern int pthread_mutex_lock(pthread_mutex_t *); -extern int pthread_mutex_unlock(pthread_mutex_t *); -extern int pthread_mutex_trylock(pthread_mutex_t *); -extern int pthread_mutex_destroy(pthread_mutex_t *); -extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); - -typedef int boolean_t; +// TODO: pthread_rwlock_rdlock. +// TODO: pthread_rwlock_wrlock. extern void lck_mtx_lock(lck_mtx_t *); -extern void lck_mtx_unlock(lck_mtx_t *); +extern void lck_rw_lock_exclusive(lck_rw_t *lck); +extern void lck_rw_lock_shared(lck_rw_t *lck); + +// Try. +extern int pthread_mutex_trylock(pthread_mutex_t *); +// TODO: pthread_rwlock_tryrdlock. +// TODO: pthread_rwlock_trywrlock. extern boolean_t lck_mtx_try_lock(lck_mtx_t *); -extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); +// TODO: lck_rw_try_lock_exclusive. +// TODO: lck_rw_try_lock_shared. -extern void lck_rw_lock_exclusive(lck_rw_t *lck); +// Release. +extern int pthread_mutex_unlock(pthread_mutex_t *); +// TODO: pthread_rwlock_tryrdlock. +// TODO: pthread_rwlock_trywrlock. +extern void lck_mtx_unlock(lck_mtx_t *); extern void lck_rw_unlock_exclusive(lck_rw_t *lck); -extern void lck_rw_lock_shared(lck_rw_t *lck); extern void lck_rw_unlock_shared(lck_rw_t *lck); + +// Destroy. +extern int pthread_mutex_destroy(pthread_mutex_t *); +extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -17,7 +17,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" using namespace clang; using namespace ento; @@ -67,7 +67,7 @@ }; class PthreadLockChecker -: public Checker, check::DeadSymbols> { +: public Checker { mutable std::unique_ptr BT_doublelock; mutable std::unique_ptr BT_doubleunlock; mutable std::unique_ptr BT_destroylock; @@ -78,23 +78,54 @@ PthreadSemantics, XNUSemantics }; -public: - void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; - void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; - void printState(raw_ostream &Out, ProgramStateRef State, - const char *NL, const char *Sep) const override; - void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock, - bool isTryLock, enum LockingSemantics semantics) const; + typedef void (PthreadLockChecker::*FnCheck)(const CallEvent &Call, + CheckerContext &C) const; + struct SupportedAPI { +CallDescription Name; +FnCheck Callback; + }; + typedef SmallVector SupportedAPIList; + SupportedAPIList SupportedAPIs; - void ReleaseLock(CheckerContext &C, const CallExpr *CE, SVal lock) const; - void DestroyLock(CheckerContext &C, const CallExpr *CE, SVal Lock, - enum LockingSemantics semantics) const; - void InitLock(CheckerContext &C, const CallExpr *CE, SVal Lock) const; - void reportUseDestroyedBug(CheckerContext &C, const CallExpr *CE) const; ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef state, const MemRegion *lockR, const SymbolRef *sym) const; + void reportUseD
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth added a comment. In https://reviews.llvm.org/D37808#869602, @Eugene.Zelenko wrote: > I think will be good idea to extend -Wswitch diagnostics. Ok. But it will introduce new warnings to llvm codebase itself. I prepare some example output i found right now. https://reviews.llvm.org/D37808 ___ 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
Typz added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:1339 +unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, +LineState &State, djasper wrote: > Can you create a patch that doesn't move the code around so much? Seems > unnecessary and hard to review. Moving the code around is an unfortunate requirement for this patch: we must actually do the "reflowing" twice, to find out which solution (actually reflowing or not) gives the least penalty. Therefore the function that reflowing must be moved out of `breakProtrudingToken()`... All I can do is try moving the new function after `breakProtrudingToken()`, maybe Phabricator will better show the change. 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); djasper wrote: > 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 This behavior has not changed : before the commit, the last token was not included in the penalty [c.f. `if` at line 1338 in original code]. To make the comparison significative, the last token's penalty is included in the penalty returned by `reflowProtrudingToken()` (hence the removal of the test at line 1260); and it is removed before returning from this function, to keep the same behavior as before. https://reviews.llvm.org/D33589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r313150 - [clang-tidy] fixed misc-unused-parameters omitting parameters default value
Author: alexfh Date: Wed Sep 13 07:55:13 2017 New Revision: 313150 URL: http://llvm.org/viewvc/llvm-project?rev=313150&view=rev Log: [clang-tidy] fixed misc-unused-parameters omitting parameters default value Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34450 **Problem:** Clang-tidy check misc-unused-parameters omits parameter default value what results in its complete removal. Compilation errors might occur after clang-tidy fix. **Patch description:** Changed removal range. The range should end after parameter declarator, not after whole parameter declaration (which might contain a default value). Reviewers: alexfh, xazax.hun Reviewed By: alexfh Subscribers: JDevlieghere, cfe-commits Tags: #clang-tools-extra Patch by Pawel Maciocha! Differential Revision: https://reviews.llvm.org/D37566 Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp?rev=313150&r1=313149&r2=313150&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp Wed Sep 13 07:55:13 2017 @@ -138,7 +138,8 @@ void UnusedParametersCheck::warnOnUnused if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { -SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd()); +SourceRange RemovalRange(Param->getLocation(), + Param->DeclaratorDecl::getSourceRange().getEnd()); // Note: We always add a space before the '/*' to not accidentally create a // '*/*' for pointer types, which doesn't start a comment. clang-format will // clean this up afterwards. Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp?rev=313150&r1=313149&r2=313150&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Wed Sep 13 07:55:13 2017 @@ -14,7 +14,7 @@ void a(int i) {} void b(int i = 1) {} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void b(int /*i*/) {}{{$}} +// CHECK-FIXES: {{^}}void b(int /*i*/ = 1) {}{{$}} void c(int *i) {} // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters] @@ -22,7 +22,8 @@ void c(int *i) {} // Unchanged cases // === -void g(int i); // Don't remove stuff in declarations +void f(int i); // Don't remove stuff in declarations +void g(int i = 1); void h(int i) { (void)i; } // Don't remove used parameters bool useLambda(int (*fn)(int)); @@ -52,6 +53,11 @@ static void staticFunctionE(int i = 4) { // CHECK-MESSAGES: :[[@LINE-1]]:33: warning // CHECK-FIXES: {{^}}static void staticFunctionE() +static void staticFunctionF(int i = 4); +// CHECK-FIXES: {{^}}static void staticFunctionF(); +static void staticFunctionF(int i) {} +// CHECK-MESSAGES: :[[@LINE-1]]:33: warning +// CHECK-FIXES: {{^}}static void staticFunctionF() static void someCallSites() { staticFunctionA(1); @@ -62,7 +68,12 @@ static void someCallSites() { // CHECK-FIXES: staticFunctionC(2); staticFunctionD(1, 2, 3); // CHECK-FIXES: staticFunctionD(1, 3); - staticFunctionE(); + staticFunctionE(1); +// CHECK-FIXES: staticFunctionE(); + staticFunctionF(1); +// CHECK-FIXES: staticFunctionF(); + staticFunctionF(); +// CHECK-FIXES: staticFunctionF(); } /* @@ -95,6 +106,9 @@ class SomeClass { static void f(int i) {} // CHECK-MESSAGES: :[[@LINE-1]]:21: warning // CHECK-FIXES: static void f(int /*i*/) {} + static void g(int i = 1) {} +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning +// CHECK-FIXES: static void g(int /*i*/ = 1) {} }; namespace { @@ -108,6 +122,9 @@ public: void h(int i) {} // CHECK-MESSAGES: :[[@LINE-1]]:14: warning // CHECK-FIXES: void h(int /*i*/) {} + void s(int i = 1) {} +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning +// CHECK-FIXES: void s(int /*i*/ = 1) {} }; void C::f(int i) {} @@ -125,6 +142,7 @@ void someMoreCallSites() { // CHECK-FIXES: c.g(); useFunction(&C::h); + useFunction(&C::s);; } class Base { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37566: [clang-tidy] fixed misc-unused-parameters omitting parameters default value
This revision was automatically updated to reflect the committed changes. Closed by commit rL313150: [clang-tidy] fixed misc-unused-parameters omitting parameters default value (authored by alexfh). Changed prior to commit: https://reviews.llvm.org/D37566?vs=114538&id=115047#toc Repository: rL LLVM https://reviews.llvm.org/D37566 Files: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp @@ -138,7 +138,8 @@ if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { -SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd()); +SourceRange RemovalRange(Param->getLocation(), + Param->DeclaratorDecl::getSourceRange().getEnd()); // Note: We always add a space before the '/*' to not accidentally create a // '*/*' for pointer types, which doesn't start a comment. clang-format will // clean this up afterwards. Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp @@ -14,15 +14,16 @@ void b(int i = 1) {} // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] -// CHECK-FIXES: {{^}}void b(int /*i*/) {}{{$}} +// CHECK-FIXES: {{^}}void b(int /*i*/ = 1) {}{{$}} void c(int *i) {} // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters] // CHECK-FIXES: {{^}}void c(int * /*i*/) {}{{$}} // Unchanged cases // === -void g(int i); // Don't remove stuff in declarations +void f(int i); // Don't remove stuff in declarations +void g(int i = 1); void h(int i) { (void)i; } // Don't remove used parameters bool useLambda(int (*fn)(int)); @@ -52,6 +53,11 @@ // CHECK-MESSAGES: :[[@LINE-1]]:33: warning // CHECK-FIXES: {{^}}static void staticFunctionE() +static void staticFunctionF(int i = 4); +// CHECK-FIXES: {{^}}static void staticFunctionF(); +static void staticFunctionF(int i) {} +// CHECK-MESSAGES: :[[@LINE-1]]:33: warning +// CHECK-FIXES: {{^}}static void staticFunctionF() static void someCallSites() { staticFunctionA(1); @@ -62,7 +68,12 @@ // CHECK-FIXES: staticFunctionC(2); staticFunctionD(1, 2, 3); // CHECK-FIXES: staticFunctionD(1, 3); - staticFunctionE(); + staticFunctionE(1); +// CHECK-FIXES: staticFunctionE(); + staticFunctionF(1); +// CHECK-FIXES: staticFunctionF(); + staticFunctionF(); +// CHECK-FIXES: staticFunctionF(); } /* @@ -95,6 +106,9 @@ static void f(int i) {} // CHECK-MESSAGES: :[[@LINE-1]]:21: warning // CHECK-FIXES: static void f(int /*i*/) {} + static void g(int i = 1) {} +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning +// CHECK-FIXES: static void g(int /*i*/ = 1) {} }; namespace { @@ -108,6 +122,9 @@ void h(int i) {} // CHECK-MESSAGES: :[[@LINE-1]]:14: warning // CHECK-FIXES: void h(int /*i*/) {} + void s(int i = 1) {} +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning +// CHECK-FIXES: void s(int /*i*/ = 1) {} }; void C::f(int i) {} @@ -125,6 +142,7 @@ // CHECK-FIXES: c.g(); useFunction(&C::h); + useFunction(&C::s);; } class Base { Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp @@ -138,7 +138,8 @@ if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { -SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd()); +SourceRange RemovalRange(Param->getLocation(), + Param->DeclaratorDecl::getSourceRange().getEnd()); // Note: We always add a space before the '/*' to not accidentally create a // '*/*' for pointer types, which doesn't start a comment. clang-format will // clean this up afterwards. Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp @@ -14,15 +14,16 @@ void b(int i = 1) {} // CHECK-MESSAGES: :[
[PATCH] D37566: [clang-tidy] fixed misc-unused-parameters omitting parameters default value
alexfh added a comment. In https://reviews.llvm.org/D37566#866096, @PriMee wrote: > Done :) Could you please commit this for me? Sure, just committed the patch. Repository: rL LLVM https://reviews.llvm.org/D37566 ___ 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 accepted this revision. rogfer01 added a subscriber: rsmith. rogfer01 added a comment. This revision is now accepted and ready to land. This LGTM, but wait a couple of days before comitting in case @rsmith or @scanon (or others!) have further comments. 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 accepted this revision. scanon added a comment. LGTM as well. 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
SjoerdMeijer added a comment. many thanks for reviewing and your help. 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
This revision was automatically updated to reflect the committed changes. Closed by commit rL313152: This adds the _Float16 preprocessor macro definitions. (authored by SjoerdMeijer). Changed prior to commit: https://reviews.llvm.org/D34695?vs=114998&id=115050#toc Repository: rL LLVM https://reviews.llvm.org/D34695 Files: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Headers/float.h cfe/trunk/test/Headers/float16.c cfe/trunk/test/Preprocessor/init.c Index: cfe/trunk/lib/Headers/float.h === --- cfe/trunk/lib/Headers/float.h +++ cfe/trunk/lib/Headers/float.h @@ -143,4 +143,18 @@ # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ #endif +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG__FLT16_MANT_DIG__ +# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ +# define FLT16_DIG __FLT16_DIG__ +# define FLT16_MIN_EXP __FLT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ +# define FLT16_MAX_EXP __FLT16_MAX_EXP__ +# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ +# define FLT16_MAX __FLT16_MAX__ +# define FLT16_EPSILON __FLT16_EPSILON__ +# define FLT16_MIN __FLT16_MIN__ +# define FLT16_TRUE_MIN__FLT16_TRUE_MIN__ +#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ + #endif /* __FLOAT_H */ Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp === --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp @@ -110,9 +110,11 @@ /// PickFP - This is used to pick a value based on the FP semantics of the /// specified FP model. template -static T PickFP(const llvm::fltSemantics *Sem, T IEEESingleVal, +static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, T IEEEQuadVal) { + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) +return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) return IEEESingleVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEdouble()) @@ -128,26 +130,26 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext) { const char *DenormMin, *Epsilon, *Max, *Min; - DenormMin = PickFP(Sem, "1.40129846e-45", "4.9406564584124654e-324", - "3.64519953188247460253e-4951", + DenormMin = PickFP(Sem, "5.9604644775390625e-8", "1.40129846e-45", + "4.9406564584124654e-324", "3.64519953188247460253e-4951", "4.94065645841246544176568792868221e-324", "6.47517511943802511092443895822764655e-4966"); - int Digits = PickFP(Sem, 6, 15, 18, 31, 33); - int DecimalDigits = PickFP(Sem, 9, 17, 21, 33, 36); - Epsilon = PickFP(Sem, "1.19209290e-7", "2.2204460492503131e-16", - "1.08420217248550443401e-19", + int Digits = PickFP(Sem, 3, 6, 15, 18, 31, 33); + int DecimalDigits = PickFP(Sem, 5, 9, 17, 21, 33, 36); + Epsilon = PickFP(Sem, "9.765625e-4", "1.19209290e-7", + "2.2204460492503131e-16", "1.08420217248550443401e-19", "4.94065645841246544176568792868221e-324", "1.92592994438723585305597794258492732e-34"); - int MantissaDigits = PickFP(Sem, 24, 53, 64, 106, 113); - int Min10Exp = PickFP(Sem, -37, -307, -4931, -291, -4931); - int Max10Exp = PickFP(Sem, 38, 308, 4932, 308, 4932); - int MinExp = PickFP(Sem, -125, -1021, -16381, -968, -16381); - int MaxExp = PickFP(Sem, 128, 1024, 16384, 1024, 16384); - Min = PickFP(Sem, "1.17549435e-38", "2.2250738585072014e-308", + int MantissaDigits = PickFP(Sem, 11, 24, 53, 64, 106, 113); + int Min10Exp = PickFP(Sem, -13, -37, -307, -4931, -291, -4931); + int Max10Exp = PickFP(Sem, 4, 38, 308, 4932, 308, 4932); + int MinExp = PickFP(Sem, -14, -125, -1021, -16381, -968, -16381); + int MaxExp = PickFP(Sem, 15, 128, 1024, 16384, 1024, 16384); + Min = PickFP(Sem, "6.103515625e-5", "1.17549435e-38", "2.2250738585072014e-308", "3.36210314311209350626e-4932", "2.00416836000897277799610805135016e-292", "3.36210314311209350626267781732175260e-4932"); - Max = PickFP(Sem, "3.40282347e+38", "1.7976931348623157e+308", + Max = PickFP(Sem, "6.5504e+4", "3.40282347e+38", "1.7976931348623157e+308", "1.18973149535723176502e+4932", "1.79769313486231580793728971405301e+308", "1.18973149535723176508575932662800702e+4932"); @@ -802,6 +804,7 @@ DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder); DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder); + DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16"); DefineFloatMacros(Builder, "FLT", &TI.getFl
r313152 - This adds the _Float16 preprocessor macro definitions.
Author: sjoerdmeijer Date: Wed Sep 13 08:23:19 2017 New Revision: 313152 URL: http://llvm.org/viewvc/llvm-project?rev=313152&view=rev Log: This adds the _Float16 preprocessor macro definitions. Differential Revision: https://reviews.llvm.org/D34695 Added: cfe/trunk/test/Headers/float16.c Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Headers/float.h cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=313152&r1=313151&r2=313152&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Sep 13 08:23:19 2017 @@ -110,9 +110,11 @@ static void AddImplicitIncludePCH(MacroB /// PickFP - This is used to pick a value based on the FP semantics of the /// specified FP model. template -static T PickFP(const llvm::fltSemantics *Sem, T IEEESingleVal, +static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, T IEEEQuadVal) { + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) +return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) return IEEESingleVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEdouble()) @@ -128,26 +130,26 @@ static T PickFP(const llvm::fltSemantics static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext) { const char *DenormMin, *Epsilon, *Max, *Min; - DenormMin = PickFP(Sem, "1.40129846e-45", "4.9406564584124654e-324", - "3.64519953188247460253e-4951", + DenormMin = PickFP(Sem, "5.9604644775390625e-8", "1.40129846e-45", + "4.9406564584124654e-324", "3.64519953188247460253e-4951", "4.94065645841246544176568792868221e-324", "6.47517511943802511092443895822764655e-4966"); - int Digits = PickFP(Sem, 6, 15, 18, 31, 33); - int DecimalDigits = PickFP(Sem, 9, 17, 21, 33, 36); - Epsilon = PickFP(Sem, "1.19209290e-7", "2.2204460492503131e-16", - "1.08420217248550443401e-19", + int Digits = PickFP(Sem, 3, 6, 15, 18, 31, 33); + int DecimalDigits = PickFP(Sem, 5, 9, 17, 21, 33, 36); + Epsilon = PickFP(Sem, "9.765625e-4", "1.19209290e-7", + "2.2204460492503131e-16", "1.08420217248550443401e-19", "4.94065645841246544176568792868221e-324", "1.92592994438723585305597794258492732e-34"); - int MantissaDigits = PickFP(Sem, 24, 53, 64, 106, 113); - int Min10Exp = PickFP(Sem, -37, -307, -4931, -291, -4931); - int Max10Exp = PickFP(Sem, 38, 308, 4932, 308, 4932); - int MinExp = PickFP(Sem, -125, -1021, -16381, -968, -16381); - int MaxExp = PickFP(Sem, 128, 1024, 16384, 1024, 16384); - Min = PickFP(Sem, "1.17549435e-38", "2.2250738585072014e-308", + int MantissaDigits = PickFP(Sem, 11, 24, 53, 64, 106, 113); + int Min10Exp = PickFP(Sem, -13, -37, -307, -4931, -291, -4931); + int Max10Exp = PickFP(Sem, 4, 38, 308, 4932, 308, 4932); + int MinExp = PickFP(Sem, -14, -125, -1021, -16381, -968, -16381); + int MaxExp = PickFP(Sem, 15, 128, 1024, 16384, 1024, 16384); + Min = PickFP(Sem, "6.103515625e-5", "1.17549435e-38", "2.2250738585072014e-308", "3.36210314311209350626e-4932", "2.00416836000897277799610805135016e-292", "3.36210314311209350626267781732175260e-4932"); - Max = PickFP(Sem, "3.40282347e+38", "1.7976931348623157e+308", + Max = PickFP(Sem, "6.5504e+4", "3.40282347e+38", "1.7976931348623157e+308", "1.18973149535723176502e+4932", "1.79769313486231580793728971405301e+308", "1.18973149535723176508575932662800702e+4932"); @@ -802,6 +804,7 @@ static void InitializePredefinedMacros(c DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder); DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder); + DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16"); DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F"); DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), ""); DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L"); Modified: cfe/trunk/lib/Headers/float.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=313152&r1=313151&r2=313152&view=diff == --- cfe/trunk/lib/Headers/float.h (original) +++ cfe/trunk/lib/Headers/float.h Wed Sep 13 08:23:19 2017 @@ -143,4 +143,18 @@ # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ #endif +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG
[PATCH] D33589: clang-format: consider not splitting tokens in optimization
Typz updated this revision to Diff 115051. Typz added a comment. Reorder the functions to minimize diff. https://reviews.llvm.org/D33589 Files: lib/Format/ContinuationIndenter.cpp lib/Format/ContinuationIndenter.h lib/Format/UnwrappedLineFormatter.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -9809,6 +9809,60 @@ EXPECT_EQ("#pragma option -C -A", format("#pragmaoption -C -A")); } +TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) { + FormatStyle Style = getLLVMStyle(); + Style.ColumnLimit = 20; + + verifyFormat("int a; // the\n" + " // comment", Style); + EXPECT_EQ("int a; /* first line\n" +"* second\n" +"* line third\n" +"* line\n" +"*/", + format("int a; /* first line\n" + "* second\n" + "* line third\n" + "* line\n" + "*/", Style)); + EXPECT_EQ("int a; // first line\n" +" // second\n" +" // line third\n" +" // line", +format("int a; // first line\n" + " // second line\n" + " // third line", + Style)); + + Style.PenaltyExcessCharacter = 90; + verifyFormat("int a; // the comment", Style); + EXPECT_EQ("int a; // the\n" +" // comment aa", +format("int a; // the comment aa", Style)); + EXPECT_EQ("int a; /* first line\n" +"* second line\n" +"* third line\n" +"*/", + format("int a; /* first line\n" + "* second line\n" + "* third line\n" + "*/", Style)); + EXPECT_EQ("int a; // first line\n" +" // second line\n" +" // third line", +format("int a; // first line\n" + " // second line\n" + " // third line", + Style)); + EXPECT_EQ("int a; /* first line\n" +"* second\n" +"* line third\n" +"* line\n" +"*/", +format("int a; /* first line second line third line" + "\n*/", Style)); +} + #define EXPECT_ALL_STYLES_EQUAL(Styles)\ for (size_t i = 1; i < Styles.size(); ++i) \ EXPECT_EQ(Styles[0], Styles[i]) << "Style #" << i << " of " << Styles.size() \ Index: lib/Format/UnwrappedLineFormatter.cpp === --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -951,6 +951,7 @@ for (std::deque::iterator I = Path.begin(), E = Path.end(); I != E; ++I) { unsigned Penalty = 0; + State.Reflow = (*I)->State.Reflow; formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty); Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false); Index: lib/Format/ContinuationIndenter.h === --- lib/Format/ContinuationIndenter.h +++ lib/Format/ContinuationIndenter.h @@ -27,6 +27,7 @@ namespace format { class AnnotatedLine; +class BreakableToken; struct FormatToken; struct LineState; struct ParenState; @@ -100,6 +101,16 @@ unsigned breakProtrudingToken(const FormatToken &Current, LineState &State, bool DryRun); + /// \brief Perform the reflowing of a BreakableToken. + /// If State.Reflow=true, then the function will reflow the token as needed. + /// Otherwise, it simply computes the penalty caused by this tokens characters. + /// + /// \returns The penalty of reflowing the token if State.Reflow=true; otherwise + /// the penalty of characters going beyond the column limit. + unsigned reflowProtrudingToken(const FormatToken & Current, LineState & State, + std::unique_ptr & Token, + unsigned ColumnLimit, bool DryRun); + /// \brief Appends the next token to \p State and updates information /// necessary for indentation. /// @@ -350,6 +361,11 @@ /// \brief The indent of the first token. unsigned FirstIndent; + /// \brief Indicates if comments are reflown. + /// This value is set when breakProtrudingToken() is called with DryRun=true, + /// and simply used otherwise. + bool Reflow = true; + /// \brief The line that is being formatted. /// /// Does not need to be considered for memoization because it doesn't change. Index: lib/Format/ContinuationIndenter.cpp === --- li
[PATCH] D33440: clang-format: better handle statement and namespace macros
Typz marked 8 inline comments as done. Typz added inline comments. Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:155 const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First; - // Detect "(inline)? namespace" in the beginning of a line. - if (NamespaceTok->is(tok::kw_inline)) -NamespaceTok = NamespaceTok->getNextNonComment(); - if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace)) -return nullptr; - return NamespaceTok; + return NamespaceTok->getNamespaceToken(); +} krasimir wrote: > What happened to the old `// Detect "(inline)? namespace" in the beginning of > a line.` Moved to `FormatToken::getNamespaceToken()` Comment at: unittests/Format/FormatTest.cpp:1588 + Style.NamespaceIndentation = FormatStyle::NI_All; + verifyFormat("TESTSUITE(A) {\n" + " int foo();\n" krasimir wrote: > Hm, what would happen if you have a namespace macro with two or more > parameters? only the first argument is used, as seen in previous test case. https://reviews.llvm.org/D33440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37809: [analyzer] PthreadLock: Refactor, use PostCall API. NFC.
zaks.anna added a comment. How about committing the refactor of the code without test modifications. And committing changes to the test separately? https://reviews.llvm.org/D37809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37806: [analyzer] PthreadLock: Fix return values of XNU lock functions.
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:271 } -assert(lockFail && lockSucc); -C.addTransition(lockFail); - +// We might want to handle the case when the mutex lock function was inlined +// and returned an Unknown or Undefined value. This comment is repeated several times... Comment at: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h:29 +extern void lck_mtx_unlock(lck_mtx_t *); +extern boolean_t lck_mtx_try_lock(lck_mtx_t *); extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp); Should there be a test added that uses the function? https://reviews.llvm.org/D37806 ___ 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 115054. Typz marked 2 inline comments as done. Typz added a comment. Fix review comments, before splitting the commit. 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()", +
[PATCH] D37812: [analyzer] PthreadLock: Escape the pointers.
NoQ created this revision. As usual, we need to invalidate mutex states when something may touch them. Implement this boilerplate for the thread lock checker. The previous refactoring is handy for listing functions on which we don't need to invalidate mutex states because we model them instead. Additionally, i don't invalidate mutex states when any system header function is called, unless the mutex is passed directly into it. The TODO here would be to model *all* system functions that may change mutex states, and then disable invalidation for the rest of them even if they take a mutex; that's what other checkers do. https://reviews.llvm.org/D37812 Files: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h test/Analysis/pthreadlock.c Index: test/Analysis/pthreadlock.c === --- test/Analysis/pthreadlock.c +++ test/Analysis/pthreadlock.c @@ -221,6 +221,27 @@ lck_rw_unlock_exclusive(&rw); // no-warning } +void escape_mutex(pthread_mutex_t *m); +void ok30(void) { + pthread_mutex_t local_mtx; + pthread_mutex_init(&local_mtx, NULL); + pthread_mutex_lock(&local_mtx); + escape_mutex(&local_mtx); + pthread_mutex_lock(&local_mtx); // no-warning + pthread_mutex_unlock(&local_mtx); + pthread_mutex_destroy(&local_mtx); +} + +void ok31(void) { + pthread_mutex_t local_mtx; + pthread_mutex_init(&local_mtx, NULL); + pthread_mutex_lock(&local_mtx); + fake_system_function_that_takes_a_mutex(&local_mtx); + pthread_mutex_lock(&local_mtx); // no-warning + pthread_mutex_unlock(&local_mtx); + pthread_mutex_destroy(&local_mtx); +} + void bad1(void) { @@ -486,3 +507,9 @@ lck_rw_lock_exclusive(&rw); lck_rw_unlock_shared(&rw); // FIXME: warn - should be exclusive? } + +void bad33(void) { + pthread_mutex_lock(pmtx); + fake_system_function(); + pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been acquired}} +} Index: test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h === --- test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h +++ test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h @@ -3,6 +3,8 @@ // should not invalidate regions of their arguments. #pragma clang system_header +extern void fake_system_function(); + typedef struct { void *foo; } OpaqueThing; @@ -12,6 +14,8 @@ typedef OpaqueThing pthread_rwlock_t; typedef OpaqueThing pthread_mutexattr_t; +extern void fake_system_function_that_takes_a_mutex(pthread_mutex_t *mtx); + // XNU. typedef OpaqueThing lck_mtx_t; typedef OpaqueThing lck_rw_t; Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp === --- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -66,8 +66,8 @@ } }; -class PthreadLockChecker -: public Checker { +class PthreadLockChecker : public Checker { mutable std::unique_ptr BT_doublelock; mutable std::unique_ptr BT_doubleunlock; mutable std::unique_ptr BT_destroylock; @@ -124,6 +124,11 @@ void checkPostCall(const CallEvent &Call, CheckerContext &C) const; void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; + ProgramStateRef + checkRegionChanges(ProgramStateRef State, const InvalidatedSymbols *Symbols, + ArrayRef ExplicitRegions, + ArrayRef Regions, + const LocationContext *LCtx, const CallEvent *Call) const; void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const override; }; @@ -567,6 +572,38 @@ C.addTransition(State); } +ProgramStateRef PthreadLockChecker::checkRegionChanges( +ProgramStateRef State, const InvalidatedSymbols *Symbols, +ArrayRef ExplicitRegions, +ArrayRef Regions, const LocationContext *LCtx, +const CallEvent *Call) const { + + bool IsLibraryFunction = false; + if (Call && Call->isGlobalCFunction()) { +// Avoid invalidating mutex state when a known supported function is called. +for (auto I : SupportedAPIs) + if (Call->isCalled(I.Name)) +return State; +if (Call->isInSystemHeader()) + IsLibraryFunction = true; + } + + for (auto R : Regions) { +// We assume that system library function wouldn't touch the mutex unless +// it takes the mutex explicitly as an argument. +if (IsLibraryFunction && +std::find(ExplicitRegions.begin(), ExplicitRegions.end(), R) == +ExplicitRegions.end()) + continue; + +State = State->remove(R); +State = State->remove(R); +// TODO: Destroy the lock stack as well. + } + + return State; +} + void ento::registerPthreadLockChecker(CheckerManager &mgr) { mgr.registerChecker(); } ___
[PATCH] D33440: clang-format: better handle statement and namespace macros
Typz updated this revision to Diff 115057. Typz added a comment. Split diff: handle only statements in here, namespace macros will be moved to another one. 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/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2385,6 +2385,26 @@ getLLVMStyleWithColumns(40))); verifyFormat("MACRO(>)"); + + // Some macros contain an implicit semicolon + FormatStyle Style = getLLVMStyle(); + Style.StatementMacros.push_back("FOO"); + verifyFormat("FOO(a) int b = 0;"); + verifyFormat("FOO(a)\n" + "int b = 0;", + Style); + verifyFormat("FOO(a);\n" + "int b = 0;", + Style); + verifyFormat("FOO(argc, argv, \"4.0.2\")\n" + "int b = 0;", + Style); + verifyFormat("FOO()\n" + "int b = 0;", + Style); + verifyFormat("FOO\n" + "int b = 0;", + Style); } TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) { @@ -10185,6 +10205,12 @@ CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros, BoostAndQForeach); + Style.StatementMacros.clear(); + CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros, + std::vector{"QUNUSED"}); + CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros, + std::vector({"QUNUSED", "QT_REQUIRE_VERSION"})); + Style.IncludeCategories.clear(); std::vector ExpectedCategories = {{"abc/.*", 2}, {".*", 1}}; Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1089,6 +1089,15 @@ return; } } +if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) { + nextToken(); + if (FormatTok->is(tok::l_paren)) +parseParens(); + if (FormatTok->is(tok::semi)) +nextToken(); + addUnwrappedLine(); + return; +} // In all other cases, parse the declaration. break; default: Index: lib/Format/FormatTokenLexer.h === --- lib/Format/FormatTokenLexer.h +++ lib/Format/FormatTokenLexer.h @@ -97,7 +97,29 @@ // Index (in 'Tokens') of the last token that starts a new line. unsigned FirstInLineIndex; SmallVector Tokens; - SmallVector ForEachMacros; + + struct MacroInfo { +MacroInfo() : Identifier(NULL), TokType(TT_Unknown) {} +MacroInfo(IdentifierInfo *Identifier, TokenType TokType) +: Identifier(Identifier), TokType(TokType) {} + +IdentifierInfo *Identifier; +TokenType TokType; + +bool operator==(const MacroInfo &Other) const { + return Identifier == Other.Identifier; +} +bool operator==(const IdentifierInfo *Other) const { + return Identifier == Other; +} +bool operator<(const MacroInfo &Other) const { + return Identifier < Other.Identifier; +} +bool operator<(const IdentifierInfo *Other) const { + return Identifier < Other; +} + }; + SmallVector Macros; bool FormattingDisabled; Index: lib/Format/FormatTokenLexer.cpp === --- lib/Format/FormatTokenLexer.cpp +++ lib/Format/FormatTokenLexer.cpp @@ -37,8 +37,10 @@ Lex->SetKeepWhitespaceMode(true); for (const std::string &ForEachMacro : Style.ForEachMacros) -ForEachMacros.push_back(&IdentTable.get(ForEachMacro)); - std::sort(ForEachMacros.begin(), ForEachMacros.end()); +Macros.emplace_back(&IdentTable.get(ForEachMacro), TT_ForEachMacro); + for (const std::string &StatementMacro : Style.StatementMacros) +Macros.emplace_back(&IdentTable.get(StatementMacro), TT_StatementMacro); + std::sort(Macros.begin(), Macros.end()); } ArrayRef FormatTokenLexer::lex() { @@ -633,12 +635,13 @@ } if (Style.isCpp()) { +decltype(Macros)::iterator it; if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() && Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() == tok::pp_define) && -std::find(ForEachMacros.begin(), ForEachMacros.end(), - FormatTok->Tok.getIdentifierInfo()) != ForEachMacros.end()) { - FormatTok->Type = TT_ForEachMacro; +(it = std::find(Macros.begin(), Macros.end(), +FormatTok->Tok.getIdentifierInfo())) != Macros.end()) { + FormatTok->Type = it->TokType; } else if (FormatTok->is(tok::identif
[PATCH] D37813: clang-format: better handle namespace macros
Typz created this revision. Other macros are used to declare namespaces, and should thus be handled similarly. This is the case for crpcut's TESTSUITE macro, or for unittest-cpp's SUITE macro: TESTSUITE(Foo) { TEST(MyFirstTest) { assert(0); } } // TESTSUITE(Foo) This patch deals with this cases by introducing a new option to specify lists of namespace macros. Internally, it re-uses the system already in place for foreach and statement macros, to ensure there is no impact on performance. https://reviews.llvm.org/D37813 Files: include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/FormatTokenLexer.cpp 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"
[PATCH] D37564: Update users of llvm::sys::ExecuteAndWait etc.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lgtm too https://reviews.llvm.org/D37564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313156 - Update users of llvm::sys::ExecuteAndWait etc.
Author: alexfh Date: Wed Sep 13 10:03:58 2017 New Revision: 313156 URL: http://llvm.org/viewvc/llvm-project?rev=313156&view=rev Log: Update users of llvm::sys::ExecuteAndWait etc. Summary: Clang part of https://reviews.llvm.org/D37563 Reviewers: bkramer Subscribers: vsk, cfe-commits Differential Revision: https://reviews.llvm.org/D37564 Modified: cfe/trunk/include/clang/Driver/Compilation.h cfe/trunk/include/clang/Driver/Job.h cfe/trunk/lib/Driver/Compilation.cpp cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Modified: cfe/trunk/include/clang/Driver/Compilation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=313156&r1=313155&r2=313156&view=diff == --- cfe/trunk/include/clang/Driver/Compilation.h (original) +++ cfe/trunk/include/clang/Driver/Compilation.h Wed Sep 13 10:03:58 2017 @@ -99,8 +99,8 @@ class Compilation { /// only be removed if we crash. ArgStringMap FailureResultFiles; - /// Redirection for stdout, stderr, etc. - const StringRef **Redirects; + /// Optional redirection for stdin, stdout, stderr. + std::vector> Redirects; /// Whether we're compiling for diagnostic purposes. bool ForDiagnostics; @@ -283,12 +283,10 @@ public: /// Redirect - Redirect output of this compilation. Can only be done once. /// - /// \param Redirects - array of pointers to paths. The array - /// should have a size of three. The inferior process's - /// stdin(0), stdout(1), and stderr(2) will be redirected to the - /// corresponding paths. This compilation instance becomes - /// the owner of Redirects and will delete the array and StringRef's. - void Redirect(const StringRef** Redirects); + /// \param Redirects - array of optional paths. The array should have a size + /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will + /// be redirected to the corresponding paths, if provided (not llvm::None). + void Redirect(ArrayRef> Redirects); }; } // end namespace driver Modified: cfe/trunk/include/clang/Driver/Job.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=313156&r1=313155&r2=313156&view=diff == --- cfe/trunk/include/clang/Driver/Job.h (original) +++ cfe/trunk/include/clang/Driver/Job.h Wed Sep 13 10:03:58 2017 @@ -97,8 +97,8 @@ public: virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const; - virtual int Execute(const StringRef **Redirects, std::string *ErrMsg, - bool *ExecutionFailed) const; + virtual int Execute(ArrayRef> Redirects, + std::string *ErrMsg, bool *ExecutionFailed) const; /// getSource - Return the Action which caused the creation of this job. const Action &getSource() const { return Source; } @@ -141,7 +141,7 @@ public: void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const override; - int Execute(const StringRef **Redirects, std::string *ErrMsg, + int Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override; private: @@ -158,7 +158,7 @@ public: void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const override; - int Execute(const StringRef **Redirects, std::string *ErrMsg, + int Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override; }; Modified: cfe/trunk/lib/Driver/Compilation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=313156&r1=313155&r2=313156&view=diff == --- cfe/trunk/lib/Driver/Compilation.cpp (original) +++ cfe/trunk/lib/Driver/Compilation.cpp Wed Sep 13 10:03:58 2017 @@ -26,8 +26,8 @@ Compilation::Compilation(const Driver &D InputArgList *_Args, DerivedArgList *_TranslatedArgs, bool ContainsError) : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u), - Args(_Args), TranslatedArgs(_TranslatedArgs), Redirects(nullptr), - ForDiagnostics(false), ContainsError(ContainsError) { + Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false), + ContainsError(ContainsError) { // The offloading host toolchain is the default tool chain. OrderedOffloadingToolchains.insert( std::make_pair(Action::OFK_Host, &DefaultToolChain)); @@ -41,14 +41,6 @@ Compilation::~Compilation() { for (auto Arg : TCArgs) if (Arg.second != TranslatedArgs) delete Arg.second; - - // Free redirections of stdout/stderr. - if (Redi
[PATCH] D37564: Update users of llvm::sys::ExecuteAndWait etc.
This revision was automatically updated to reflect the committed changes. Closed by commit rL313156: Update users of llvm::sys::ExecuteAndWait etc. (authored by alexfh). Repository: rL LLVM https://reviews.llvm.org/D37564 Files: cfe/trunk/include/clang/Driver/Compilation.h cfe/trunk/include/clang/Driver/Job.h cfe/trunk/lib/Driver/Compilation.cpp cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Index: cfe/trunk/include/clang/Driver/Compilation.h === --- cfe/trunk/include/clang/Driver/Compilation.h +++ cfe/trunk/include/clang/Driver/Compilation.h @@ -99,8 +99,8 @@ /// only be removed if we crash. ArgStringMap FailureResultFiles; - /// Redirection for stdout, stderr, etc. - const StringRef **Redirects; + /// Optional redirection for stdin, stdout, stderr. + std::vector> Redirects; /// Whether we're compiling for diagnostic purposes. bool ForDiagnostics; @@ -283,12 +283,10 @@ /// Redirect - Redirect output of this compilation. Can only be done once. /// - /// \param Redirects - array of pointers to paths. The array - /// should have a size of three. The inferior process's - /// stdin(0), stdout(1), and stderr(2) will be redirected to the - /// corresponding paths. This compilation instance becomes - /// the owner of Redirects and will delete the array and StringRef's. - void Redirect(const StringRef** Redirects); + /// \param Redirects - array of optional paths. The array should have a size + /// of three. The inferior process's stdin(0), stdout(1), and stderr(2) will + /// be redirected to the corresponding paths, if provided (not llvm::None). + void Redirect(ArrayRef> Redirects); }; } // end namespace driver Index: cfe/trunk/include/clang/Driver/Job.h === --- cfe/trunk/include/clang/Driver/Job.h +++ cfe/trunk/include/clang/Driver/Job.h @@ -97,8 +97,8 @@ virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const; - virtual int Execute(const StringRef **Redirects, std::string *ErrMsg, - bool *ExecutionFailed) const; + virtual int Execute(ArrayRef> Redirects, + std::string *ErrMsg, bool *ExecutionFailed) const; /// getSource - Return the Action which caused the creation of this job. const Action &getSource() const { return Source; } @@ -141,7 +141,7 @@ void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const override; - int Execute(const StringRef **Redirects, std::string *ErrMsg, + int Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override; private: @@ -158,7 +158,7 @@ void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo = nullptr) const override; - int Execute(const StringRef **Redirects, std::string *ErrMsg, + int Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override; }; Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -854,8 +854,7 @@ Ubiviz = *Path; const char *args[] = {Ubiviz.c_str(), Filename.c_str(), nullptr}; - if (llvm::sys::ExecuteAndWait(Ubiviz, &args[0], nullptr, nullptr, 0, 0, -&ErrMsg)) { + if (llvm::sys::ExecuteAndWait(Ubiviz, &args[0], nullptr, {}, 0, 0, &ErrMsg)) { llvm::errs() << "Error viewing graph: " << ErrMsg << "\n"; } Index: cfe/trunk/lib/Driver/Compilation.cpp === --- cfe/trunk/lib/Driver/Compilation.cpp +++ cfe/trunk/lib/Driver/Compilation.cpp @@ -26,8 +26,8 @@ InputArgList *_Args, DerivedArgList *_TranslatedArgs, bool ContainsError) : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u), - Args(_Args), TranslatedArgs(_TranslatedArgs), Redirects(nullptr), - ForDiagnostics(false), ContainsError(ContainsError) { + Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false), + ContainsError(ContainsError) { // The offloading host toolchain is the default tool chain. OrderedOffloadingToolchains.insert( std::make_pair(Action::OFK_Host, &DefaultToolChain)); @@ -41,14 +41,6 @@ for (auto Arg : TCArgs) if (Arg.second != TranslatedArgs) delete Arg.second; - - // Free redirections of stdout/stderr. - if (Redirects) { -delete Redirects[0]; -delete Redirects[1]; -delete Redirects[2]; -delete [] Redirects; - } } cons
[PATCH] D37785: [Fuchsia] Set ENABLE_X86_RELAX_RELOCATIONS for Fuchsia builds
phosek accepted this revision. phosek added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D37785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
Eugene.Zelenko added a comment. In https://reviews.llvm.org/D37808#869612, @JonasToth wrote: > In https://reviews.llvm.org/D37808#869602, @Eugene.Zelenko wrote: > > > I think will be good idea to extend -Wswitch diagnostics. > > > Ok. But it will introduce new warnings to llvm codebase itself. I prepare > some example output i found right now. If number of them will not be huge, it'll be worth to fix before extended -Wswitch will be committed. https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
lebedev.ri added a comment. What about GNU extension `case 1 ... 3:` ? https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313162 - Attempt to fix MSVC build.
Author: alexfh Date: Wed Sep 13 10:45:51 2017 New Revision: 313162 URL: http://llvm.org/viewvc/llvm-project?rev=313162&view=rev Log: Attempt to fix MSVC build. Modified: cfe/trunk/lib/Driver/Job.cpp Modified: cfe/trunk/lib/Driver/Job.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=313162&r1=313161&r2=313162&view=diff == --- cfe/trunk/lib/Driver/Job.cpp (original) +++ cfe/trunk/lib/Driver/Job.cpp Wed Sep 13 10:45:51 2017 @@ -14,6 +14,7 @@ #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" @@ -307,7 +308,7 @@ void Command::setEnvironment(llvm::Array Environment.push_back(nullptr); } -int Command::Execute(ArrayRef> Redirects, +int Command::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { SmallVector Argv; @@ -378,7 +379,7 @@ static bool ShouldFallback(int ExitCode) return ExitCode != 0; } -int FallbackCommand::Execute(ArrayRef> Redirects, +int FallbackCommand::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { int PrimaryStatus = Command::Execute(Redirects, ErrMsg, ExecutionFailed); if (!ShouldFallback(PrimaryStatus)) @@ -410,7 +411,7 @@ void ForceSuccessCommand::Print(raw_ostr OS << " || (exit 0)" << Terminator; } -int ForceSuccessCommand::Execute(ArrayRef> Redirects, +int ForceSuccessCommand::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed); ___ 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#869467, @aaron.ballman wrote: > In https://reviews.llvm.org/D37436#869462, @hfinkel wrote: > > > I think that I misunderstood your concern. Let me see if I can summarize > > your position: You believe that, when GCC implements this syntax in C, they > > will audit their attributes and not support all of their existing `gnu::` > > attributes in C. You only want us to support these when we know what that > > list will be (which we don't yet). Is that correct? > > > Yes, that is correct. Okay. A large fraction of the number of attributes we'll want to use are going to fall into this category (because Clang doesn't have its own attributes, but copied GCC's, for many things). I don't think we'll get good implementation feedback until we have this figured out. If we can't sync with GCC soon, I suggest just making a reasonable guess. My first choice would be to just allowing everything, and then we can see what people found to be useful and why. Our experience here can also provide feedback to GCC (and we can always update late if needed - it is still an experimental feature). https://reviews.llvm.org/D37436 ___ 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#869851, @hfinkel wrote: > In https://reviews.llvm.org/D37436#869467, @aaron.ballman wrote: > > > In https://reviews.llvm.org/D37436#869462, @hfinkel wrote: > > > > > I think that I misunderstood your concern. Let me see if I can summarize > > > your position: You believe that, when GCC implements this syntax in C, > > > they will audit their attributes and not support all of their existing > > > `gnu::` attributes in C. You only want us to support these when we know > > > what that list will be (which we don't yet). Is that correct? > > > > > > Yes, that is correct. > > > Okay. A large fraction of the number of attributes we'll want to use are > going to fall into this category (because Clang doesn't have its own > attributes, but copied GCC's, for many things). I don't think we'll get good > implementation feedback until we have this figured out. If we can't sync with > GCC soon, I suggest just making a reasonable guess. My first choice would be > to just allowing everything, and then we can see what people found to be > useful and why. Our experience here can also provide feedback to GCC (and we > can always update late if needed - it is still an experimental feature). I think this direction is a reasonable one, but not for the initial syntax patch. I would prefer to be conservative and get the basic syntax in first. My plan is that once the syntax is available, I would start adding more attributes, starting with the ones proposed to WG14, followed by the existing C++ ones in the clang namespace. I think the gnu attributes would likely be immediately following the clang ones, so they're definitely a high priority for me to support. Btw, because I wasn't explicit about this, we're in violent agreement that getting implementation experience about how well we can share attributes between C and C++ code bases is also an important question to answer. https://reviews.llvm.org/D37436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
JonasToth added a comment. In https://reviews.llvm.org/D37808#869823, @lebedev.ri wrote: > What about GNU extension `case 1 ... 3:` ? Strictly speaking, the coding standard (which should be enforced by the patch) requires strict ISO C++11, therefore this extension is not considered directly. Does clang support this extension? When this would be a warning, then that case should be added as well. https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37703: [AMDGPU] Change addr space of clk_event_t, queue_t and reserve_id_t to global
b-sumner accepted this revision. b-sumner added a comment. This revision is now accepted and ready to land. Looks good to me. https://reviews.llvm.org/D37703 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37808: [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches
lebedev.ri added a comment. In https://reviews.llvm.org/D37808#869879, @JonasToth wrote: > In https://reviews.llvm.org/D37808#869823, @lebedev.ri wrote: > > > What about GNU extension `case 1 ... 3:` ? > > > Strictly speaking, the coding standard (which should be enforced by the > patch) requires strict ISO C++11, therefore this extension is not considered > directly. > Does clang support this extension? It does: test.cpp:3:12: warning: use of GNU case range extension [-Wgnu-case-range] case 1 ... 3: ^ > When this would be a warning, then that case should be added as well. https://reviews.llvm.org/D37808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37787: Driver: Make -fwhole-program-vtables a core option so it can be used from clang-cl.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D37787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313169 - Driver: Make -fwhole-program-vtables a core option so it can be used from clang-cl.
Author: pcc Date: Wed Sep 13 11:36:07 2017 New Revision: 313169 URL: http://llvm.org/viewvc/llvm-project?rev=313169&view=rev Log: Driver: Make -fwhole-program-vtables a core option so it can be used from clang-cl. Also add some missing driver tests for the regular clang driver. Differential Revision: https://reviews.llvm.org/D37787 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/Driver/whole-program-vtables.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=313169&r1=313168&r2=313169&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed Sep 13 11:36:07 2017 @@ -1502,9 +1502,10 @@ def fvisibility_ms_compat : Flag<["-"], HelpText<"Give global types 'default' visibility and global functions and " "variables 'hidden' visibility by default">; def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, Group, - Flags<[CC1Option]>, + Flags<[CoreOption, CC1Option]>, HelpText<"Enables whole-program vtable optimization. Requires -flto">; -def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group; +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group, + Flags<[CoreOption]>; def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, HelpText<"Treat signed integer overflow as two's complement">; def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, Flags<[CC1Option]>, Modified: cfe/trunk/test/Driver/whole-program-vtables.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/whole-program-vtables.c?rev=313169&r1=313168&r2=313169&view=diff == --- cfe/trunk/test/Driver/whole-program-vtables.c (original) +++ cfe/trunk/test/Driver/whole-program-vtables.c Wed Sep 13 11:36:07 2017 @@ -1,2 +1,11 @@ // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s // NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto' + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// LTO: "-fwhole-program-vtables" + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// LTO-DISABLE-NOT: "-fwhole-program-vtables" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37787: Driver: Make -fwhole-program-vtables a core option so it can be used from clang-cl.
This revision was automatically updated to reflect the committed changes. Closed by commit rL313169: Driver: Make -fwhole-program-vtables a core option so it can be used from clang… (authored by pcc). Changed prior to commit: https://reviews.llvm.org/D37787?vs=114960&id=115082#toc Repository: rL LLVM https://reviews.llvm.org/D37787 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/Driver/whole-program-vtables.c Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1502,9 +1502,10 @@ HelpText<"Give global types 'default' visibility and global functions and " "variables 'hidden' visibility by default">; def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, Group, - Flags<[CC1Option]>, + Flags<[CoreOption, CC1Option]>, HelpText<"Enables whole-program vtable optimization. Requires -flto">; -def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group; +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group, + Flags<[CoreOption]>; def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, HelpText<"Treat signed integer overflow as two's complement">; def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, Flags<[CC1Option]>, Index: cfe/trunk/test/Driver/whole-program-vtables.c === --- cfe/trunk/test/Driver/whole-program-vtables.c +++ cfe/trunk/test/Driver/whole-program-vtables.c @@ -1,2 +1,11 @@ // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s // NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto' + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// LTO: "-fwhole-program-vtables" + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// LTO-DISABLE-NOT: "-fwhole-program-vtables" Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1502,9 +1502,10 @@ HelpText<"Give global types 'default' visibility and global functions and " "variables 'hidden' visibility by default">; def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, Group, - Flags<[CC1Option]>, + Flags<[CoreOption, CC1Option]>, HelpText<"Enables whole-program vtable optimization. Requires -flto">; -def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group; +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, Group, + Flags<[CoreOption]>; def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, HelpText<"Treat signed integer overflow as two's complement">; def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, Flags<[CC1Option]>, Index: cfe/trunk/test/Driver/whole-program-vtables.c === --- cfe/trunk/test/Driver/whole-program-vtables.c +++ cfe/trunk/test/Driver/whole-program-vtables.c @@ -1,2 +1,11 @@ // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s // NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto' + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// LTO: "-fwhole-program-vtables" + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// LTO-DISABLE-NOT: "-fwhole-program-vtables" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37322: [Sema] Correct typos in LHS, RHS before building a binop expression.
vsapsai added a comment. Correcting typo in Sema::ActOnMemberAccessExpr is an interesting idea and it almost works. After such change there is a single failure in clang/test/SemaCXX/typo-correction-cxx11.cpp void run(A *annotations) { map new_annotations; auto &annotation = *annotations; auto new_it = new_annotations.find(5); auto &new_anotation = new_it.second; // expected-note {{'new_anotation' declared here}} new_annotation->Swap(&annotation); // expected-error {{use of undeclared identifier 'new_annotation'; did you mean 'new_anotation'?}} } because we don't mention `did you mean 'new_anotation'?` anymore. I haven't investigated in depth what's causing it but my guess is that general typo correction doesn't suggest replacement due to ambiguity between new_anotation and new_annotations, and prevents member-specific typo correction from handling it. I think having CXXDependentScopeMemberExpr for an ObjC property should be fine as we are dealing with invalid code and all typos are already type-dependent and instantiation-dependent though it doesn't apply to ObjC. I agree that my fix isn't specific to the code triggering the assertion. But broader fix can be useful as it covers more cases. After checking SemaExpr.cpp and its multiple CorrectDelayedTyposInExpr, CorrectTypo, CorrectTypoDelayed I have an impression that typo correction absent in Sema::BuildBinOp is an omission worth fixing. https://reviews.llvm.org/D37322 ___ 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 updated this revision to Diff 115085. vivekvpandya added a comment. update https://reviews.llvm.org/D37196 Files: lib/CodeGen/CodeGenAction.cpp Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -46,6 +46,31 @@ using namespace llvm; namespace clang { + class BackendConsumer; + class ClangDiagnosticHandler final : public DiagnosticHandler { + public: +ClangDiagnosticHandler(const CodeGenOptions &CGOpts, BackendConsumer *BCon) +: CodeGenOpts(CGOpts), BackendCon(BCon) {} + +bool handleDiagnostics(const DiagnosticInfo &DI) override; +bool isAnalysisRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkAnalysisPattern && + CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName)); +} +bool isMissedOptRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkMissedPattern && + CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName)); +} +bool isPassedOptRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkPattern && + CodeGenOpts.OptimizationRemarkPattern->match(PassName)); +} + + private: +const CodeGenOptions &CodeGenOpts; +BackendConsumer *BackendCon; + }; + class BackendConsumer : public ASTConsumer { using LinkModule = CodeGenAction::LinkModule; @@ -224,10 +249,10 @@ void *OldContext = Ctx.getInlineAsmDiagnosticContext(); Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this); - LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = + std::unique_ptr OldDiagnosticHandler = Ctx.getDiagnosticHandler(); - void *OldDiagnosticContext = Ctx.getDiagnosticContext(); - Ctx.setDiagnosticHandler(DiagnosticHandler, this); + Ctx.setDiagnosticHandler(llvm::make_unique( +CodeGenOpts, this)); Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness); if (CodeGenOpts.DiagnosticsHotnessThreshold != 0) Ctx.setDiagnosticsHotnessThreshold( @@ -264,7 +289,7 @@ Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext); - Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext); + Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler)); if (OptRecordFile) OptRecordFile->keep(); @@ -299,11 +324,6 @@ ((BackendConsumer*)Context)->InlineAsmDiagHandler2(SM, Loc); } -static void DiagnosticHandler(const llvm::DiagnosticInfo &DI, - void *Context) { - ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI); -} - /// Get the best possible source location to represent a diagnostic that /// may have associated debug info. const FullSourceLoc @@ -343,6 +363,11 @@ void BackendConsumer::anchor() {} } +bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) { + BackendCon->DiagnosticHandlerImpl(DI); + return true; +} + /// ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr /// buffer to be a valid FullSourceLoc. static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D, Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -46,6 +46,31 @@ using namespace llvm; namespace clang { + class BackendConsumer; + class ClangDiagnosticHandler final : public DiagnosticHandler { + public: +ClangDiagnosticHandler(const CodeGenOptions &CGOpts, BackendConsumer *BCon) +: CodeGenOpts(CGOpts), BackendCon(BCon) {} + +bool handleDiagnostics(const DiagnosticInfo &DI) override; +bool isAnalysisRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkAnalysisPattern && + CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName)); +} +bool isMissedOptRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkMissedPattern && + CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName)); +} +bool isPassedOptRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkPattern && + CodeGenOpts.OptimizationRemarkPattern->match(PassName)); +} + + private: +const CodeGenOptions &CodeGenOpts; +BackendConsumer *BackendCon; + }; + class BackendConsumer : public ASTConsumer { using LinkModule = CodeGenAction::LinkModule; @@ -224,10 +249,10 @@ void *OldContext = Ctx.getInlineAsmDiagnosticContext(); Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this); - LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = + std::unique_ptr OldDiagnosticHandler = Ctx.getD
[PATCH] D33514: [WIP] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
vivekvpandya updated this revision to Diff 115086. vivekvpandya added a comment. Added method to detach unique_ptr from LLVMContext. 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; - Co
r313171 - [AMDGPU] Change addr space of clk_event_t, queue_t and reserve_id_t to global
Author: yaxunl Date: Wed Sep 13 11:50:42 2017 New Revision: 313171 URL: http://llvm.org/viewvc/llvm-project?rev=313171&view=rev Log: [AMDGPU] Change addr space of clk_event_t, queue_t and reserve_id_t to global Differential Revision: https://reviews.llvm.org/D37703 Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=313171&r1=313170&r2=313171&view=diff == --- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original) +++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Wed Sep 13 11:50:42 2017 @@ -202,6 +202,10 @@ public: case BuiltinType::Id: \ return LangAS::opencl_constant; #include "clang/Basic/OpenCLImageTypes.def" +case BuiltinType::OCLClkEvent: +case BuiltinType::OCLQueue: +case BuiltinType::OCLReserveID: + return LangAS::opencl_global; default: return TargetInfo::getOpenCLTypeAddrSpace(T); Modified: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/opencl_types.cl?rev=313171&r1=313170&r2=313171&view=diff == --- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Wed Sep 13 11:50:42 2017 @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-SPIR +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-AMDGCN #define CLK_ADDRESS_CLAMP_TO_EDGE 2 #define CLK_NORMALIZED_COORDS_TRUE 1 @@ -7,7 +7,7 @@ #define CLK_FILTER_LINEAR 0x20 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_NEAREST; -// CHECK-SPIR-NOT: constant i32 +// CHECK-COM-NOT: constant i32 void fnc1(image1d_t img) {} // CHECK-SPIR: @fnc1(%opencl.image1d_ro_t addrspace(1)* @@ -39,20 +39,23 @@ void fnc4smp(sampler_t s) {} kernel void foo(image1d_t img) { sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_LINEAR; - // CHECK-SPIR: alloca %opencl.sampler_t addrspace(2)* + // CHECK-COM: alloca %opencl.sampler_t addrspace(2)* event_t evt; - // CHECK-SPIR: alloca %opencl.event_t* + // CHECK-COM: alloca %opencl.event_t* clk_event_t clk_evt; // CHECK-SPIR: alloca %opencl.clk_event_t* + // CHECK-AMDGCN: alloca %opencl.clk_event_t addrspace(1)* queue_t queue; // CHECK-SPIR: alloca %opencl.queue_t* + // CHECK-AMDGCN: alloca %opencl.queue_t addrspace(1)* reserve_id_t rid; // CHECK-SPIR: alloca %opencl.reserve_id_t* - // CHECK-SPIR: store %opencl.sampler_t addrspace(2)* + // CHECK-AMDGCN: alloca %opencl.reserve_id_t addrspace(1)* + // CHECK-COM: store %opencl.sampler_t addrspace(2)* fnc4smp(smp); - // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* + // CHECK-COM: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* fnc4smp(glb_smp); - // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* + // CHECK-COM: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* } kernel void foo_pipe(read_only pipe int p) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37703: [AMDGPU] Change addr space of clk_event_t, queue_t and reserve_id_t to global
This revision was automatically updated to reflect the committed changes. Closed by commit rL313171: [AMDGPU] Change addr space of clk_event_t, queue_t and reserve_id_t to global (authored by yaxunl). Changed prior to commit: https://reviews.llvm.org/D37703?vs=114642&id=115088#toc Repository: rL LLVM https://reviews.llvm.org/D37703 Files: cfe/trunk/lib/Basic/Targets/AMDGPU.h cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Index: cfe/trunk/lib/Basic/Targets/AMDGPU.h === --- cfe/trunk/lib/Basic/Targets/AMDGPU.h +++ cfe/trunk/lib/Basic/Targets/AMDGPU.h @@ -202,6 +202,10 @@ case BuiltinType::Id: \ return LangAS::opencl_constant; #include "clang/Basic/OpenCLImageTypes.def" +case BuiltinType::OCLClkEvent: +case BuiltinType::OCLQueue: +case BuiltinType::OCLReserveID: + return LangAS::opencl_global; default: return TargetInfo::getOpenCLTypeAddrSpace(T); Index: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl === --- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl +++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-SPIR +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-AMDGCN #define CLK_ADDRESS_CLAMP_TO_EDGE 2 #define CLK_NORMALIZED_COORDS_TRUE 1 #define CLK_FILTER_NEAREST 0x10 #define CLK_FILTER_LINEAR 0x20 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_NEAREST; -// CHECK-SPIR-NOT: constant i32 +// CHECK-COM-NOT: constant i32 void fnc1(image1d_t img) {} // CHECK-SPIR: @fnc1(%opencl.image1d_ro_t addrspace(1)* @@ -39,20 +39,23 @@ kernel void foo(image1d_t img) { sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE|CLK_NORMALIZED_COORDS_TRUE|CLK_FILTER_LINEAR; - // CHECK-SPIR: alloca %opencl.sampler_t addrspace(2)* + // CHECK-COM: alloca %opencl.sampler_t addrspace(2)* event_t evt; - // CHECK-SPIR: alloca %opencl.event_t* + // CHECK-COM: alloca %opencl.event_t* clk_event_t clk_evt; // CHECK-SPIR: alloca %opencl.clk_event_t* + // CHECK-AMDGCN: alloca %opencl.clk_event_t addrspace(1)* queue_t queue; // CHECK-SPIR: alloca %opencl.queue_t* + // CHECK-AMDGCN: alloca %opencl.queue_t addrspace(1)* reserve_id_t rid; // CHECK-SPIR: alloca %opencl.reserve_id_t* - // CHECK-SPIR: store %opencl.sampler_t addrspace(2)* + // CHECK-AMDGCN: alloca %opencl.reserve_id_t addrspace(1)* + // CHECK-COM: store %opencl.sampler_t addrspace(2)* fnc4smp(smp); - // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* + // CHECK-COM: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* fnc4smp(glb_smp); - // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* + // CHECK-COM: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* } kernel void foo_pipe(read_only pipe int p) {} Index: cfe/trunk/lib/Basic/Targets/AMDGPU.h === --- cfe/trunk/lib/Basic/Targets/AMDGPU.h +++ cfe/trunk/lib/Basic/Targets/AMDGPU.h @@ -202,6 +202,10 @@ case BuiltinType::Id:\ return LangAS::opencl_constant; #include "clang/Basic/OpenCLImageTypes.def" +case BuiltinType::OCLClkEvent: +case BuiltinType::OCLQueue: +case BuiltinType::OCLReserveID: + return LangAS::opencl_global; default: return TargetInfo::getOpenCLTypeAddrSpace(T); Index: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl === --- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl +++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR -// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-SPIR +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefixes=CHECK-COM,CHECK-AMDGCN #define CLK_ADDRESS_CLAMP_TO_EDGE 2 #define CLK_NORMALIZED_COORDS_TRUE 1 #define CLK_FILTER_NEAREST 0x10 #define CLK_FILTER_LINEAR
[PATCH] D37818: [lit] Update clang and lld to use the new shared LLVMConfig stuff
zturner created this revision. Herald added a reviewer: modocache. Herald added a subscriber: fedor.sergeev. This is probably the last work I'm going to do here for a while. I still see some room for improvement, but I think after this patch: a) refactor begins to have diminishing returns b) There's a sufficient amount of sharing and re-use to validate the design c) There's enough specific examples of how to use this that other projects (e.g. compiler-rt, etc) can use those as a model of how to simplify their own configs. In other words, I'm not brave enough to touch compiler-rt's config files :) There's some minor changes in the config api that increase flexibility in how you override environment variables and spawn an external `llvm-config`, but otherwise this is mostly just deleting code. https://reviews.llvm.org/D37818 Files: clang/test/lit.cfg clang/test/lit.site.cfg.in lld/test/lit.cfg lld/test/lit.site.cfg.in llvm/test/lit.cfg llvm/utils/lit/lit/llvm/config.py Index: llvm/utils/lit/lit/llvm/config.py === --- llvm/utils/lit/lit/llvm/config.py +++ llvm/utils/lit/lit/llvm/config.py @@ -1,4 +1,5 @@ import os +import platform import re import subprocess import sys @@ -23,35 +24,40 @@ # Tweak PATH for Win32 to decide to use bash.exe or not. if sys.platform == 'win32': -# For tests that require Windows to run. -features.add('system-windows') - # Seek sane tools in directories and set to $PATH. path = self.lit_config.getToolsPath(config.lit_tools_dir, config.environment['PATH'], ['cmp.exe', 'grep.exe', 'sed.exe']) self.with_environment('PATH', path, append_path=True) -if use_lit_shell: -# 0 is external, "" is default, and everything else is internal. -self.use_lit_shell = (use_lit_shell != "0") -else: -# Otherwise we default to internal on Windows and external elsewhere, as -# bash on Windows is usually very slow. -self.use_lit_shell = (sys.platform in ['win32']) +self.with_environment('LLVM_SRC_ROOT', config.llvm_src_root) self.use_lit_shell = litsh -if not self.litsh: +if not litsh: features.add('shell') + +# Running on Darwin OS +if platform.system() in ['Darwin']: +# FIXME: lld uses the first, other projects use the second. +# We should standardize on the former. +features.add('system-linker-mach-o') +features.add('system-darwin') +elif platform.system() in ['Windows']: +# For tests that require Windows to run. +features.add('system-windows') + # Native compilation: host arch == default triple arch -# FIXME: Consider cases that target can be executed -# even if host_triple were different from target_triple. -if config.host_triple == config.target_triple: +# Both of these values should probably be in every site config (e.g. as +# part of the standard header. But currently they aren't) +host_triple = getattr(config, 'host_triple', None) +target_triple = getattr(config, 'target_triple', None) +if host_triple and host_triple == target_triple: features.add("native") # Sanitizers. -sanitizers = frozenset(x.lower() for x in getattr(config, 'llvm_use_sanitizer', []).split(';')) +sanitizers = getattr(config, 'llvm_use_sanitizer', '') +sanitizers = frozenset(x.lower() for x in sanitizers.split(';')) features.add(binary_feature('address' in sanitizers, 'asan', 'not_')) features.add(binary_feature('memory' in sanitizers, 'msan', 'not_')) features.add(binary_feature('undefined' in sanitizers, 'ubsan', 'not_')) @@ -64,7 +70,6 @@ if lit.util.pythonize_bool(long_tests): features.add("long_tests") -target_triple = getattr(config, 'target_triple', None) if target_triple: if re.match(r'^x86_64.*-linux', target_triple): features.add("x86_64-linux") @@ -80,25 +85,34 @@ if gmalloc_path_str is not None: self.with_environment('DYLD_INSERT_LIBRARIES', gmalloc_path_str) -breaking_checks = getattr(config, 'enable_abi_breaking_checks') -if lit.util.pythonize_bool(lit_config, breaking_checks): +breaking_checks = getattr(config, 'enable_abi_breaking_checks', None) +if lit.util.pythonize_bool(breaking_checks): features.add('abi-breaking-checks') def with_environment(self, variable, value, append_path = False): -if append_path and variable in self.config.environment: +if append_path: +# For paths, we should be able to take a list
r313172 - Add more tests for OpenCL atomic builtin functions
Author: yaxunl Date: Wed Sep 13 11:56:25 2017 New Revision: 313172 URL: http://llvm.org/viewvc/llvm-project?rev=313172&view=rev Log: Add more tests for OpenCL atomic builtin functions Add tests for different address spaces and insert some blank lines to make them more readable. Differential Revision: https://reviews.llvm.org/D37742 Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl?rev=313172&r1=313171&r2=313172&view=diff == --- cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl Wed Sep 13 11:56:25 2017 @@ -18,39 +18,64 @@ typedef enum memory_scope { #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 @__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(pi, 1, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_add_4(i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) // ARM: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) x = __opencl_atomic_fetch_add(i, 3, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_min_4(i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) // ARM: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_min_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) x = __opencl_atomic_fetch_min(i, 3, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_umin_4(i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) // ARM: {{%[^ ]*}} = call i32 @__opencl_atomic_fetch_umin_4(i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 1) x = __opencl_atomic_fetch_min(ui, 3, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8 addrspace(4)* {{%[0-9]+}}, i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 5, i32 1) // ARM: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8* {{%[0-9]+}}, i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 5, i32 1) x = __opencl_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8 addrspace(4)* {{%[0-9]+}}, i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 5, i32 1) // ARM: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8* {{%[0-9]+}}, i8* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 5, i32 1) x = __opencl_atomic_compare_exchange_weak(i, &cmp, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group); + // SPIR: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8 addrspace(4)* {{%[0-9]+}}, i8 addrspace(4)* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 5, i32 5, i32 2) // ARM: {{%[^ ]*}} = call zeroext i1 @__opencl_atomic_compare_exchange_4(i8* {{%[
[PATCH] D37742: Add more tests for OpenCL atomic builtin functions
This revision was automatically updated to reflect the committed changes. Closed by commit rL313172: Add more tests for OpenCL atomic builtin functions (authored by yaxunl). Changed prior to commit: https://reviews.llvm.org/D37742?vs=114824&id=115090#toc Repository: rL LLVM https://reviews.llvm.org/D37742 Files: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl Index: cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl === --- cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl +++ cfe/trunk/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: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl === --- cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl +++ cfe/trunk/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*
Re: [libcxx] r250235 - [libcxx] Capture configuration information when installing the libc++ headers
On 13 October 2015 at 15:12, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ericwf > Date: Tue Oct 13 17:12:02 2015 > New Revision: 250235 > > URL: http://llvm.org/viewvc/llvm-project?rev=250235&view=rev > Log: > [libcxx] Capture configuration information when installing the libc++ > headers > > Summary: > Hi all, > > This patch is a successor to D11963. However it has changed dramatically > and I felt it would be best to start a new review thread. > > Please read the design documentation added in this patch for a description > of how it works. > > Reviewers: mclow.lists, danalbert, jroelofs, EricWF > > Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, > cfe-commits > > Differential Revision: http://reviews.llvm.org/D13407 > > Added: > libcxx/trunk/docs/DesignDocs/ > libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst > libcxx/trunk/include/__config_site.in > Modified: > libcxx/trunk/CMakeLists.txt > libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake > libcxx/trunk/docs/index.rst > libcxx/trunk/include/CMakeLists.txt > > Modified: libcxx/trunk/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/ > CMakeLists.txt?rev=250235&r1=250234&r2=250235&view=diff > > == > --- libcxx/trunk/CMakeLists.txt (original) > +++ libcxx/trunk/CMakeLists.txt Tue Oct 13 17:12:02 2015 > @@ -260,13 +260,6 @@ endif() > > # Feature flags == > = > define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) > -define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE > -D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) > -define_if_not(LIBCXX_ENABLE_STDIN -D_LIBCPP_HAS_NO_STDIN) > -define_if_not(LIBCXX_ENABLE_STDOUT -D_LIBCPP_HAS_NO_STDOUT) > -define_if_not(LIBCXX_ENABLE_THREADS -D_LIBCPP_HAS_NO_THREADS) > -define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK -D_LIBCPP_HAS_NO_MONOTONIC_ > CLOCK) > -define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS > -D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) > - > > # Sanitizer flags == > === > > @@ -303,6 +296,22 @@ if (LIBCXX_BUILT_STANDALONE) > message(WARNING "LLVM_USE_SANITIZER is not supported on this > platform.") >endif() > endif() > + > +# Configuration file flags == > === > +config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE > _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) > +config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) > +config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) > +config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) > +config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK > _LIBCPP_HAS_NO_MONOTONIC_CLOCK) > +config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS > _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) > + > +if (LIBCXX_NEEDS_SITE_CONFIG) > + configure_file( > +include/__config_site.in > +${LIBCXX_BINARY_DIR}/__config_site > +@ONLY) > +endif() > + > #=== > > # Setup Source Code And Tests > #=== > > > Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/ > Modules/HandleLibcxxFlags.cmake?rev=250235&r1=250234&r2=250235&view=diff > > == > --- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original) > +++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Tue Oct 13 > 17:12:02 2015 > @@ -49,6 +49,22 @@ macro(define_if_not condition def) >endif() > endmacro() > > +macro(config_define_if condition def) > + if (${condition}) > +set(${def} ON) > +add_definitions(-D${def}) > +set(LIBCXX_NEEDS_SITE_CONFIG ON) > + endif() > +endmacro() > + > +macro(config_define_if_not condition def) > + if (NOT ${condition}) > +set(${def} ON) > +add_definitions(-D${def}) > +set(LIBCXX_NEEDS_SITE_CONFIG ON) > + endif() > +endmacro() > + > # Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and > # 'LIBCXX_LINK_FLAGS'. > macro(add_flags) > > Added: libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/ > CapturingConfigInfo.rst?rev=250235&view=auto > > == > --- libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst (added) > +++ libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst Tue Oct 13 > 17:12:02 2015 > @@ -0,0 +1,88 @@ > +=== > +Capturing configuration information during installation > +=== > + > +.. contents:: > + :loc
Re: [libcxx] r250235 - [libcxx] Capture configuration information when installing the libc++ headers
On Wed, Sep 13, 2017 at 1:02 PM, Richard Smith wrote: > On 13 October 2015 at 15:12, Eric Fiselier via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: ericwf >> Date: Tue Oct 13 17:12:02 2015 >> New Revision: 250235 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=250235&view=rev >> Log: >> [libcxx] Capture configuration information when installing the libc++ >> headers >> >> Summary: >> Hi all, >> >> This patch is a successor to D11963. However it has changed dramatically >> and I felt it would be best to start a new review thread. >> >> Please read the design documentation added in this patch for a >> description of how it works. >> >> Reviewers: mclow.lists, danalbert, jroelofs, EricWF >> >> Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, >> cfe-commits >> >> Differential Revision: http://reviews.llvm.org/D13407 >> >> Added: >> libcxx/trunk/docs/DesignDocs/ >> libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst >> libcxx/trunk/include/__config_site.in >> Modified: >> libcxx/trunk/CMakeLists.txt >> libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake >> libcxx/trunk/docs/index.rst >> libcxx/trunk/include/CMakeLists.txt >> >> Modified: libcxx/trunk/CMakeLists.txt >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >> txt?rev=250235&r1=250234&r2=250235&view=diff >> >> == >> --- libcxx/trunk/CMakeLists.txt (original) >> +++ libcxx/trunk/CMakeLists.txt Tue Oct 13 17:12:02 2015 >> @@ -260,13 +260,6 @@ endif() >> >> # Feature flags == >> = >> define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) >> -define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE >> -D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) >> -define_if_not(LIBCXX_ENABLE_STDIN -D_LIBCPP_HAS_NO_STDIN) >> -define_if_not(LIBCXX_ENABLE_STDOUT -D_LIBCPP_HAS_NO_STDOUT) >> -define_if_not(LIBCXX_ENABLE_THREADS -D_LIBCPP_HAS_NO_THREADS) >> -define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK >> -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK) >> -define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS >> -D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) >> - >> >> # Sanitizer flags == >> === >> >> @@ -303,6 +296,22 @@ if (LIBCXX_BUILT_STANDALONE) >> message(WARNING "LLVM_USE_SANITIZER is not supported on this >> platform.") >>endif() >> endif() >> + >> +# Configuration file flags == >> === >> +config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE >> _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) >> +config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) >> +config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) >> +config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) >> +config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK >> _LIBCPP_HAS_NO_MONOTONIC_CLOCK) >> +config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS >> _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) >> + >> +if (LIBCXX_NEEDS_SITE_CONFIG) >> + configure_file( >> +include/__config_site.in >> +${LIBCXX_BINARY_DIR}/__config_site >> +@ONLY) >> +endif() >> + >> #== >> = >> # Setup Source Code And Tests >> #== >> = >> >> Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modul >> es/HandleLibcxxFlags.cmake?rev=250235&r1=250234&r2=250235&view=diff >> >> == >> --- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original) >> +++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Tue Oct 13 >> 17:12:02 2015 >> @@ -49,6 +49,22 @@ macro(define_if_not condition def) >>endif() >> endmacro() >> >> +macro(config_define_if condition def) >> + if (${condition}) >> +set(${def} ON) >> +add_definitions(-D${def}) >> +set(LIBCXX_NEEDS_SITE_CONFIG ON) >> + endif() >> +endmacro() >> + >> +macro(config_define_if_not condition def) >> + if (NOT ${condition}) >> +set(${def} ON) >> +add_definitions(-D${def}) >> +set(LIBCXX_NEEDS_SITE_CONFIG ON) >> + endif() >> +endmacro() >> + >> # Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and >> # 'LIBCXX_LINK_FLAGS'. >> macro(add_flags) >> >> Added: libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/Design >> Docs/CapturingConfigInfo.rst?rev=250235&view=auto >> >> == >> --- libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst (added) >> +++ libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst Tue Oct 13 >> 17:12:02 2015 >> @@ -0,0 +1,88 @@ >> +===
r313173 - [Fuchsia] Set ENABLE_X86_RELAX_RELOCATIONS for Fuchsia builds
Author: phosek Date: Wed Sep 13 12:17:41 2017 New Revision: 313173 URL: http://llvm.org/viewvc/llvm-project?rev=313173&view=rev Log: [Fuchsia] Set ENABLE_X86_RELAX_RELOCATIONS for Fuchsia builds This is a "Does your linker support it?" option, and all ours do. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D37785 Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=313173&r1=313172&r2=313173&view=diff == --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original) +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Wed Sep 13 12:17:41 2017 @@ -18,6 +18,13 @@ if(NOT APPLE) set(CLANG_DEFAULT_LINKER lld CACHE STRING "") endif() +# This is a "Does your linker support it?" option that only applies +# to x86-64 ELF targets. All Fuchsia target linkers do support it. +# For x86-64 Linux, it's supported by LLD and by GNU linkers since +# binutils 2.27, so one can hope that all Linux hosts in use handle it. +# Ideally this would be settable as a per-target option. +set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") + if(APPLE) set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "") endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37785: [Fuchsia] Set ENABLE_X86_RELAX_RELOCATIONS for Fuchsia builds
This revision was automatically updated to reflect the committed changes. Closed by commit rL313173: [Fuchsia] Set ENABLE_X86_RELAX_RELOCATIONS for Fuchsia builds (authored by phosek). Changed prior to commit: https://reviews.llvm.org/D37785?vs=114956&id=115094#toc Repository: rL LLVM https://reviews.llvm.org/D37785 Files: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake === --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake @@ -18,6 +18,13 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "") endif() +# This is a "Does your linker support it?" option that only applies +# to x86-64 ELF targets. All Fuchsia target linkers do support it. +# For x86-64 Linux, it's supported by LLD and by GNU linkers since +# binutils 2.27, so one can hope that all Linux hosts in use handle it. +# Ideally this would be settable as a per-target option. +set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") + if(APPLE) set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "") endif() Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake === --- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake +++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake @@ -18,6 +18,13 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "") endif() +# This is a "Does your linker support it?" option that only applies +# to x86-64 ELF targets. All Fuchsia target linkers do support it. +# For x86-64 Linux, it's supported by LLD and by GNU linkers since +# binutils 2.27, so one can hope that all Linux hosts in use handle it. +# Ideally this would be settable as a per-target option. +set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") + if(APPLE) set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "") endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37818: [lit] Update clang and lld to use the new shared LLVMConfig stuff
rnk added inline comments. Comment at: llvm/utils/lit/lit/llvm/config.py:92 def with_environment(self, variable, value, append_path = False): +if append_path: Rather than having an optional parameter that makes this append, maybe have a new method that calls this one after doing the path appending. How about `append_environment_path(var, value)` or something? https://reviews.llvm.org/D37818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37818: [lit] Update clang and lld to use the new shared LLVMConfig stuff
dlj added inline comments. Comment at: clang/test/lit.cfg:23 # the test runner updated. -config.test_format = lit.formats.ShTest(execute_external) +config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) Minor nit: it seems reasonable enough to name this parameter: ShTest(execute_external=(not llvm_config.use_lit_shell)) (I don't think that's a problem for ShTest.__init__, and has the benefit of failing if the parameter name changes. Imagine if someone added another default-valued bool argument to ShTest.__init__...) Comment at: llvm/utils/lit/lit/llvm/config.py:93 def with_environment(self, variable, value, append_path = False): -if append_path and variable in self.config.environment: +if append_path: +# For paths, we should be able to take a list of them and process all Looking at the callers of this... should the path-append logic be a separate function? For example: llvm_config.with_environment('PATH', [config.llvm_tools_dir, config.clang_tools_dir], append_path=True) versus maybe this: llvm_config.append_env_pathvar('PATH', [config.llvm_tools_dir, config.clang_tools_dir]) Comment at: llvm/utils/lit/lit/llvm/config.py:128-129 +def clear_environment(self, variables): +for name in variables: +if name in self.config.environment: +del self.config.environment[name] You could also say: ``` for name in variables: self.config.environment.pop(name, None) ``` Comment at: llvm/utils/lit/lit/llvm/config.py:132 + +def feature_config(self, features, encoding = 'ascii'): +# Ask llvm-config about the specified feature. I think the expected format of the 'features' arg is complex enough that you should add a docstring that explains it... Comment at: llvm/utils/lit/lit/llvm/config.py:134 +# Ask llvm-config about the specified feature. +arguments = [x for (x, _) in features] try: I think you could probably just use features.keys() for this, no? Comment at: llvm/utils/lit/lit/llvm/config.py:147 +output = output.decode(encoding) +lines = output.split('\n') +for (line, (_, patterns)) in zip(lines, features): You might want to use splitlines() for Windows compatibility. https://reviews.llvm.org/D37818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct
yaxunl created this revision. Currently block is translated to a structure equivalent to struct Block { void *isa; int flags; int reserved; void *invoke; void *descriptor; }; Except `invoke`, which is the pointer to the block invoke function, all other fields are useless for OpenCL, which clutter the IR and also waste memory since the block struct is passed to the block invoke function as argument. On the other hand, the size and alignment of the block struct is not stored in the struct, which causes difficulty to implement __enqueue_kernel as library function, since the library function needs to know the size and alignment of the argument which needs to be passed to the kernel. This patch removes the useless fields from the block struct and adds size and align fields. The equivalent block struct will become struct Block { int size; int align; generic void *invoke; }; It also changes the pointer to the invoke function to be a generic pointer since the address space of a function may not be private on certain targets. https://reviews.llvm.org/D37822 Files: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CGOpenCLRuntime.h test/CodeGen/blocks-opencl.cl test/CodeGenOpenCL/blocks.cl test/CodeGenOpenCL/cl20-device-side-enqueue.cl Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl === --- test/CodeGenOpenCL/cl20-device-side-enqueue.cl +++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl @@ -7,7 +7,7 @@ typedef struct {int a;} ndrange_t; // N.B. The check here only exists to set BL_GLOBAL -// COMMON: @block_G = addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*) +// COMMON: @block_G = addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*) const bl_t block_G = (bl_t) ^ (local void *a) {}; kernel void device_side_enqueue(global int *a, global int *b, int i) { @@ -27,9 +27,10 @@ // COMMON: [[NDR:%[a-z0-9]+]] = alloca %struct.ndrange_t, align 4 // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags - // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()* + // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()* + // B64: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* %block to void ()* // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)* - // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* [[BL_I8]]) + // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{([0-9]+)?}}, i8 addrspace(4)* [[BL_I8]]) enqueue_kernel(default_queue, flags, ndrange, ^(void) { a[i] = b[i]; @@ -39,7 +40,7 @@ // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)* // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)* - // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()* + // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()* // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)* // COMMON: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]], i8 addrspace(4)* [[BL_I8]]) enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event, @@ -52,11 +53,11 @@ // B32: %[[TMP:.*]] = alloca [1 x i32] // B32: %[[TMP1:.*]] = getelementptr [1 x i32], [1 x i32]* %[[TMP]], i32 0, i32 0 // B32: store i32 256, i32* %[[TMP1]], align 4 - // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_
Re: [libcxx] r250235 - [libcxx] Capture configuration information when installing the libc++ headers
On 13 September 2017 at 12:15, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > On Wed, Sep 13, 2017 at 1:02 PM, Richard Smith > wrote: > >> On 13 October 2015 at 15:12, Eric Fiselier via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: ericwf >>> Date: Tue Oct 13 17:12:02 2015 >>> New Revision: 250235 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=250235&view=rev >>> Log: >>> [libcxx] Capture configuration information when installing the libc++ >>> headers >>> >>> Summary: >>> Hi all, >>> >>> This patch is a successor to D11963. However it has changed dramatically >>> and I felt it would be best to start a new review thread. >>> >>> Please read the design documentation added in this patch for a >>> description of how it works. >>> >>> Reviewers: mclow.lists, danalbert, jroelofs, EricWF >>> >>> Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, >>> cfe-commits >>> >>> Differential Revision: http://reviews.llvm.org/D13407 >>> >>> Added: >>> libcxx/trunk/docs/DesignDocs/ >>> libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst >>> libcxx/trunk/include/__config_site.in >>> Modified: >>> libcxx/trunk/CMakeLists.txt >>> libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake >>> libcxx/trunk/docs/index.rst >>> libcxx/trunk/include/CMakeLists.txt >>> >>> Modified: libcxx/trunk/CMakeLists.txt >>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >>> txt?rev=250235&r1=250234&r2=250235&view=diff >>> >>> == >>> --- libcxx/trunk/CMakeLists.txt (original) >>> +++ libcxx/trunk/CMakeLists.txt Tue Oct 13 17:12:02 2015 >>> @@ -260,13 +260,6 @@ endif() >>> >>> # Feature flags == >>> = >>> define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) >>> -define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE >>> -D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) >>> -define_if_not(LIBCXX_ENABLE_STDIN -D_LIBCPP_HAS_NO_STDIN) >>> -define_if_not(LIBCXX_ENABLE_STDOUT -D_LIBCPP_HAS_NO_STDOUT) >>> -define_if_not(LIBCXX_ENABLE_THREADS -D_LIBCPP_HAS_NO_THREADS) >>> -define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK >>> -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK) >>> -define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS >>> -D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) >>> - >>> >>> # Sanitizer flags == >>> === >>> >>> @@ -303,6 +296,22 @@ if (LIBCXX_BUILT_STANDALONE) >>> message(WARNING "LLVM_USE_SANITIZER is not supported on this >>> platform.") >>>endif() >>> endif() >>> + >>> +# Configuration file flags == >>> === >>> +config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE >>> _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) >>> +config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) >>> +config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) >>> +config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) >>> +config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK >>> _LIBCPP_HAS_NO_MONOTONIC_CLOCK) >>> +config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS >>> _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) >>> + >>> +if (LIBCXX_NEEDS_SITE_CONFIG) >>> + configure_file( >>> +include/__config_site.in >>> +${LIBCXX_BINARY_DIR}/__config_site >>> +@ONLY) >>> +endif() >>> + >>> #== >>> = >>> # Setup Source Code And Tests >>> #== >>> = >>> >>> Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake >>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modul >>> es/HandleLibcxxFlags.cmake?rev=250235&r1=250234&r2=250235&view=diff >>> >>> == >>> --- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original) >>> +++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Tue Oct 13 >>> 17:12:02 2015 >>> @@ -49,6 +49,22 @@ macro(define_if_not condition def) >>>endif() >>> endmacro() >>> >>> +macro(config_define_if condition def) >>> + if (${condition}) >>> +set(${def} ON) >>> +add_definitions(-D${def}) >>> +set(LIBCXX_NEEDS_SITE_CONFIG ON) >>> + endif() >>> +endmacro() >>> + >>> +macro(config_define_if_not condition def) >>> + if (NOT ${condition}) >>> +set(${def} ON) >>> +add_definitions(-D${def}) >>> +set(LIBCXX_NEEDS_SITE_CONFIG ON) >>> + endif() >>> +endmacro() >>> + >>> # Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and >>> # 'LIBCXX_LINK_FLAGS'. >>> macro(add_flags) >>> >>> Added: libcxx/trunk/docs/DesignDocs/CapturingConfigInfo.rst >>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/Design >>> Docs/CapturingConfigInfo.rst?rev=250235&view=auto >>> ===
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
andrew.w.kaylor added a comment. Does anything else need to be done for this to be ready to land? https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r313104 - Revert "[Driver] MinGW: Remove custom linker detection"
This is a wild guess, but don't you need to add `REQUIRES: lld` to your test if your test depends on lld? I don't think all bots have lld, and if `ld.lld` is not found, clang prints out that error message. On Tue, Sep 12, 2017 at 7:16 PM, Martell Malone wrote: > Just to follow up, > The test case here was added by yaron in https://reviews.llvm.org/rL253066 > As a follow up to the original detection which I originally wrote and reid > reviewed https://reviews.llvm.org/rL242121 > Given that no other target does special checks except msvc for lld-link > removing this test case might also be an option. > > On Wed, Sep 13, 2017 at 2:54 AM, Martell Malone > wrote: > >> Hey Reid, Rui, >> >> I had to revert this twice. I'm not sure where the configurations for the >> build bots are but there are 2 issues as I mentioned in the commit message >> >> Looking through the clang test directory I only se -fuse-ld=lld tested in >> 4 locations >> >> test/Driver/windows-cross.c does some really old tests like >> `-fuse-ld=lld-link2` which was back when Rui had just started the new COFF >> linker. (maybe we should remove / update these ? ) >> test/Driver/cl-link.c which checks that for cl -fuse-ld=lld is converted >> to lld-link and not ld.lld >> test/Driver/cl-options.c just checks an error showing LTO that requires >> -fuse-ld=lld >> and in >> test/Driver/mingw-useld.c where we run into our errors. >> >> So to begin there does not seem to be any checking for lld in the test >> suite because it is not properly tested anywhere (from a clang perspective). >> >> For the first error `error: invalid linker name in argument >> '-fuse-ld=lld'` >> I'm not sure exactly how to add requirements to the lit tooling, I did a >> few greps build only came up with target checks. >> but do you know where I would look to implement something like this? >> `// REQUIRES: lld` >> >> As for the second issue. >> >> lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld >> >> I can't confirm but it seems like a configuration with the buildbot >> itself. >> Possibly related to setting LLD_SYMLINKS_TO_CREATE within the bot itself >> or some bat file on the system itself for symlinking? >> >> I don't think it is clang itself that is doing this because the only >> place where lld is remapped to lld-link is in lib/Driver/ToolChains/MSVC. >> cpp >> and that is only for msvc targets with a testcase in test/Driver/cl-link.c >> >> Best, >> Martell >> >> >> On Wed, Sep 13, 2017 at 1:57 AM, Martell Malone via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: martell >>> Date: Tue Sep 12 17:57:50 2017 >>> New Revision: 313104 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=313104&view=rev >>> Log: >>> Revert "[Driver] MinGW: Remove custom linker detection" >>> >>> This reverts rL313102 because it still fails some build bot tests. >>> >>> On many linux bots it fails with the following error. >>> error: invalid linker name in argument '-fuse-ld=lld' >>> and on some windows bots also because there is no ld.lld.exe >>> lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld >>> >>> Modified: >>> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp >>> cfe/trunk/test/Driver/mingw-useld.c >>> >>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp >>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too >>> lChains/MinGW.cpp?rev=313104&r1=313103&r2=313104&view=diff >>> >>> == >>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original) >>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Sep 12 17:57:50 2017 >>> @@ -104,6 +104,14 @@ void tools::MinGW::Linker::ConstructJob( >>>// 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)); >>> >>> @@ -233,7 +241,7 @@ void tools::MinGW::Linker::ConstructJob( >>> >>>if (Args.hasArg(options::OPT_static)) >>> CmdArgs.push_back("--end-group"); >>> - else >>> + else if (!LinkerName.equals_lower("lld")) >>> AddLibGCC(Args, CmdArgs); >>> } >>> >>> @@ -244,7 +252,7 @@ void tools::MinGW::Linker::ConstructJob( >>>CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend >>> .o"))); >>> } >>>} >>> - const char *Exec = Args.MakeArgString(TC.GetLinkerPath()); >>> + const char *Exec = Args.MakeArgString(TC.GetProgr >>> amPath(LinkerName.data())); >>>C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, >>> Inputs)); >>> } >>> >>> >>> Modified: cfe/trunk/test/Driver/mingw-useld.c >>> URL: htt
Re: r313104 - Revert "[Driver] MinGW: Remove custom linker detection"
Ah, sorry, you mentioned that. Yes, I think you need it. On Wed, Sep 13, 2017 at 1:00 PM, Rui Ueyama wrote: > This is a wild guess, but don't you need to add `REQUIRES: lld` to your > test if your test depends on lld? I don't think all bots have lld, and if > `ld.lld` is not found, clang prints out that error message. > > On Tue, Sep 12, 2017 at 7:16 PM, Martell Malone > wrote: > >> Just to follow up, >> The test case here was added by yaron in https://reviews.llvm.org/rL253 >> 066 >> As a follow up to the original detection which I originally wrote and >> reid reviewed https://reviews.llvm.org/rL242121 >> Given that no other target does special checks except msvc for lld-link >> removing this test case might also be an option. >> >> On Wed, Sep 13, 2017 at 2:54 AM, Martell Malone >> wrote: >> >>> Hey Reid, Rui, >>> >>> I had to revert this twice. I'm not sure where the configurations for >>> the build bots are but there are 2 issues as I mentioned in the commit >>> message >>> >>> Looking through the clang test directory I only se -fuse-ld=lld tested >>> in 4 locations >>> >>> test/Driver/windows-cross.c does some really old tests like >>> `-fuse-ld=lld-link2` which was back when Rui had just started the new COFF >>> linker. (maybe we should remove / update these ? ) >>> test/Driver/cl-link.c which checks that for cl -fuse-ld=lld is converted >>> to lld-link and not ld.lld >>> test/Driver/cl-options.c just checks an error showing LTO that requires >>> -fuse-ld=lld >>> and in >>> test/Driver/mingw-useld.c where we run into our errors. >>> >>> So to begin there does not seem to be any checking for lld in the test >>> suite because it is not properly tested anywhere (from a clang perspective). >>> >>> For the first error `error: invalid linker name in argument >>> '-fuse-ld=lld'` >>> I'm not sure exactly how to add requirements to the lit tooling, I did a >>> few greps build only came up with target checks. >>> but do you know where I would look to implement something like this? >>> `// REQUIRES: lld` >>> >>> As for the second issue. >>> >>> lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld >>> >>> I can't confirm but it seems like a configuration with the buildbot >>> itself. >>> Possibly related to setting LLD_SYMLINKS_TO_CREATE within the bot itself >>> or some bat file on the system itself for symlinking? >>> >>> I don't think it is clang itself that is doing this because the only >>> place where lld is remapped to lld-link is in lib/Driver/ToolChains/MSVC. >>> cpp >>> and that is only for msvc targets with a testcase >>> in test/Driver/cl-link.c >>> >>> Best, >>> Martell >>> >>> >>> On Wed, Sep 13, 2017 at 1:57 AM, Martell Malone via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: martell Date: Tue Sep 12 17:57:50 2017 New Revision: 313104 URL: http://llvm.org/viewvc/llvm-project?rev=313104&view=rev Log: Revert "[Driver] MinGW: Remove custom linker detection" This reverts rL313102 because it still fails some build bot tests. On many linux bots it fails with the following error. error: invalid linker name in argument '-fuse-ld=lld' and on some windows bots also because there is no ld.lld.exe lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/test/Driver/mingw-useld.c Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too lChains/MinGW.cpp?rev=313104&r1=313103&r2=313104&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Sep 12 17:57:50 2017 @@ -104,6 +104,14 @@ void tools::MinGW::Linker::ConstructJob( // 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)); @@ -233,7 +241,7 @@ void tools::MinGW::Linker::ConstructJob( if (Args.hasArg(options::OPT_static)) CmdArgs.push_back("--end-group"); - else + else if (!LinkerName.equals_lower("lld")) AddLibGCC(Args, CmdArgs); } @@ -244,7 +252,7 @@ void tools::MinGW::Linker::ConstructJob( CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend .o"))); } } - const char *Exec = Args.MakeArgString(TC.GetLinkerPa
r313182 - SplitEmptyFunction should be true in the Mozilla coding style
Author: sylvestre Date: Wed Sep 13 13:03:29 2017 New Revision: 313182 URL: http://llvm.org/viewvc/llvm-project?rev=313182&view=rev Log: SplitEmptyFunction should be true in the Mozilla coding style Summary: As defined here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Classes See for the downstream bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1399359 Reviewers: Typz, djasper Reviewed By: Typz Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37795 Modified: cfe/trunk/lib/Format/Format.cpp Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=313182&r1=313181&r2=313182&view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Wed Sep 13 13:03:29 2017 @@ -515,7 +515,7 @@ static FormatStyle expandPresets(const F Expanded.BraceWrapping.AfterFunction = true; Expanded.BraceWrapping.AfterStruct = true; Expanded.BraceWrapping.AfterUnion = true; -Expanded.BraceWrapping.SplitEmptyFunction = false; +Expanded.BraceWrapping.SplitEmptyFunction = true; Expanded.BraceWrapping.SplitEmptyRecord = false; break; case FormatStyle::BS_Stroustrup: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)
cameron314 updated this revision to Diff 115104. cameron314 edited the summary of this revision. cameron314 added a comment. Alright, I've changed the patch so that the preamble takes into account the BOM presence and is invalidated when it changes. This automatically fixes all clients of `PrecompiledPreamble`, and ensures that all `SourceLocation`s are always consistent when using a PCH generated from the preamble. I think this should do the trick! https://reviews.llvm.org/D37491 Files: include/clang/Frontend/PrecompiledPreamble.h include/clang/Lex/Lexer.h include/clang/Lex/PreprocessorOptions.h lib/Frontend/FrontendActions.cpp lib/Frontend/PrecompiledPreamble.cpp lib/Lex/Lexer.cpp lib/Lex/Preprocessor.cpp unittests/Frontend/PCHPreambleTest.cpp Index: unittests/Frontend/PCHPreambleTest.cpp === --- unittests/Frontend/PCHPreambleTest.cpp +++ unittests/Frontend/PCHPreambleTest.cpp @@ -153,4 +153,48 @@ ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2)); } +TEST_F(PCHPreambleTest, ParseWithBom) { + std::string Header = "//./header.h"; + std::string Main = "//./main.cpp"; + AddFile(Header, "int random() { return 4; }"); + AddFile(Main, +"\xef\xbb\xbf" +"#include \"//./header.h\"\n" +"int main() { return random() -2; }"); + + std::unique_ptr AST(ParseAST(Main)); + ASSERT_TRUE(AST.get()); + ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred()); + + unsigned HeaderReadCount = GetFileReadCount(Header); + + ASSERT_TRUE(ReparseAST(AST)); + ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred()); + + // Check preamble PCH was really reused + ASSERT_EQ(HeaderReadCount, GetFileReadCount(Header)); + + // Remove BOM + RemapFile(Main, +"#include \"//./header.h\"\n" +"int main() { return random() -2; }"); + + ASSERT_TRUE(ReparseAST(AST)); + ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred()); + + ASSERT_LE(HeaderReadCount, GetFileReadCount(Header)); + HeaderReadCount = GetFileReadCount(Header); + + // Add BOM back + RemapFile(Main, +"\xef\xbb\xbf" +"#include \"//./header.h\"\n" +"int main() { return random() -2; }"); + + ASSERT_TRUE(ReparseAST(AST)); + ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred()); + + ASSERT_LE(HeaderReadCount, GetFileReadCount(Header)); +} + } // anonymous namespace Index: lib/Lex/Preprocessor.cpp === --- lib/Lex/Preprocessor.cpp +++ lib/Lex/Preprocessor.cpp @@ -516,9 +516,9 @@ // If we've been asked to skip bytes in the main file (e.g., as part of a // precompiled preamble), do so now. if (SkipMainFilePreamble.first > 0) - CurLexer->SkipBytes(SkipMainFilePreamble.first, - SkipMainFilePreamble.second); - + CurLexer->SetByteOffset(SkipMainFilePreamble.first, + SkipMainFilePreamble.second); + // Tell the header info that the main file was entered. If the file is later // #imported, it won't be re-entered. if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID)) Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -552,9 +552,9 @@ } // end anonymous namespace -std::pair Lexer::ComputePreamble(StringRef Buffer, - const LangOptions &LangOpts, - unsigned MaxLines) { +PreambleBounds Lexer::ComputePreamble(StringRef Buffer, + const LangOptions &LangOpts, + unsigned MaxLines) { // Create a lexer starting at the beginning of the file. Note that we use a // "fake" file source location at offset 1 so that the lexer will track our // position within the file. @@ -688,7 +688,8 @@ else End = TheTok.getLocation(); - return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(), + return PreambleBounds(StartLoc.getRawEncoding() - FileLoc.getRawEncoding(), +End.getRawEncoding() - StartLoc.getRawEncoding(), TheTok.isAtStartOfLine()); } @@ -1394,9 +1395,9 @@ // Helper methods for lexing. //===--===// -/// \brief Routine that indiscriminately skips bytes in the source file. -void Lexer::SkipBytes(unsigned Bytes, bool StartOfLine) { - BufferPtr += Bytes; +/// \brief Routine that indiscriminately sets the offset into the source file. +void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) { + BufferPtr = BufferStart + Offset; if (BufferPtr > BufferEnd) BufferPtr = BufferEnd; // FIXME: What exactly does the StartOfLine bit mean? There are two Index: lib/Frontend/PrecompiledPreamble.cpp === --- lib/Fron
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
efriedma added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6031 InGroup; +def ext_gnu_null_ptr_arith : Extension< + "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, "extension" isn't really right here; this shouldn't be an error in -pedantic-errors mode. Probably best to just stick this into the NullPointerArithmetic, like the other new warning. https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313186 - [OPENMP] Fix types for the target specific parameters in debug mode.
Author: abataev Date: Wed Sep 13 13:20:59 2017 New Revision: 313186 URL: http://llvm.org/viewvc/llvm-project?rev=313186&view=rev Log: [OPENMP] Fix types for the target specific parameters in debug mode. Used incorrect types for target specific parameters in debug mode, should use original pointers rather than the pointee types. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=313186&r1=313185&r2=313186&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Sep 13 13:20:59 2017 @@ -2274,9 +2274,9 @@ CGOpenMPRuntimeNVPTX::getParameterAddres QualType NativePointeeTy = cast(NonQualTy)->getPointeeType(); unsigned NativePointeeAddrSpace = NativePointeeTy.getQualifiers().getAddressSpace(); - QualType TargetPointeeTy = TargetParam->getType()->getPointeeType(); + QualType TargetTy = TargetParam->getType(); llvm::Value *TargetAddr = CGF.EmitLoadOfScalar( - LocalAddr, /*Volatile=*/false, TargetPointeeTy, SourceLocation()); + LocalAddr, /*Volatile=*/false, TargetTy, SourceLocation()); // First cast to generic. TargetAddr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( TargetAddr, TargetAddr->getType()->getPointerElementType()->getPointerTo( @@ -2287,7 +2287,7 @@ CGOpenMPRuntimeNVPTX::getParameterAddres NativePointeeAddrSpace)); Address NativeParamAddr = CGF.CreateMemTemp(NativeParamType); CGF.EmitStoreOfScalar(TargetAddr, NativeParamAddr, /*Volatile=*/false, -NativeParam->getType()); +NativeParamType); return NativeParamAddr; } Modified: cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp?rev=313186&r1=313185&r2=313186&view=diff == --- cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp Wed Sep 13 13:20:59 2017 @@ -5,11 +5,13 @@ int main() { /* int(*b)[a]; */ /* int *(**c)[a]; */ + bool bb; int a; int b[10][10]; int c[10][10][10]; -#pragma omp target parallel firstprivate(a, b) map(tofrom \ - : c) +#pragma omp target parallel firstprivate(a, b) map(tofrom \ + : c) map(tofrom \ +: bb) { int &f = c[1][1][1]; int &g = a; @@ -19,9 +21,11 @@ int main() { b[0][a] = 10; c[0][0][a] = 11; b[0][a] = c[0][0][a]; +bb |= b[0][a]; } -#pragma omp target parallel firstprivate(a) map(tofrom \ -: c, b) +#pragma omp target parallel firstprivate(a) map(tofrom \ +: c, b) map(to \ +: bb) { int &f = c[1][1][1]; int &g = a; @@ -31,9 +35,11 @@ int main() { b[0][a] = 10; c[0][0][a] = 11; b[0][a] = c[0][0][a]; +d = bb; } -#pragma omp target parallel map(tofrom \ -: a, c, b) +#pragma omp target parallel map(tofrom \ +: a, c, b) map(from \ + : bb) { int &f = c[1][1][1]; int &g = a; @@ -43,64 +49,65 @@ int main() { b[0][a] = 10; c[0][0][a] = 11; b[0][a] = c[0][0][a]; +bb = b[0][a]; } return 0; } -// CHECK: define internal void @__omp_offloading{{[^(]+}}([10 x [10 x [10 x i32]]] addrspace(1)* {{[^,]+}}, i32 {{[^,]+}}, [10 x [10 x i32]]* {{[^)]+}}) +// CHECK: define internal void @__omp_offloading{{[^(]+}}([10 x [10 x [10 x i32]]] addrspace(1)* {{[^,]+}}, i32 {{[^,]+}}, [10 x [10 x i32]]* {{[^,]+}}, i8 addrspace(1)* noalias{{[^)]+}}) // CHECK: addrspacecast [10 x [10 x [10 x i32]]] addrspace(1)* %{{.+}} to [10 x [10 x [10 x i32]]]* -// CHECK: call void [[NONDEBUG_WRAPPER:.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x [10 x i32]]]* {{[^,]+}}, i64 {{[^,]+}}, [10 x [10 x i32]]* {{[^)]+}}) +// CHECK: call void [[NONDEBUG_WRAPPER:.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x [10 x i32]]]* {{[^,]+}}, i64 {{[^,]+}}, [10 x [10 x i32]]* {{[^,]+}}, i8* {{[^)]+}}) -// CHECK: define internal void [[DEBUG_PARALLEL:@.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x [10 x i32]]] addrspace(1)* noalias{{[^,]+}}, i32 {{[^,]+}}, [10 x [10 x i32]]* noalias{{[^)]+}}) +// CHECK: define internal void [[DEBUG_PARALLEL:@.+]](i32* {{[^,]+}},
Re: r304661 - CodeGen: fix section names for different file formats
Hi Saleem I just realize there can be an issue with this commit. This breaks the bitcode compatibility when LTO linking bitcode file produced by llvm-5.0 vs the older versions. Because the objc related module flag has the behavior Module::Error, simple whitespace changes will cause libLTO to error upon seeing different values. I wish I caught this earlier so we can fix the issue before 5.0 released. Maybe we need another bitcode upgrade path to strip away all the whitespaces in "Objective-C Image Info Section" module flag? Steven > On Jun 3, 2017, at 9:18 AM, Saleem Abdulrasool via cfe-commits > wrote: > > Author: compnerd > Date: Sat Jun 3 11:18:09 2017 > New Revision: 304661 > > URL: http://llvm.org/viewvc/llvm-project?rev=304661&view=rev > Log: > CodeGen: fix section names for different file formats > > This changes the codegen to match the section names according to the > ObjC rewriter as well as the runtime. The changes to the test are > simply whitespace changes to the section attributes and names and are > functionally equivalent (the whitespace is ignored by the linker). > > Added: >cfe/trunk/test/CodeGenObjC/sections.m > Modified: >cfe/trunk/lib/CodeGen/CGObjCMac.cpp >cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m >cfe/trunk/test/CodeGenObjC/image-info.m >cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m >cfe/trunk/test/CodeGenObjC/metadata_symbols.m >cfe/trunk/test/CodeGenObjC/non-lazy-classes.m > > Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=304661&r1=304660&r2=304661&view=diff > == > --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Jun 3 11:18:09 2017 > @@ -1004,6 +1004,8 @@ protected: > const ObjCInterfaceDecl *ID, > ObjCCommonTypesHelper &ObjCTypes); > > + std::string GetSectionName(StringRef Section, StringRef MachOAttributes); > + > public: > /// CreateMetadataVar - Create a global variable with internal > /// linkage for use by the Objective-C runtime. > @@ -4786,6 +4788,27 @@ llvm::Value *CGObjCMac::EmitIvarOffset(C > > /* *** Private Interface *** */ > > +std::string CGObjCCommonMac::GetSectionName(StringRef Section, > +StringRef MachOAttributes) { > + switch (CGM.getTriple().getObjectFormat()) { > + default: > +llvm_unreachable("unexpected object file format"); > + case llvm::Triple::MachO: { > +if (MachOAttributes.empty()) > + return ("__DATA," + Section).str(); > +return ("__DATA," + Section + "," + MachOAttributes).str(); > + } > + case llvm::Triple::ELF: > +assert(Section.substr(0, 2) == "__" && > + "expected the name to begin with __"); > +return Section.substr(2).str(); > + case llvm::Triple::COFF: > +assert(Section.substr(0, 2) == "__" && > + "expected the name to begin with __"); > +return ("." + Section.substr(2) + "$B").str(); > + } > +} > + > /// EmitImageInfo - Emit the image info marker used to encode some module > /// level information. > /// > @@ -4809,9 +4832,10 @@ enum ImageInfoFlags { > > void CGObjCCommonMac::EmitImageInfo() { > unsigned version = 0; // Version is unused? > - const char *Section = (ObjCABI == 1) ? > -"__OBJC, __image_info,regular" : > -"__DATA, __objc_imageinfo, regular, no_dead_strip"; > + std::string Section = > + (ObjCABI == 1) > + ? "__OBJC,__image_info,regular" > + : GetSectionName("__objc_imageinfo", "regular,no_dead_strip"); > > // Generate module-level named metadata to convey this information to the > // linker and code-gen. > @@ -4822,7 +4846,7 @@ void CGObjCCommonMac::EmitImageInfo() { > Mod.addModuleFlag(llvm::Module::Error, "Objective-C Image Info Version", > version); > Mod.addModuleFlag(llvm::Module::Error, "Objective-C Image Info Section", > -llvm::MDString::get(VMContext,Section)); > +llvm::MDString::get(VMContext, Section)); > > if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { > // Non-GC overrides those files which specify GC. > @@ -5930,17 +5954,21 @@ void CGObjCNonFragileABIMac::FinishNonFr > } > > AddModuleClassList(DefinedClasses, "OBJC_LABEL_CLASS_$", > - "__DATA, __objc_classlist, regular, no_dead_strip"); > + GetSectionName("__objc_classlist", > +"regular,no_dead_strip")); > > AddModuleClassList(DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$", > - "__DATA, __objc_nlclslist, regular, no_dead_strip"); > + GetSectionName("__objc_nlclslist", > +"regular,no_dead_strip")); > > // Build list of all implemen
[PATCH] D37308: Interface class with uuid base record
erichkeane added a comment. Tighten up the 'IUnknown' check, and do the check I mentioned above, and I think this logic is correct. Searching would be required in the positive case, but this is the negative case. Comment at: lib/Sema/SemaDeclCXX.cpp:2483 +!IsDeclPublicInterface(RD, KnownBase->getAccessSpecifier()) && +!IsOrInheritsFromIUnknown(RD)) { Diag(KnownBase->getLocStart(), diag::err_invalid_base_in_interface) So, I just realized... this call here is useless, we got sidetracked because of the inversion of logic here. You ACTUALLY just care that this base is either a public interface, OR if it is IUnknown. This logic can be: if (Class->isInterface() && !IsDeclPublicInterface(...) && !IsIUnknownType(...)) {...} The search doesn't actually need to take place, since the current base COULD NOT be a valid 'interface' unless it inherited only from interfaces/IUnknown anyway. Unless I'm missing something, you can delete the function "IsOrInheritsFromIUnknown" as well. https://reviews.llvm.org/D37308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313192 - Mark static member functions as static in CodeViewDebug
Author: amccarth Date: Wed Sep 13 13:53:55 2017 New Revision: 313192 URL: http://llvm.org/viewvc/llvm-project?rev=313192&view=rev Log: Mark static member functions as static in CodeViewDebug Summary: To improve CodeView quality for static member functions, we need to make the static explicit. In addition to a small change in LLVM's CodeViewDebug to return the appropriate MethodKind, this requires a small change in Clang to note the staticness in the debug info metadata. Subscribers: aprantl, hiraditya Differential Revision: https://reviews.llvm.org/D37715 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=313192&r1=313191&r2=313192&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Sep 13 13:53:55 2017 @@ -1408,6 +1408,8 @@ llvm::DISubprogram *CGDebugInfo::CreateC ContainingType = RecordTy; } + if (Method->isStatic()) +Flags |= llvm::DINode::FlagStaticMember; if (Method->isImplicit()) Flags |= llvm::DINode::FlagArtificial; Flags |= getAccessFlag(Method->getAccess(), Method->getParent()); Modified: cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp?rev=313192&r1=313191&r2=313192&view=diff == --- cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp (original) +++ cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp Wed Sep 13 13:53:55 2017 @@ -6,6 +6,7 @@ struct Foo { virtual void f(); virtual void g(); virtual void h(); + static void i(int, int); struct Nested {}; }; Foo f; @@ -18,7 +19,7 @@ Foo::Nested n; // CHECK-SAME: elements: ![[elements:[0-9]+]] // CHECK-SAME: identifier: ".?AUFoo@@" -// CHECK: ![[elements]] = !{![[vshape:[0-9]+]], ![[vptr:[0-9]+]], ![[Nested]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]]} +// CHECK: ![[elements]] = !{![[vshape:[0-9]+]], ![[vptr:[0-9]+]], ![[Nested]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]], ![[i:[0-9]+]]} // CHECK: ![[vshape]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: null, size: 96) @@ -38,3 +39,9 @@ Foo::Nested n; // CHECK: ![[h]] = !DISubprogram(name: "h", // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, + +// CHECK: ![[i]] = !DISubprogram(name: "i", +// CHECK-SAME: flags: DIFlagPrototyped | DIFlagStaticMember +// CHECK-NEXT: ![[dummy:[0-9]+]] = !DISubroutineType(types: ![[Signature:[0-9]+]]) +// CHECK: ![[Signature]] = !{null, ![[BasicInt:[0-9]+]], ![[BasicInt]]} +// CHECK: ![[BasicInt]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37681: [refactor] Simplify the interface and remove some template magic
ioeric added a comment. This is very nice! Thanks! Looks good to me; I'll let Manuel stamp the patch for you. Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:56 + virtual Expected + createSourceReplacements(RefactoringRuleContext &Context) = 0; + Can this be `private`? Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:77 + virtual Expected + findSymbolOccurrences(RefactoringRuleContext &Context) = 0; `private`? Repository: rL LLVM https://reviews.llvm.org/D37681 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37308: Interface class with uuid base record
erichkeane added a comment. Actually... disregard that... the rule is more complex than that. Based on some playing around with MSVC on godbolt, it seems that it actually marks any type that inherits ONLY from interface types or IUnknown as an interface itself. We may be better off doing that instead. Additionally, the implementation of "isIUnknown" is actually more complicated too, since it contains function declarations. Comment at: lib/Sema/SemaDeclCXX.cpp:2388 + + return Uuid && Uuid->getGuid() =="---C000-0046" && + RD->isStruct() && RD->getName() == "IUnknown" && RD->isEmpty() && erichkeane wrote: > Up to @aaron.ballman, but moving the getGuid string check (a massive > string-diff) to 2nd defeats the purpose of moving UUID up front, which is to > put the 'easy' things first. IsTU, isStruct, and isEmpty are likely better. > > Additionally, I'd mentioned it before, this still doesn't check to make sure > that the IUnknown doesn't inherit from anywhere, does it? MSVC also will > error if IUnknown's definition includes an inherited type. Also, "isEmpty" isn't sufficient. IUnknown actually contains functions as long as none have an implementation. (Declarations only). 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] D37804: [OpenCL] Handle address space conversion while setting type alignment
yaxunl added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:957 -return Builder.CreateBitCast(Addr, ConvertType(E->getType())); +return Builder.CreatePointerBitCastOrAddrSpaceCast( +Addr, ConvertType(E->getType())); Better assert that only CK_AddressSpaceConversion allows different addr spaces in target type. https://reviews.llvm.org/D37804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
andrew.w.kaylor added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6031 InGroup; +def ext_gnu_null_ptr_arith : Extension< + "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, efriedma wrote: > "extension" isn't really right here; this shouldn't be an error in > -pedantic-errors mode. Probably best to just stick this into the > NullPointerArithmetic, like the other new warning. So how should a word the warning? Just this: "arithmetic on a null pointer treated as a cast from integer to pointer"? https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
efriedma added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6031 InGroup; +def ext_gnu_null_ptr_arith : Extension< + "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, andrew.w.kaylor wrote: > efriedma wrote: > > "extension" isn't really right here; this shouldn't be an error in > > -pedantic-errors mode. Probably best to just stick this into the > > NullPointerArithmetic, like the other new warning. > So how should a word the warning? Just this: > > "arithmetic on a null pointer treated as a cast from integer to pointer"? That wasn't what I meant; the current wording is fine. I meant this should be something like `def warn_gnu_null_ptr_arith : Warning<`. https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
andrew.w.kaylor added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6031 InGroup; +def ext_gnu_null_ptr_arith : Extension< + "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, efriedma wrote: > andrew.w.kaylor wrote: > > efriedma wrote: > > > "extension" isn't really right here; this shouldn't be an error in > > > -pedantic-errors mode. Probably best to just stick this into the > > > NullPointerArithmetic, like the other new warning. > > So how should a word the warning? Just this: > > > > "arithmetic on a null pointer treated as a cast from integer to pointer"? > That wasn't what I meant; the current wording is fine. I meant this should be > something like `def warn_gnu_null_ptr_arith : Warning<`. OK. I think I understand the behavior you wanted. I just thought maybe the current wording might be technically incorrect. I wasn't sure how precisely defined we consider "extension" to be in this context. https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313201 - Use -- to prevent the driver from confusing paths with flags, should fix Mac bot.
Author: pcc Date: Wed Sep 13 14:49:17 2017 New Revision: 313201 URL: http://llvm.org/viewvc/llvm-project?rev=313201&view=rev Log: Use -- to prevent the driver from confusing paths with flags, should fix Mac bot. Modified: cfe/trunk/test/Driver/whole-program-vtables.c Modified: cfe/trunk/test/Driver/whole-program-vtables.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/whole-program-vtables.c?rev=313201&r1=313200&r2=313201&view=diff == --- cfe/trunk/test/Driver/whole-program-vtables.c (original) +++ cfe/trunk/test/Driver/whole-program-vtables.c Wed Sep 13 14:49:17 2017 @@ -1,11 +1,11 @@ // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s -// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -### -- %s 2>&1 | FileCheck --check-prefix=NO-LTO %s // NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto' // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s -// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -flto -### -- %s 2>&1 | FileCheck --check-prefix=LTO %s // LTO: "-fwhole-program-vtables" // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s -// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s +// RUN: %clang_cl --target=x86_64-pc-win32 -fwhole-program-vtables -fno-whole-program-vtables -flto -### -- %s 2>&1 | FileCheck --check-prefix=LTO-DISABLE %s // LTO-DISABLE-NOT: "-fwhole-program-vtables" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37308: Interface class with uuid base record
zahiraam updated this revision to Diff 115125. zahiraam added a comment. Hi have made all the changes requested. https://reviews.llvm.org/D37308 Files: lib/Sema/SemaDeclCXX.cpp Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -2373,6 +2373,40 @@ return true; } +/// \brief Tests if RD is a public interface. +static bool IsDeclPublicInterface(const CXXRecordDecl *RD, + AccessSpecifier spec) { + return RD->isInterface() && spec == AS_public; +} + +/// \brief Test if record is a uuid for IUnknown. +/// This is an MS SDK specific type that has a special +/// behavior in the CL compiler. +static bool IsIUnknownType(const CXXRecordDecl *RD) { + const auto *Uuid = RD->getAttr(); + + return Uuid && RD->isStruct() && RD->isEmpty() && + RD->getDeclContext()->isTranslationUnit() && + RD->getName() == "IUnknown" && + Uuid->getGuid() =="---C000-0046"; +} + +/// \brief Test if RD or its inherited bases is an IUnknown type. +static bool IsOrInheritsFromIUnknown(const CXXRecordDecl *RD) { + bool IsUnknown = IsIUnknownType(RD); + for (CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(), +BaseEnd = RD->bases_end(); + Base != BaseEnd; ++Base) { + CXXRecordDecl *BaseChild = Base->getType()->getAsCXXRecordDecl(); + + return IsUnknown || + IsOrInheritsFromIUnknown(BaseChild) || + (RD->getNumBases() > 1) && + IsOrInheritsFromIUnknown((CXXRecordDecl*) BaseChild->getNextDeclInContext()); + } + return IsUnknown; +} + /// Use small set to collect indirect bases. As this is only used /// locally, there's no need to abstract the small size parameter. typedef llvm::SmallPtrSet IndirectBaseSet; @@ -2450,10 +2484,10 @@ if (const RecordType *Record = NewBaseType->getAs()) { const CXXRecordDecl *RD = cast(Record->getDecl()); if (Class->isInterface() && - (!RD->isInterface() || - KnownBase->getAccessSpecifier() != AS_public)) { - // The Microsoft extension __interface does not permit bases that - // are not themselves public interfaces. +// The Microsoft extension __interface does not permit bases that +// are not themselves public interfaces. +!IsDeclPublicInterface(RD, KnownBase->getAccessSpecifier()) && +!IsOrInheritsFromIUnknown(RD)) { Diag(KnownBase->getLocStart(), diag::err_invalid_base_in_interface) << getRecordDiagFromTagKind(RD->getTagKind()) << RD->getName() << RD->getSourceRange(); Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -2373,6 +2373,40 @@ return true; } +/// \brief Tests if RD is a public interface. +static bool IsDeclPublicInterface(const CXXRecordDecl *RD, + AccessSpecifier spec) { + return RD->isInterface() && spec == AS_public; +} + +/// \brief Test if record is a uuid for IUnknown. +/// This is an MS SDK specific type that has a special +/// behavior in the CL compiler. +static bool IsIUnknownType(const CXXRecordDecl *RD) { + const auto *Uuid = RD->getAttr(); + + return Uuid && RD->isStruct() && RD->isEmpty() && + RD->getDeclContext()->isTranslationUnit() && + RD->getName() == "IUnknown" && + Uuid->getGuid() =="---C000-0046"; +} + +/// \brief Test if RD or its inherited bases is an IUnknown type. +static bool IsOrInheritsFromIUnknown(const CXXRecordDecl *RD) { + bool IsUnknown = IsIUnknownType(RD); + for (CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(), +BaseEnd = RD->bases_end(); + Base != BaseEnd; ++Base) { + CXXRecordDecl *BaseChild = Base->getType()->getAsCXXRecordDecl(); + + return IsUnknown || + IsOrInheritsFromIUnknown(BaseChild) || + (RD->getNumBases() > 1) && + IsOrInheritsFromIUnknown((CXXRecordDecl*) BaseChild->getNextDeclInContext()); + } + return IsUnknown; +} + /// Use small set to collect indirect bases. As this is only used /// locally, there's no need to abstract the small size parameter. typedef llvm::SmallPtrSet IndirectBaseSet; @@ -2450,10 +2484,10 @@ if (const RecordType *Record = NewBaseType->getAs()) { const CXXRecordDecl *RD = cast(Record->getDecl()); if (Class->isInterface() && - (!RD->isInterface() || - KnownBase->getAccessSpecifier() != AS_public)) { - // The Microsoft extension __interface does not permit bases that - // are not themselves public interfaces. +// The Microsoft extension __interface does not permit bases that +
[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
efriedma added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6031 InGroup; +def ext_gnu_null_ptr_arith : Extension< + "arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension">, andrew.w.kaylor wrote: > efriedma wrote: > > andrew.w.kaylor wrote: > > > efriedma wrote: > > > > "extension" isn't really right here; this shouldn't be an error in > > > > -pedantic-errors mode. Probably best to just stick this into the > > > > NullPointerArithmetic, like the other new warning. > > > So how should a word the warning? Just this: > > > > > > "arithmetic on a null pointer treated as a cast from integer to pointer"? > > That wasn't what I meant; the current wording is fine. I meant this should > > be something like `def warn_gnu_null_ptr_arith : Warning<`. > OK. I think I understand the behavior you wanted. I just thought maybe the > current wording might be technically incorrect. I wasn't sure how precisely > defined we consider "extension" to be in this context. The part that makes this a little weird is that unlike most extensions, this code is already well-formed. It's an extension because we're guaranteeing runtime behavior for a construct which has undefined behavior at runtime according to the standard. (This is in contrast to "implementation-defined" behaviors, which are the gaps in the standard we're allowed to fill in as we see fit.) Given that, I think calling it a "GNU extension" in the text is fine. https://reviews.llvm.org/D37042 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r313179 - [docs] Update LeakSanitizer documentation to reflect OS X support
Author: fjricci Date: Wed Sep 13 12:40:10 2017 New Revision: 313179 URL: http://llvm.org/viewvc/llvm-project?rev=313179&view=rev Log: [docs] Update LeakSanitizer documentation to reflect OS X support Reviewers: kcc, alekseyshl, kubamracek, glider Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37811 Modified: cfe/trunk/docs/AddressSanitizer.rst cfe/trunk/docs/LeakSanitizer.rst Modified: cfe/trunk/docs/AddressSanitizer.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AddressSanitizer.rst?rev=313179&r1=313178&r2=313179&view=diff == --- cfe/trunk/docs/AddressSanitizer.rst (original) +++ cfe/trunk/docs/AddressSanitizer.rst Wed Sep 13 12:40:10 2017 @@ -140,7 +140,8 @@ Memory leak detection - For more information on leak detector in AddressSanitizer, see -:doc:`LeakSanitizer`. The leak detection is turned on by default on Linux; +:doc:`LeakSanitizer`. The leak detection is turned on by default on Linux, +and can be enabled using ``ASAN_OPTIONS=detect_leaks=1`` on OS X; however, it is not yet supported on other platforms. Issue Suppression Modified: cfe/trunk/docs/LeakSanitizer.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LeakSanitizer.rst?rev=313179&r1=313178&r2=313179&view=diff == --- cfe/trunk/docs/LeakSanitizer.rst (original) +++ cfe/trunk/docs/LeakSanitizer.rst Wed Sep 13 12:40:10 2017 @@ -17,7 +17,7 @@ detection phase. Usage = -LeakSanitizer is only supported on x86\_64 Linux. In order to use it, +LeakSanitizer is supported on x86\_64 Linux and OS X. In order to use it, simply build your program with :doc:`AddressSanitizer`: .. code-block:: console @@ -30,7 +30,7 @@ simply build your program with :doc:`Add p = 0; // The memory is leaked here. return 0; } -% clang -fsanitize=address -g memory-leak.c ; ./a.out +% clang -fsanitize=address -g memory-leak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out ==23646==ERROR: LeakSanitizer: detected memory leaks Direct leak of 7 byte(s) in 1 object(s) allocated from: #0 0x4af01b in __interceptor_malloc /projects/compiler-rt/lib/asan/asan_malloc_linux.cc:52:3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits