summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenCL][Sema] Fix builtin rewritingMarco Antognini2019-07-091-2/+2
| | | | | | | | | | | This patch ensures built-in functions are rewritten using the proper parent declaration. Existing tests are modified to run in C++ mode to ensure the functionality works also with C++ for OpenCL while not increasing the testing runtime. llvm-svn: 365499
* Ignore trailing NullStmts in StmtExprs for GCC compatibility.Aaron Ballman2019-07-092-3/+5
| | | | | | | | Ignore trailing NullStmts in compound expressions when determining the result type and value. This is to match the GCC behavior which ignores semicolons at the end of compound expressions. Patch by Dominic Ferreira. llvm-svn: 365498
* [BPF] Preserve debuginfo array/union/struct type/access indexYonghong Song2019-07-091-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For background of BPF CO-RE project, please refer to http://vger.kernel.org/bpfconf2019.html In summary, BPF CO-RE intends to compile bpf programs adjustable on struct/union layout change so the same program can run on multiple kernels with adjustment before loading based on native kernel structures. In order to do this, we need keep track of GEP(getelementptr) instruction base and result debuginfo types, so we can adjust on the host based on kernel BTF info. Capturing such information as an IR optimization is hard as various optimization may have tweaked GEP and also union is replaced by structure it is impossible to track fieldindex for union member accesses. Three intrinsic functions, preserve_{array,union,struct}_access_index, are introducted. addr = preserve_array_access_index(base, index, dimension) addr = preserve_union_access_index(base, di_index) addr = preserve_struct_access_index(base, gep_index, di_index) here, base: the base pointer for the array/union/struct access. index: the last access index for array, the same for IR/DebugInfo layout. dimension: the array dimension. gep_index: the access index based on IR layout. di_index: the access index based on user/debuginfo types. If using these intrinsics blindly, i.e., transforming all GEPs to these intrinsics and later on reducing them to GEPs, we have seen up to 7% more instructions generated. To avoid such an overhead, a clang builtin is proposed: base = __builtin_preserve_access_index(base) such that user wraps to-be-relocated GEPs in this builtin and preserve_*_access_index intrinsics only apply to those GEPs. Such a buyin will prevent performance degradation if people do not use CO-RE, even for programs which use bpf_probe_read(). For example, for the following example, $ cat test.c struct sk_buff { int i; int b1:1; int b2:2; union { struct { int o1; int o2; } o; struct { char flags; char dev_id; } dev; int netid; } u[10]; }; static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr) = (void *) 4; #define _(x) (__builtin_preserve_access_index(x)) int bpf_prog(struct sk_buff *ctx) { char dev_id; bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id)); return dev_id; } $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \ test.c >& log The generated IR looks like below: ... define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 { %2 = alloca %struct.sk_buff*, align 8 %3 = alloca i8, align 1 store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45 call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49 call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50 call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51 %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45 %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45 %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs( %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19 %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons( [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53 %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons( %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26 %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53 %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s( %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34 %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52 %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55 %13 = sext i8 %12 to i32, !dbg !54 call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56 ret i32 %13, !dbg !57 } !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20) !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27) !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35) Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index attached to instructions to provide struct/union debuginfo type information. For &ctx->u[5].dev.dev_id, . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout. . The "%7 = ..." represents array subscript "5". . The "%8 = ..." represents union member "dev" with index 1 for DI layout. . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout. Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and examining all preserve_*_access_index calls, the debuginfo struct/union/array access index can be achieved. The intrinsics also contain enough information to regenerate codes for IR layout. For array and structure intrinsics, the proper GEP can be constructed. For union intrinsics, replacing all uses of "addr" with "base" should be enough. Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D61809 llvm-svn: 365438
* Revert "[BPF] Preserve debuginfo array/union/struct type/access index"Yonghong Song2019-07-091-14/+0
| | | | | | | | | This reverts commit r365435. Forgot adding the Differential Revision link. Will add to the commit message and resubmit. llvm-svn: 365436
* [BPF] Preserve debuginfo array/union/struct type/access indexYonghong Song2019-07-091-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For background of BPF CO-RE project, please refer to http://vger.kernel.org/bpfconf2019.html In summary, BPF CO-RE intends to compile bpf programs adjustable on struct/union layout change so the same program can run on multiple kernels with adjustment before loading based on native kernel structures. In order to do this, we need keep track of GEP(getelementptr) instruction base and result debuginfo types, so we can adjust on the host based on kernel BTF info. Capturing such information as an IR optimization is hard as various optimization may have tweaked GEP and also union is replaced by structure it is impossible to track fieldindex for union member accesses. Three intrinsic functions, preserve_{array,union,struct}_access_index, are introducted. addr = preserve_array_access_index(base, index, dimension) addr = preserve_union_access_index(base, di_index) addr = preserve_struct_access_index(base, gep_index, di_index) here, base: the base pointer for the array/union/struct access. index: the last access index for array, the same for IR/DebugInfo layout. dimension: the array dimension. gep_index: the access index based on IR layout. di_index: the access index based on user/debuginfo types. If using these intrinsics blindly, i.e., transforming all GEPs to these intrinsics and later on reducing them to GEPs, we have seen up to 7% more instructions generated. To avoid such an overhead, a clang builtin is proposed: base = __builtin_preserve_access_index(base) such that user wraps to-be-relocated GEPs in this builtin and preserve_*_access_index intrinsics only apply to those GEPs. Such a buyin will prevent performance degradation if people do not use CO-RE, even for programs which use bpf_probe_read(). For example, for the following example, $ cat test.c struct sk_buff { int i; int b1:1; int b2:2; union { struct { int o1; int o2; } o; struct { char flags; char dev_id; } dev; int netid; } u[10]; }; static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr) = (void *) 4; #define _(x) (__builtin_preserve_access_index(x)) int bpf_prog(struct sk_buff *ctx) { char dev_id; bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id)); return dev_id; } $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \ test.c >& log The generated IR looks like below: ... define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 { %2 = alloca %struct.sk_buff*, align 8 %3 = alloca i8, align 1 store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45 call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49 call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50 call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51 %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45 %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45 %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs( %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19 %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons( [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53 %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons( %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26 %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53 %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s( %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34 %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52 %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55 %13 = sext i8 %12 to i32, !dbg !54 call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56 ret i32 %13, !dbg !57 } !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20) !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27) !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35) Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index attached to instructions to provide struct/union debuginfo type information. For &ctx->u[5].dev.dev_id, . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout. . The "%7 = ..." represents array subscript "5". . The "%8 = ..." represents union member "dev" with index 1 for DI layout. . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout. Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and examining all preserve_*_access_index calls, the debuginfo struct/union/array access index can be achieved. The intrinsics also contain enough information to regenerate codes for IR layout. For array and structure intrinsics, the proper GEP can be constructed. For union intrinsics, replacing all uses of "addr" with "base" should be enough. Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 365435
* clang-cl: Port cl.exe's C4659 to clang-clNico Weber2019-07-092-7/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D64349 llvm-svn: 365411
* [ObjC] Add a -Wtautological-compare warning for BOOLErik Pilkington2019-07-081-6/+30
| | | | | | | | | | | | On macOS, BOOL is a typedef for signed char, but it should never hold a value that isn't 1 or 0. Any code that expects a different value in their BOOL should be fixed. rdar://51954400 Differential revision: https://reviews.llvm.org/D63856 llvm-svn: 365408
* [cxx2a] P0624R2 fix: only lambdas with no lambda-capture are ↵David Blaikie2019-07-081-1/+1
| | | | | | | | | | | | | | default-constructible and assignable. This is a fix for rG864949 which only disabled default construction and assignment for lambdas with capture-defaults, where the C++2a draft disables them for lambdas with any lambda-capture at all. Patch by Logan Smith! Differential Revision: https://reviews.llvm.org/D64058 llvm-svn: 365406
* Revert [Sema] Resolve placeholder types before type deduction to silence ↵Reid Kleckner2019-07-083-38/+12
| | | | | | | | | | | | | | | | | | | | | | spurious `-Warc-repeated-use-of-weak` warnings This reverts r365382 (git commit 8b1becf2e31d9170ee356a19c7b6ea991d3a520f) Appears to regress this semi-reduced fragment of valid code from windows SDK headers: #define InterlockedIncrement64 _InterlockedIncrement64 extern "C" __int64 InterlockedIncrement64(__int64 volatile *Addend); #pragma intrinsic(_InterlockedIncrement64) unsigned __int64 InterlockedIncrement(unsigned __int64 volatile *Addend) { return (unsigned __int64)(InterlockedIncrement64)((volatile __int64 *)Addend); } Found on a buildbot here, but no mail was sent due to it already being red: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/48067 llvm-svn: 365393
* [Sema] Resolve placeholder types before type deduction to silenceAkira Hatanaka2019-07-083-12/+38
| | | | | | | | | | | | | | | | | | spurious `-Warc-repeated-use-of-weak` warnings The spurious -Warc-repeated-use-of-weak warnings are issued when an initializer expression uses a weak ObjC pointer. My first attempt to silence the warnings (r350917) caused clang to reject code that is legal in C++17. The patch is based on the feedback I received from Richard when the patch was reverted. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268945.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268943.html Differential Revision: https://reviews.llvm.org/D62645 llvm-svn: 365382
* [OPENMP]Improve error message for device unsupported types.Alexey Bataev2019-07-081-2/+3
| | | | | | | Provide more data to the user in the error message about unsupported type for device compilation. llvm-svn: 365374
* Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or ↵Fangrui Song2019-07-032-12/+6
| | | | | | llvm::partition_point. NFC llvm-svn: 365006
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-031-7/+14
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* [C++2a] Add __builtin_bit_cast, used to implement std::bit_castErik Pilkington2019-07-023-0/+97
| | | | | | | | | | | | | | | | | | This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a bit_cast from a value v to a type T. This expression can be evaluated at compile time under specific circumstances. The compile time evaluation currently doesn't support bit-fields, but I'm planning on fixing this in a follow up (some of the logic for figuring this out is in CodeGen). I'm also planning follow-ups for supporting some more esoteric types that the constexpr evaluator supports, as well as extending __builtin_memcpy constexpr evaluation to use the same infrastructure. rdar://44987528 Differential revision: https://reviews.llvm.org/D62825 llvm-svn: 364954
* [OPENMP]Fix handling of lambda captures in target regions.Alexey Bataev2019-07-012-53/+46
| | | | | | | | Previously, lambda captures were processed in the function called during capturing the variables. It leads to the recursive functions calls and may result in the compiler crash. llvm-svn: 364820
* [OPENMP]Improve analysis of implicit captures.Alexey Bataev2019-06-281-20/+38
| | | | | | | | | If the variable is used in the OpenMP region implicitly, we need to check the data-sharing attributes for such variables and generate implicit clauses for them. Patch improves analysis of such variables for better handling of data-sharing rules. llvm-svn: 364683
* [OPENMP]Fix top DSA for static members.Alexey Bataev2019-06-281-3/+15
| | | | | | | | | Fixed handling of the data-sharing attributes for static members when requesting top most attribute. Previously, it might return the incorrect attributes for static members if they were overriden in the outer constructs. llvm-svn: 364655
* [OPENMP]Fix DSA for loop iteration variables in simd loops.Alexey Bataev2019-06-281-1/+3
| | | | | | | | | | | | According to the OpenMP 5.0 standard, the loop iteration variable in the associated for-loop of a simd construct with just one associated for-loop may be listed in a private, lastprivate, or linear clause with a linear-step that is the increment of the associated for-loop. Also, the loop teration variables in the associated for-loops of a simd construct with multiple associated for-loops may be listed in a private or lastprivate clause. llvm-svn: 364650
* [OPENMP]Fix checks for DSA in simd constructs.Alexey Bataev2019-06-281-2/+2
| | | | | | | | The errors for incorrectly specified data-sharing attributes for simd constructs must be emitted only for the explicitly provided clauses, not the predetermined ones. llvm-svn: 364647
* [OpenCL] Improve diagnostic for placement newSven van Haastregt2019-06-261-1/+5
| | | | | | | | | | | | | Without an explicit declaration for placement new, clang would reject uses of placement new with "'default new' is not supported in OpenCL C++". This may mislead users into thinking that placement new is not supported, see e.g. PR42060. Clarify that placement new requires an explicit declaration. Differential Revision: https://reviews.llvm.org/D63561 llvm-svn: 364423
* [HIP] Support attribute hip_pinned_shadowYaxun Liu2019-06-261-0/+4
| | | | | | | | | | | | | | | This patch introduces support of hip_pinned_shadow variable for HIP. A hip_pinned_shadow variable is a global variable with attribute hip_pinned_shadow. It has external linkage on device side and has no initializer. It has internal linkage on host side and has initializer or static constructor. It can be accessed in both device code and host code. This allows HIP runtime to implement support of HIP texture reference. Differential Revision: https://reviews.llvm.org/D62738 llvm-svn: 364381
* Remove redundant expression evaluation context when substituting into aRichard Smith2019-06-251-7/+5
| | | | | | | | template argument. We do need one of these but we don't need two. llvm-svn: 364347
* [cxx2a] P1236R1: the validity of a left shift does not depend on theRichard Smith2019-06-251-5/+8
| | | | | | value of the LHS operand. llvm-svn: 364265
* PR42362: Fix auto deduction of template parameter packs fromRichard Smith2019-06-241-1/+4
| | | | | | | | | type-dependent argument packs. We need to strip off the PackExpansionExpr to get the real (dependent) type rather than an opaque DependentTy. llvm-svn: 364165
* clang-format a block; NFCGeorge Burgess IV2019-06-211-6/+7
| | | | | | | The indentation of the return here was off, and confusing as a result. Cleaned up a bit extra while I was in the area. llvm-svn: 364104
* [OPENMP]Fix PR42068: Vla type is not captured.Alexey Bataev2019-06-211-0/+27
| | | | | | | | If the variably modified type is declared outside of the captured region and then used in the cast expression along with array subscript expression, the type is not captured and it leads to the compiler crash. llvm-svn: 364080
* [OPENMP]Fix PR42159: do not capture threadprivate variables.Alexey Bataev2019-06-211-2/+5
| | | | | | | The threadprivate variables should not be captured in the outlined regions, otherwise it leads to the compiler crash. llvm-svn: 364061
* [Sema] Fix diagnostic for addr spaces in reference bindingAnastasia Stulova2019-06-211-8/+18
| | | | | | | | Extend reference binding behavior to account for address spaces. Differential Revision: https://reviews.llvm.org/D62914 llvm-svn: 364032
* [Sema] Improved diagnostic for qualifiers in reference bindingAnastasia Stulova2019-06-211-1/+2
| | | | | | | | | Improved wording and also simplified by using printing method from qualifiers. Differential Revision: https://reviews.llvm.org/D62914 llvm-svn: 364023
* [clang] Small improvments after Adding APValue to ConstantExprGauthier Harnisch2019-06-212-7/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: this patch has multiple small improvements related to the APValue in ConstantExpr. changes: - APValue in ConstantExpr are now cleaned up using ASTContext::addDestruction instead of there own system. - ConstantExprBits Stores the ValueKind of the result beaing stored. - VerifyIntegerConstantExpression now stores the evaluated value in ConstantExpr. - the Constant Evaluator uses the stored value of ConstantExpr when available. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63376 llvm-svn: 364011
* P0840R2: support for [[no_unique_address]] attributeRichard Smith2019-06-201-0/+3
| | | | | | | | | | | | | | | | | Summary: Add support for the C++2a [[no_unique_address]] attribute for targets using the Itanium C++ ABI. This depends on D63371. Reviewers: rjmccall, aaron.ballman Subscribers: dschuff, aheejin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63451 llvm-svn: 363976
* Fix crash and rejects-valid when a later template parameter or defaultRichard Smith2019-06-202-11/+38
| | | | | | | | | | | | | | | | | | | | template argument contains a backreference to a dependently-typed earlier parameter. In a case like: template<typename T, T A, decltype(A) = A> struct X {}; template<typename U> auto Y = X<U, 0>(); we previously treated both references to `A` in the third parameter as being of type `int` when checking the template-id in `Y`. That`s wrong; the type of `A` in these contexts is the dependent type `U`. When we encounter a non-type template argument that we can't convert to the parameter type because of type-dependence, we now insert a dependent conversion node so that the SubstNonTypeTemplateParmExpr for the template argument will have the parameter's type rather than whatever type the argument had. llvm-svn: 363972
* [Sema] Diagnose addr space mismatch while constructing objectsAnastasia Stulova2019-06-203-3/+34
| | | | | | | | | | | | | | If we construct an object in some arbitrary non-default addr space it should fail unless either: - There is an implicit conversion from the address space to default /generic address space. - There is a matching ctor qualified with an address space that is either exactly matching or convertible to the address space of an object. Differential Revision: https://reviews.llvm.org/D62156 llvm-svn: 363944
* Allow copy/move assignment operator to be coroutine as per N4775Vivek Pandya2019-06-191-12/+2
| | | | | | | | | | | | This change fixes https://bugs.llvm.org/show_bug.cgi?id=40997. Reviewers: GorNishanov, rsmith Reviewed by: GorNishanov Subscribers: cfe-commits, lewissbaker, modocache, llvm-commits Differential Revision: https://reviews.llvm.org/D63381 llvm-svn: 363804
* Suggestions to fix -Wmissing-{prototypes,variable-declarations}Aaron Puchert2019-06-181-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've found that most often the proper way to fix this warning is to add `static`, because if the code otherwise compiles and links, the function or variable is apparently not needed outside of the TU. We can't provide a fix-it hint for variable declarations, because multiple VarDecls can share the same type, and if we put static in front of that, we affect all declared variables, some of which might have previous declarations. We also provide no fix-it hint for the rare case of an `extern` function definition, because that would require removing `extern` and I have no idea how to get the source location of the storage class specifier from a FunctionDecl. I believe this information is only available earlier in the AST construction from DeclSpec::getStorageClassSpecLoc(), but we don't have that here. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D59402 llvm-svn: 363749
* Show note for -Wmissing-prototypes for functions with parametersAaron Puchert2019-06-181-16/+15
| | | | | | | | | | | | | | Summary: There was a search for non-prototype declarations for the function, but we only showed the results for zero-parameter functions. Now we show the note for functions with parameters as well, but we omit the fix-it hint suggesting to add `void`. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D62750 llvm-svn: 363748
* [OPENMP]Use host's long double when compiling the code for device.Alexey Bataev2019-06-181-1/+3
| | | | | | | | | The device code must use the same long double type as the host. Otherwise the code cannot be linked and executed properly. Patch adds only basic support and checks for supporting of the host long double double on the device. llvm-svn: 363717
* Recommit [OpenCL] Move OpenCLBuiltins.td and remove unused includeSven van Haastregt2019-06-173-1/+305
| | | | | | | | | | Reland r363242 after fixing an issue with the tablegen dependence. Patch by Pierre Gondois and Sven van Haastregt. Differential revision: https://reviews.llvm.org/D62849 llvm-svn: 363541
* [clang] Add storage for APValue in ConstantExprGauthier Harnisch2019-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When using ConstantExpr we often need the result of the expression to be kept in the AST. Currently this is done on a by the node that needs the result and has been done multiple times for enumerator, for constexpr variables... . This patch adds to ConstantExpr the ability to store the result of evaluating the expression. no functional changes expected. Changes: - Add trailling object to ConstantExpr that can hold an APValue or an uint64_t. the uint64_t is here because most ConstantExpr yield integral values so there is an optimized layout for integral values. - Add basic* serialization support for the trailing result. - Move conversion functions from an enum to a fltSemantics from clang::FloatingLiteral to llvm::APFloatBase. this change is to make it usable for serializing APValues. - Add basic* Import support for the trailing result. - ConstantExpr created in CheckConvertedConstantExpression now stores the result in the ConstantExpr Node. - Adapt AST dump to print the result when present. basic* : None, Indeterminate, Int, Float, FixedPoint, ComplexInt, ComplexFloat, the result is not yet used anywhere but for -ast-dump. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, hiraditya, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62399 llvm-svn: 363493
* [clang] perform semantic checking in constant contextGauthier Harnisch2019-06-152-68/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Since the addition of __builtin_is_constant_evaluated the result of an expression can change based on whether it is evaluated in constant context. a lot of semantic checking performs evaluations with out specifying context. which can lead to wrong diagnostics. for example: ``` constexpr int i0 = (long long)__builtin_is_constant_evaluated() * (1ll << 33); //#1 constexpr int i1 = (long long)!__builtin_is_constant_evaluated() * (1ll << 33); //#2 ``` before the patch, #2 was diagnosed incorrectly and #1 wasn't diagnosed. after the patch #1 is diagnosed as it should and #2 isn't. Changes: - add a flag to Sema to passe in constant context mode. - in SemaChecking.cpp calls to Expr::Evaluate* are now done in constant context when they should. - in SemaChecking.cpp diagnostics for UB are not checked for in constant context because an error will be emitted by the constant evaluator. - in SemaChecking.cpp diagnostics for construct that cannot appear in constant context are not checked for in constant context. - in SemaChecking.cpp diagnostics on constant expression are always emitted because constant expression are always evaluated. - semantic checking for initialization of constexpr variables is now done in constant context. - adapt test that were depending on warning changes. - add test. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62009 llvm-svn: 363488
* [X86] Add checks that immediate for reducesd/ss fits in 8-bits.Craig Topper2019-06-141-0/+2
| | | | llvm-svn: 363472
* Use unsigned for bitfields to avoid sign extensionReid Kleckner2019-06-141-3/+3
| | | | llvm-svn: 363450
* PR42071: Reject weird names for non-type template parameters.Richard Smith2019-06-142-24/+44
| | | | | | Also reject default arguments appearing in invalid locations. llvm-svn: 363447
* Use getOperatorSpelling to get the spelling of an overloaded operatorRichard Smith2019-06-141-2/+3
| | | | | | rather than duplicating operator name tables in multiple places. llvm-svn: 363446
* [OpenMP] Avoid emitting maps for target link variables when unified memory ↵Gheorghe-Teodor Bercea2019-06-141-1/+2
| | | | | | | | | | | | | | | | | | is used Summary: This patch avoids the emission of maps for target link variables when unified memory is present. Reviewers: ABataev, caomhin Reviewed By: ABataev Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60883 llvm-svn: 363435
* Remove unused SK_LValueToRValue initialization step.Richard Smith2019-06-141-27/+0
| | | | | | | | | In addition to being unused and duplicating code, this was also wrong (it didn't properly mark the operand as being potentially not odr-used). This reinstates r363340, reverted in r363352. llvm-svn: 363430
* PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of typeRichard Smith2019-06-142-5/+11
| | | | | | | | | | | nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r363337, reverted in r363352. llvm-svn: 363429
* C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue ↵Richard Smith2019-06-141-26/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. This reinstates r363295, reverted in r363352, with a fix for PR42276: we now produce a proper name for a non-odr-use reference to a static constexpr data member. The name <mangled-name>.const is used in that case; such names are reserved to the implementation for cases such as this and should demangle nicely. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363428
* Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"Sven van Haastregt2019-06-143-304/+1
| | | | | | | | | This reverts commit r363242 as it broke some builds with make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by 'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'. llvm-svn: 363376
* [C++20] add Basic consteval specifierGauthier Harnisch2019-06-1412-103/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: this revision adds Lexing, Parsing and Basic Semantic for the consteval specifier as specified by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html with this patch, the consteval specifier is treated as constexpr but can only be applied to function declaration. Changes: - add the consteval keyword. - add parsing of consteval specifier for normal declarations and lambdas expressions. - add the whether a declaration is constexpr is now represented by and enum everywhere except for variable because they can't be consteval. - adapt diagnostic about constexpr to print constexpr or consteval depending on the case. - add tests for basic semantic. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: eraman, efriedma, rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61790 llvm-svn: 363362
OpenPOWER on IntegriCloud