summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenCL] Support logical vector operators in C++ modeSven van Haastregt2019-05-301-2/+3
| | | | | | | | | Support logical operators on vectors in C++ for OpenCL mode, to preserve backwards compatibility with OpenCL C. Differential Revision: https://reviews.llvm.org/D62588 llvm-svn: 362087
* Add the `objc_class_stub` attribute.John McCall2019-05-302-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Swift requires certain classes to be not just initialized lazily on first use, but actually allocated lazily using information that is only available at runtime. This is incompatible with ObjC class initialization, or at least not efficiently compatible, because there is no meaningful class symbol that can be put in a class-ref variable at load time. This leaves ObjC code unable to access such classes, which is undesirable. objc_class_stub says that class references should be resolved by calling a new ObjC runtime function with a pointer to a new "class stub" structure. Non-ObjC compilers (like Swift) can simply emit this structure when ObjC interop is required for a class that cannot be statically allocated, then apply this attribute to the `@interface` in the generated ObjC header for the class. This attribute can be thought of as a generalization of the existing `objc_runtime_visible` attribute which permits more efficient class resolution as well as supporting the additon of categories to the class. Subclassing these classes from ObjC is currently not allowed. Patch by Slava Pestov! llvm-svn: 362054
* clang support gnu asm goto.Jennifer Yu2019-05-303-54/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045
* [CodeComplete] Add semicolon when completing patterns for 'static_assert' ↵Ilya Biryukov2019-05-291-0/+2
| | | | | | | | | and 'typedef This is a trivial follow-up to r360042, which added semicolons to other pattern completions, so sending without review. llvm-svn: 361974
* [mips] Check argument for __builtin_msa_ctcmsa / __builtin_msa_cfcmsaSimon Atanasyan2019-05-291-0/+2
| | | | | | | | | | | | | The `__builtin_msa_ctcmsa` and `__builtin_msa_cfcmsa` builtins are mapped to the `ctcmsa` and `cfcmsa` instructions respectively. While MSA control registers have indexes in 0..7 range, the instructions accept register index in 0..31 range [1]. [1] MIPS Architecture for Programmers Volume IV-j: The MIPS64 SIMD Architecture Module https://www.mips.com/?do-download=the-mips64-simd-architecture-module llvm-svn: 361967
* [X86] Fix the Sema checks for getmant builtins to only allow 4 and 8 for ↵Craig Topper2019-05-281-7/+4
| | | | | | | | | rounding immediates. These don't support embedded rounding so we shouldn't be setting HasRC. That way we only allow current direction and suppress all exceptions. llvm-svn: 361897
* Defer creating fields for captures until we finish building theRichard Smith2019-05-287-150/+103
| | | | | | | | | | | | | | | capturing expression or statement. No functionality change yet. The intent is that we will also delay building the initialization expression until the enclosing context, so that: a) we build the initialization expression in the right context, and b) we can elide captures that are not odr-used, as suggested by P0588R1. This also consolidates some duplicated code building capture fields into a single place. llvm-svn: 361893
* If capturing a variable fails, add a capture anyway (and mark itRichard Smith2019-05-284-50/+68
| | | | | | invalid) so that we can avoid repeated diagnostics for the same capture. llvm-svn: 361891
* Move code to mark a variable as odr-used adjacement to all the relatedRichard Smith2019-05-282-5/+39
| | | | | | | | code. No functional change intended. llvm-svn: 361890
* [CodeComplete] Set preferred type for qualified-idIlya Biryukov2019-05-281-5/+11
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62514 llvm-svn: 361838
* [CodeComplete] Consistently break after '{' in multi-line patternsIlya Biryukov2019-05-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Completion can return multi-line patterns in some cases, e.g. for (<#init#>; <#cond#>; <#inc#>) { <#body#> } However, most patterns break the line only before closing brace, resulting in code like: namespace <#name#> { <#decls#> } While some (e.g. the 'for' example above) are breaking lines after the opening brace too. This change ensures all patterns consistently break after the opening brace, this leads to nicer UX when using those in an actual editor. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62405 llvm-svn: 361829
* [OpenCL] Fix file-scope const sampler variable for 2.0Yaxun Liu2019-05-271-1/+15
| | | | | | | | | | | | | | | | | | | OpenCL spec v2.0 s6.13.14: Samplers can also be declared as global constants in the program source using the following syntax. const sampler_t <sampler name> = <value> This works fine for OpenCL 1.2 but fails for 2.0, because clang duduces address space of file-scope const sampler variable to be in global address space whereas spec v2.0 s6.9.b forbids file-scope sampler variable to be in global address space. The fix is not to deduce address space for file-scope sampler variables. Differential Revision: https://reviews.llvm.org/D62197 llvm-svn: 361757
* [CodeComplete] Complete 'return true/false' in boolean functionsIlya Biryukov2019-05-271-11/+26
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62391 llvm-svn: 361753
* Permit static local structured bindings to be named from arbitrary scopes ↵Richard Smith2019-05-251-3/+5
| | | | | | inside their declaring scope. llvm-svn: 361686
* Default arguments are potentially constant evaluated.Richard Smith2019-05-241-5/+1
| | | | | | | | We need to eagerly instantiate constexpr functions used in them even if the default argument is never actually used, because we might evaluate portions of it when performing semantic checks. llvm-svn: 361670
* Refactor use-marking to better match standard terminology. NoRichard Smith2019-05-241-162/+244
| | | | | | functionality change intended. llvm-svn: 361668
* [CodeComplete] Add whitespace around braces in lambda completionsIlya Biryukov2019-05-241-0/+3
| | | | | | | This produces nicer output. Trivial follow-up to r361461, so sending without review. llvm-svn: 361645
* [CodeComplete] Filter override completions by function nameIlya Biryukov2019-05-241-18/+29
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We put only part of the signature starting with a function name into "typed text" chunks now, previously the whole signature was "typed text". This leads to meaningful fuzzy match scores, giving better signals to compare with other completion items. Ideally, we would not display the result type to the user, but that requires adding a new kind of completion chunk. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62298 llvm-svn: 361623
* Factor out repeated code to build 'this' expressions and mark themRichard Smith2019-05-244-15/+21
| | | | | | referenced. llvm-svn: 361588
* [CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *.Artem Dergachev2019-05-241-6/+8
| | | | | | | | | | | Turn it into a variant class instead. This conversion does indeed save some code but there's a plan to add support for more kinds of terminators that aren't necessarily based on statements, and with those in mind it becomes more and more confusing to have CFGTerminators implicitly convertible to a Stmt *. Differential Revision: https://reviews.llvm.org/D61814 llvm-svn: 361586
* [CodeComplete] Only show lambda completions if patterns are requestedIlya Biryukov2019-05-231-0/+2
| | | | | | This is a trivial follow-up to r361461, so sending without review. llvm-svn: 361510
* Ensure builtins use the target default Calling ConventionErich Keane2019-05-231-1/+1
| | | | | | | | | | | | | | | | | r355317 changed builtins/allocation functions to use the default calling convention in order to support platforms that use non-cdecl calling conventions by default. However the default calling convention is overridable on Windows 32 bit implementations with some of the /G options. The intent is to permit the user to set the calling convention of normal functions, however it should NOT apply to builtins and C++ allocation functions. This patch ensures that the builtin/allocation functions always use the Target specific Calling Convention, ignoring the user overridden version of said default. llvm-svn: 361507
* Enable queue_t and clk_event_t comparisons in C++ modeSven van Haastregt2019-05-231-1/+1
| | | | | | | | | Support queue_t and clk_event_t comparisons in C++ for OpenCL mode, to preserve backwards compatibility with OpenCL C. Differential Revision: https://reviews.llvm.org/D62208 llvm-svn: 361467
* [CodeComplete] Complete a lambda when preferred type is a functionIlya Biryukov2019-05-231-0/+71
| | | | | | | | | | | | | | | | Summary: Uses a heuristic to detect std::function and friends. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62238 llvm-svn: 361461
* Part of P1091R3: permit structured bindings to be declared 'static' andRichard Smith2019-05-221-5/+25
| | | | | | 'thread_local' in C++20. llvm-svn: 361424
* [OpenCL] Support pipe keyword in C++ modeSven van Haastregt2019-05-222-3/+5
| | | | | | | | | | | | Support the OpenCL C pipe feature in C++ for OpenCL mode, to preserve backwards compatibility with OpenCL C. Various changes had to be made in Parse and Sema to enable pipe-specific diagnostics, so enable a SemaOpenCL test for C++. Differential Revision: https://reviews.llvm.org/D62181 llvm-svn: 361382
* Refactor: split Uninitialized state on APValue into an "Absent" stateRichard Smith2019-05-211-1/+4
| | | | | | | representing no such object, and an "Indeterminate" state representing an uninitialized object. The latter is not yet used, but soon will be. llvm-svn: 361328
* [c++20] P0780R2: Support pack-expansion of init-captures.Richard Smith2019-05-215-102/+210
| | | | | | | | | | | This permits an init-capture to introduce a new pack: template<typename ...T> auto x = [...a = T()] { /* a is a pack */ }; To support this, the mechanism for allowing ParmVarDecls to be packs has been extended to support arbitrary local VarDecls. llvm-svn: 361300
* Do not use the incorrect attribute spelling list index when translating a ↵Aaron Ballman2019-05-211-3/+15
| | | | | | | | no_sanitize_foo attribute into a no_sanitize("foo") attribute. This fixes a crash when AST pretty printing declarations marked with no_sanitize_memory. llvm-svn: 361274
* Added an assertion to constant evaluation enty points that prohibits ↵Dmitri Gribenko2019-05-172-4/+16
| | | | | | | | | | | | | | | | | | dependent expressions Summary: Constant evaluator does not work on value-dependent or type-dependent expressions. Also fixed bugs uncovered by these assertions. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61522 llvm-svn: 361050
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-4/+5
| | | | | | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) This reinstates r360974, reverted in r360988, with a fix for a static_assert failure on 32-bit builds: force Type base class to have 8-byte alignment like the rest of Clang's AST nodes. llvm-svn: 360995
* Revert Refactor constant evaluation of typeid(T) to track a symbolic ↵Chris Bieneman2019-05-171-5/+4
| | | | | | | | type_info object rather than tracking the originating expression. This reverts r360974 (git commit 7ee4307bd4450022c3c8777f43a40cc4f0ccc009) llvm-svn: 360988
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-4/+5
| | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) llvm-svn: 360974
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-165-33/+57
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* [CodeComplete] Complete enumerators when preferred type is an enumIlya Biryukov2019-05-161-21/+44
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62010 llvm-svn: 360912
* Fix regression in r360311 caused by reversed bool arguments.Richard Smith2019-05-161-1/+2
| | | | llvm-svn: 360837
* Test commitKevin Petit2019-05-151-1/+1
| | | | | | | Remove stray space. Signed-off-by: Kevin Petit <kevin.petit@arm.com> llvm-svn: 360783
* [c++20] P1064R0: Allow virtual function calls in constant expressionRichard Smith2019-05-132-16/+34
| | | | | | | | | | | | | evaluation. This reinstates r360559, reverted in r360580, with a fix to avoid crashing if evaluation-for-overflow mode encounters a virtual call on an object of a class with a virtual base class, and to generally not try to resolve virtual function calls to objects whose (notional) vptrs are not readable. (The standard rules are unclear here, but this seems like a reasonable approach.) llvm-svn: 360635
* Make more friendly with unions. Reviewed as https://reviews.llvm.org/D61858Marshall Clow2019-05-131-1/+8
| | | | llvm-svn: 360614
* Revert r360559 "[c++20] P1064R0: Allow virtual function calls in constant ↵Hans Wennborg2019-05-132-34/+16
| | | | | | | | | expression evaluation." This caused Chromium builds to hit the new "can't handle virtual calls with virtual bases" assert. Reduced repro coming up. llvm-svn: 360580
* PR41845: Detect and reject mismatched inner/outer pack expansion sizesRichard Smith2019-05-132-10/+16
| | | | | | in fold expressions rather than crashing. llvm-svn: 360563
* [c++20] P1064R0: Allow virtual function calls in constant expressionRichard Smith2019-05-132-16/+34
| | | | | | evaluation. llvm-svn: 360559
* make -ftime-trace also print template argumentsLubos Lunak2019-05-122-2/+10
| | | | | | | | | Without this, I get e.g. 'PerformPendingInstantiations' -> 'std::fill', now I get 'std::fill<unsigned long *, int>'. Differential Revision: https://reviews.llvm.org/D61822 llvm-svn: 360539
* Improve interface of APValuePathEntry.Richard Smith2019-05-101-1/+1
| | | | llvm-svn: 360463
* [Sema] Mark array element destructors referenced during initializationErik Pilkington2019-05-103-53/+52
| | | | | | | | | | | | This fixes a crash where we would neglect to mark a destructor referenced for an __attribute__((no_destory)) array. The destructor is needed though, since if an exception is thrown we need to cleanup the elements. rdar://48462498 Differential revision: https://reviews.llvm.org/D61165 llvm-svn: 360446
* Assume `__cxa_allocate_exception` returns an under-aligned memory onAkira Hatanaka2019-05-101-0/+15
| | | | | | | | | | | | | | | | | | | | | Darwin if the version of libc++abi isn't new enough to include the fix in r319123 This patch resurrects r264998, which was committed to work around a bug in libc++abi that was causing _cxa_allocate_exception to return a memory that wasn't double-word aligned. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160328/154332.html In addition, this patch makes clang issue a warning if the type of the thrown object requires an alignment that is larger than the minimum guaranteed by the target C++ runtime. rdar://problem/49864414 Differential Revision: https://reviews.llvm.org/D61667 llvm-svn: 360404
* Remember to decay arrays to pointers before checking whether theRichard Smith2019-05-091-3/+6
| | | | | | left-hand side of an -> operator is a pointer to class type. llvm-svn: 360387
* [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with default(none).Alexey Bataev2019-05-091-3/+95
| | | | | | | | | If the combined directive has default(none) clause and has clauses for inner directive that reference some variables, for which data-sharing attributes are not specified, the error messages should be emitted for such variables. llvm-svn: 360365
* [OPENMP]Fix PR41768: check DSA for globals with default(none) clauses.Alexey Bataev2019-05-092-3/+26
| | | | | | | | If the default(none) was specified for the construct, we might miss diagnostic for the globals without explicitly specified data-sharing attributes. Patch fixes this problem. llvm-svn: 360362
* Revert "[OPENMP]Fix PR41768: check DSA for globals with `default(none)` ↵Roman Lebedev2019-05-091-7/+1
| | | | | | | | | | | | clauses." This has introduced (exposed?) a crash in clang sema, that does not happen without this patch. I'll followup in the original bugreport and commit with reproducer. This reverts commit r360061. llvm-svn: 360327
OpenPOWER on IntegriCloud