summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [AST] Fix -ast-print for _Bool when have diagnosticsJoel E. Denny2018-05-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, given: #define bool _Bool _Bool i; void fn() { 1; } -ast-print produced: tmp.c:3:13: warning: expression result unused void fn() { 1; } ^ bool i; void fn() { 1; } That fails to compile because bool is undefined. Details: Diagnostics print _Bool as bool when the latter is defined as the former. However, diagnostics were altering the printing policy for -ast-print as well. The printed source was then invalid because the preprocessor eats the bool definition. Problematic diagnostics included suppressed warnings (e.g., add -Wno-unused-value to the above example), including those that are suppressed by default. This patch fixes this bug and cleans up some related comments. Reviewed by: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D45093 llvm-svn: 332275
* [CodeComplete] Provide completion in decls even for incomplete typesIlya Biryukov2018-05-141-4/+2
| | | | | | | | | | | | | | | | | | | | Summary: This change fixes lack of completions in the following case ('^'designates completion points) : void f(^); struct Incomplete; Incomplete g(^); Reviewers: bkramer, aaron.ballman, sammccall Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46639 llvm-svn: 332244
* Added atomic_fetch_min, max, umin, umax intrinsics to clang.Elena Demikhovsky2018-05-131-2/+18
| | | | | | | | | These intrinsics work exactly as all other atomic_fetch_* intrinsics and allow to create *atomicrmw* with ordering. Updated the clang-extensions document. Differential Revision: https://reviews.llvm.org/D46386 llvm-svn: 332193
* [Hexagon] Implement checking arguments of builtin callsKrzysztof Parzyszek2018-05-111-0/+223
| | | | llvm-svn: 332105
* Improve diagnostics and error recovery for template name lookup.Richard Smith2018-05-114-80/+127
| | | | | | | | | | | | | For 'x::template y', consistently give a "no member named 'y' in 'x'" diagnostic if there is no such member, and give a 'template keyword not followed by a template' name error if there is such a member but it's not a template. In the latter case, add a note pointing at the non-template. Don't suggest inserting a 'template' keyword in 'X::Y<' if X is dependent if the lookup of X::Y was actually not a dependent lookup and found only non-templates. llvm-svn: 332076
* Don't propagate dllimport to base class template static data membersReid Kleckner2018-05-111-0/+17
| | | | | | MSVC doesn't, so we shouldn't. Fixes PR37232. llvm-svn: 332074
* Allow dllimport non-type template arguments in C++17Reid Kleckner2018-05-101-3/+4
| | | | | | | | | | | Summary: Fixes PR35772. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D43320 llvm-svn: 332018
* [Clang] Implement function attribute no_stack_protector.Manoj Gupta2018-05-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: This attribute tells clang to skip this function from stack protector when -stack-protector option is passed. GCC option for this is: __attribute__((__optimize__("no-stack-protector"))) and the equivalent clang syntax would be: __attribute__((no_stack_protector)) This is used in Linux kernel to selectively disable stack protector in certain functions. Reviewers: aaron.ballman, rsmith, rnk, probinson Reviewed By: aaron.ballman Subscribers: probinson, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D46300 llvm-svn: 331925
* [OpenCL] Add constant address space to __func__ in AST.Anastasia Stulova2018-05-091-13/+10
| | | | | | | | | | | | Added string literal helper function to obtain the type attributed by a constant address space. Also fixed predefind __func__ expr to use the helper to constract the string literal correctly. Differential Revision: https://reviews.llvm.org/D46049 llvm-svn: 331877
* [OpenCL] Restrict various keywords in OpenCL C++ modeSven van Haastregt2018-05-093-0/+26
| | | | | | | | | | | | | | | | | | | | | | | Restrict the following keywords in the OpenCL C++ language mode, according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification. - dynamic_cast - typeid - register (already restricted in OpenCL C, update the diagnostic) - thread_local - exceptions (try/catch/throw) - access qualifiers read_only, write_only, read_write Support the `__global`, `__local`, `__constant`, `__private`, and `__generic` keywords in OpenCL C++. Leave the unprefixed address space qualifiers such as global available, i.e., do not mark them as reserved keywords in OpenCL C++. libclcxx provides explicit address space pointer classes such as `global_ptr` and `global<T>` that are implemented using the `__`-prefixed qualifiers. Differential Revision: https://reviews.llvm.org/D46022 llvm-svn: 331874
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-0939-1058/+1058
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Fix float->int conversion warnings when near barriers.Erich Keane2018-05-081-20/+12
| | | | | | | | | | | | As Eli brought up here: https://reviews.llvm.org/D46535 I'd previously messed up this fix by missing conversions that are just slightly outside the range. This patch fixes this by no longer ignoring the return value of convertToInteger. Additionally, one of the error messages wasn't very sensical (mentioning out of range value, when it really was not), so it was cleaned up as well. llvm-svn: 331812
* [C++2a] operator<=>: Fix incorrect use of Twine.Eric Fiselier2018-05-081-3/+3
| | | | llvm-svn: 331713
* [C++2a] Implement operator<=>: Address bugs and post-commit review comments ↵Eric Fiselier2018-05-082-6/+8
| | | | | | | | | | | | after r331677. This patch addresses some mostly trivial post-commit review comments received on r331677. Additionally, this patch fixes an assertion in `getNarrowingKind` caused by the use of an uninitialized value from `checkThreeWayNarrowingConversion`. llvm-svn: 331707
* [C++2a] Implement operator<=> CodeGen and ExprConstantEric Fiselier2018-05-074-67/+463
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch tackles long hanging fruit for the builtin operator<=> expressions. It is currently needs some cleanup before landing, but I want to get some initial feedback. The main changes are: * Lookup, build, and store the required standard library types and expressions in `ASTContext`. By storing them in ASTContext we don't need to store (and duplicate) the required expressions in the BinaryOperator AST nodes. * Implement [expr.spaceship] checking, including diagnosing narrowing conversions. * Implement `ExprConstant` for builtin spaceship operators. * Implement builitin operator<=> support in `CodeGenAgg`. Initially I emitted the required comparisons using `ScalarExprEmitter::VisitBinaryOperator`, but this caused the operand expressions to be emitted once for every required cmp. * Implement [builtin.over] with modifications to support the intent of P0946R0. See the note on `BuiltinOperatorOverloadBuilder::addThreeWayArithmeticOverloads` for more information about the workaround. Reviewers: rsmith, aaron.ballman, majnemer, rnk, compnerd, rjmccall Reviewed By: rjmccall Subscribers: rjmccall, rsmith, aaron.ballman, junbuml, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D45476 llvm-svn: 331677
* Correct warning on Float->Integer conversions.Erich Keane2018-05-071-0/+17
| | | | | | | | | | | | | | | | | | As identified and briefly discussed here: https://bugs.llvm.org/show_bug.cgi?id=37305 Converting a floating point number to an integer type when the integral part is out of the range of the integer type is undefined behavior in C. Additionally, CodeGen emits an undef in this situation. HOWEVER, we've been giving a warning that says that the value is changed. This patch corrects the warning to list that it is actually undefined behavior. Differential Revision: https://reviews.llvm.org/D46535 llvm-svn: 331673
* Fix explicit template parameter reporting for narrowing conversionsErich Keane2018-05-071-0/+4
| | | | | | | | | | | | | | | | | | I found that explicit template parameters that caused a narrowing integer conversion resulted in the incorrect parameter being mentioned in the note (see test attached). This is because the argument checking code doesn't check to see if it caused SFINAE errors when checking the arguments, so instead of giving up on the first error, it continues through the list. This makes the error reporting pick up the last template param every time. This patch checks these parameters on each argument and gives up if there is an error. The result is that only the required amount of arguments are checked, and that the 'Converted' array contains only the successful arguments before the first failure, as the calls seem to all expect. llvm-svn: 331651
* Disallow pointers to const in __sync_fetch_and_xxx.Aaron Ballman2018-05-051-0/+6
| | | | | | | | | | | | Diagnoses code like: void f(const int *ptr) { __sync_fetch_and_add(ptr, 1); } which matches the behavior of GCC and ICC. llvm-svn: 331598
* Allow writing calling convention attributes on function types.Aaron Ballman2018-05-031-4/+9
| | | | | | Calling convention attributes notionally appertain to the function type -- they modify the mangling of the function, change the behavior of assignment operations, etc. This commit allows the calling convention attributes to be written in the type position as well as the declaration position. llvm-svn: 331459
* Track the result of evaluating a computed noexcept specification on theRichard Smith2018-05-0313-226/+168
| | | | | | | | | | | | | | FunctionProtoType. We previously re-evaluated the expression each time we wanted to know whether the type is noexcept or not. We now evaluate the expression exactly once. This is not quite "no functional change": it fixes a crasher bug during AST deserialization where we would try to evaluate the noexcept specification in a situation where we have not deserialized sufficient portions of the AST to permit such evaluation. llvm-svn: 331428
* [Sema] Do not match function type with const T in template argument deductionLei Liu2018-05-031-0/+6
| | | | | | | | | | | From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584, function type should not match cv-qualified type in template argument deduction. This also matches what GCC and EDG do in template argument deduction. Differential Revision: https://reviews.llvm.org/D45755 llvm-svn: 331424
* [ObjC] Supress the 'implementing unavailable method' warning whenAlex Lorenz2018-05-031-2/+10
| | | | | | | | | | | | | the method declaration is unavailable for an app extension platform Rationale: Classes are often shared between an app extension code and non-app extension code. There's no way to remove the implementation using preprocessor when building the app extension, so we should not warn here. rdar://38150617 llvm-svn: 331421
* [ObjC] The absence of ownership qualifiers on an ambiguous property leadsAlex Lorenz2018-05-021-4/+14
| | | | | | | | | to synthesis of a valid property even when the selected protocol property has ownership qualifiers rdar://39024725 llvm-svn: 331409
* [OPENMP] Analyze the type of the mapped entity instead of its base.Alexey Bataev2018-05-021-1/+8
| | | | | | | If the mapped entity is a data member, we erroneously checked the type of its base rather than the type of the mapped entity itself. llvm-svn: 331385
* [OPENMP] Do not emit warning for implicitly declared target functions.Alexey Bataev2018-05-021-14/+16
| | | | | | | Since upcoming OpenMP 5.0 functions can be mapped implicitly as declare target and we should not emit warnings for such functions. llvm-svn: 331377
* [OPENMP] Enable c++ exceptions outside of the target constructs iff they areAlexey Bataev2018-05-022-2/+10
| | | | | | | | | | enabled for the host. If the compilation for the host enables C++ exceptions, but they are not supported by the device, we still need to allow the code with the exception handling constructs outside of the target regions. llvm-svn: 331372
* Implement P0482R2, support for char8_t type.Richard Smith2018-05-019-10/+70
| | | | | | | | | | | | This is not yet part of any C++ working draft, and so is controlled by the flag -fchar8_t rather than a -std= flag. (The GCC implementation is controlled by a flag with the same name.) This implementation is experimental, and will be removed or revised substantially to match the proposal as it makes its way through the C++ committee. llvm-svn: 331244
* [OPENMP] Do not emit warning about non-declared target function params.Alexey Bataev2018-04-301-1/+1
| | | | | | | | We should not emit warning that the parameters are not marked as declare target, these declaration are local and cannot be marked as declare target. llvm-svn: 331211
* PR37189 Fix incorrect end source location and spelling for a split '>>' token.Richard Smith2018-04-305-6/+8
| | | | | | | | | | | | | | | | | | When a '>>' token is split into two '>' tokens (in C++11 onwards), or (as an extension) when we do the same for other tokens starting with a '>', we can't just use a location pointing to the first '>' as the location of the split token, because that would result in our miscomputing the length and spelling for the token. As a consequence, for example, a refactoring replacing 'A<X>' with something else would sometimes replace one character too many, and similarly diagnostics highlighting a template-id source range would highlight one character too many. Fix this by creating an expansion range covering the first character of the '>>' token, whose spelling is '>'. For this to work, we generalize the expansion range of a macro FileID to be either a token range (the common case) or a character range (used in this new case). llvm-svn: 331155
* Test commit removing trailing whitespaceStuart Brady2018-04-271-1/+1
| | | | llvm-svn: 331053
* Parse A::template B as an identifier rather than as a template-id with noRichard Smith2018-04-273-11/+14
| | | | | | | | | | template arguments. This fixes some cases where we'd incorrectly accept "A::template B" when B is a kind of template that requires template arguments (in particular, a variable template or a concept). llvm-svn: 331013
* [X86] Make __builtin_ia32_readeflags_u32 and __builtin_ia32_writeeflags_u32 ↵Craig Topper2018-04-261-0/+17
| | | | | | | | | | | | only available on 32-bit targets. These builtins can't be handled by the backend on 64-bit targets. So error up front instead of throwing an isel error. Fixes PR37225 Differential Revision: https://reviews.llvm.org/D46132 llvm-svn: 330987
* Diagnose missing template arguments for a variable template even when there isRichard Smith2018-04-261-0/+8
| | | | | | | | | a preceding 'template' keyword. We only diagnose in the dependent case (wherein we used to crash). Another bug prevents the diagnostic from appearing in the non-template case. llvm-svn: 330894
* Revert addition of 'concept' to diagnostics in r330890.Richard Smith2018-04-261-2/+0
| | | | | | Matches revert in r330888 of r330794. llvm-svn: 330891
* Factor out common code for diagnosing missing template arguments.Richard Smith2018-04-264-22/+18
| | | | | | In passing, add 'concept' to the list of template kinds in diagnostics. llvm-svn: 330890
* Fix a merge conflict that was inadvertently introduced in r330888 Faisal Vali2018-04-261-6/+0
| | | | | | - during the reversion of r330794 llvm-svn: 330889
* Revert rC330794 and some dependent tiny bug fixes Faisal Vali2018-04-265-150/+5
| | | | | | | | | | | | | | See Richard's humbling feedback here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html Wish I'd had the patience to solicit the feedback prior to committing :) Sorry for the noise guys. Thank you Richard for being the steward that clang deserves! llvm-svn: 330888
* Fix crash on qualified template name instantiation if the template name has noRichard Smith2018-04-251-6/+9
| | | | | | template argument list. llvm-svn: 330881
* [c++2a] [concepts] Add rudimentary parsing support for template concept ↵Faisal Vali2018-04-255-8/+160
| | | | | | | | | | | | | | declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! llvm-svn: 330794
* [HIP] Add hip input kind and codegen for kernel launchingYaxun Liu2018-04-252-4/+7
| | | | | | | | | | | | | | | | | | | | | | | HIP is a language similar to CUDA (https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md ). The language syntax is very similar, which allows a hip program to be compiled as a CUDA program by Clang. The main difference is the host API. HIP has a set of vendor neutral host API which can be implemented on different platforms. Currently there is open source implementation of HIP runtime on amdgpu target (https://github.com/ROCm-Developer-Tools/HIP). This patch adds support of input kind and language standard hip. When hip file is compiled, both LangOpts.CUDA and LangOpts.HIP is turned on. This allows compilation of hip program as CUDA in most cases and only special handling of hip program is needed LangOpts.HIP is checked. This patch also adds support of kernel launching of HIP program using HIP host API. When -x hip is not specified, there is no behaviour change for CUDA. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44984 llvm-svn: 330790
* Improve -Warray-bounds to handle multiple array extents rather than only ↵Aaron Ballman2018-04-241-1/+6
| | | | | | | | handling the top-most array extent. Patch by Bevin Hansson. llvm-svn: 330759
* [Sema] Add -Wno-self-assign-overloadedRoman Lebedev2018-04-231-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It seems there isn't much enthusiasm for `-wtest` D45685. This is more conservative version, which i had in the very first revision of D44883, but that 'erroneously' got removed because of the review. **Based on some [irc] discussions, it must really be documented that we want all the new diagnostics to have their own flags, to ease rollouts, transitions, etc.** Please do note that i'm only adding `-Wno-self-assign-overloaded`, but not `-Wno-self-assign-field-overloaded`, because i'm honestly not aware of any false-positives from the `-field` variant, but i can just as easily add it if wanted. https://reviews.llvm.org/D44883#1068561 Reviewers: dblaikie, aaron.ballman, thakis, rjmccall, rsmith Reviewed By: dblaikie Subscribers: Quuxplusone, chandlerc, cfe-commits Differential Revision: https://reviews.llvm.org/D45766 llvm-svn: 330651
* DR727: remove wrong assertion for use of class-scope explicitRichard Smith2018-04-231-4/+0
| | | | | | specialization without -fms-extensions. llvm-svn: 330626
* [OPENMP] Fix -Wunused-lambda-capture. NFCFangrui Song2018-04-181-0/+1
| | | | llvm-svn: 330284
* [OPENMP] Code cleanup and code improvements.Alexey Bataev2018-04-183-1003/+1004
| | | | llvm-svn: 330270
* [Sema] Disable built-in increment operator for bool in overload resolution ↵Jan Korous2018-04-181-5/+11
| | | | | | | | | | | | | | | | | in C++17 Following: https://llvm.org/svn/llvm-project/cfe/trunk@329804 For C++17 the wording of [over.built] p4 excluded bool: For every pair (T , vq), where T is an arithmetic type other than bool, there exist candidate operator functions of the form vq T & operator++(vq T &); T operator++(vq T &, int); Differential Revision: https://reviews.llvm.org/D45569 llvm-svn: 330254
* [Sema] Warn about memcpy'ing non-trivial C structs.Akira Hatanaka2018-04-171-1/+110
| | | | | | | | | | | Issue a warning when non-trivial C structs are copied or initialized by calls to memset, bzero, memcpy, or memmove. rdar://problem/36124208 Differential Revision: https://reviews.llvm.org/D45310 llvm-svn: 330202
* [Availability] Improve availability to consider functions run at load timeSteven Wu2018-04-163-0/+32
| | | | | | | | | | | | | | | | | | | | | | Summary: There are some functions/methods that run when the application launches or the library loads. Those functions will run reguardless the OS version as long as it satifies the minimum deployment target. Annotate them with availability attributes doesn't really make sense because they are essentially available on all targets since minimum deployment target. rdar://problem/36093384 Reviewers: arphaman, erik.pilkington Reviewed By: erik.pilkington Subscribers: erik.pilkington, cfe-commits Differential Revision: https://reviews.llvm.org/D45699 llvm-svn: 330166
* Limit types of builtins that can be redeclared.Erich Keane2018-04-162-0/+15
| | | | | | | | | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033 Any usage of a builtin function that uses a va_list by reference will cause an assertion when redeclaring it. After discussion in the review, it was concluded that the correct way of accomplishing this fix is to make attempts to redeclare certain builtins an error. Unfortunately, doing this limitation for all builtins is likely a breaking change, so this commit simply limits it to types with custom type checking and those that take a reference. Two tests needed to be updated to make this work. Differential Revision: https://reviews.llvm.org/D45383 llvm-svn: 330160
* Clean carriage returns from lib/ and include/. NFC.Malcolm Parsons2018-04-163-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Clean carriage returns from lib/ and include/. NFC. (I have to make this change locally in order for `git diff` to show sane output after I edit a file, so I might as well ask for it to be committed. I don't have commit privs myself.) (Without this patch, `git rebase`ing any change involving SemaDeclCXX.cpp is a real nightmare. :( So while I have no right to ask for this to be committed, geez would it make my workflow easier if it were.) Here's the command I used to reformat things. (Requires bash and OSX/FreeBSD sed.) git grep -l $'\r' lib include | xargs sed -i -e $'s/\r//' find lib include -name '*-e' -delete Reviewers: malcolm.parsons Reviewed By: malcolm.parsons Subscribers: emaste, krytarowski, cfe-commits Differential Revision: https://reviews.llvm.org/D45591 Patch by Arthur O'Dwyer. llvm-svn: 330112
OpenPOWER on IntegriCloud