summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Fix for PR34398: assert with random access iterator if theAlexey Bataev2017-08-311-2/+2
| | | | | | | | | | | | step>1. If the loop is a loot with random access iterators and the iteration construct is represented it += n, then the compiler crashed because of reusing of the same MaterializedTemporaryExpr around N. Patch fixes it by using the expression as written, without any special kind of wrappings. llvm-svn: 312292
* Suppress -Wdelete-non-virtual-dtor warnings about classes defined in system ↵Nico Weber2017-08-311-0/+6
| | | | | | | | | | | | | | | | headers. r312167 made it so that we emit Wdelete-non-virtual-dtor from delete statements that are in system headers (e.g. std::unique_ptr). That works great on Linux and macOS, but on Windows there are non-final classes that are defined in system headers that have virtual methods but non-virtual destructors and yet get deleted through a base class pointer (e.g. ATL::CAccessToken::CRevert). So paddle back a bit and don't emit the warning if it's about a class defined in a system header. https://reviews.llvm.org/D37324 llvm-svn: 312216
* Let -Wdelete-non-virtual-dtor fire in system headers too.Nico Weber2017-08-301-1/+1
| | | | | | | | | | | | | Makes the warning useful again in a std::unique_ptr world, PR28460. Also make the warning not fire in unevaluated contexts, since system libraries (e.g. libc++) do do that. This would've been a good change before we started emitting this warning in system headers too, but "normal" code seems to be less template-heavy, so we didn't notice until now. https://reviews.llvm.org/D37235 llvm-svn: 312167
* Give a better error if auto deduction fails due to inconsistent element ↵Richard Smith2017-08-301-25/+67
| | | | | | types in a braced initializer list. llvm-svn: 312085
* PR10147: When substituting a template template argument, substitute in the mostRichard Smith2017-08-291-9/+5
| | | | | | | recent (non-friend) declaration to pick up the right set of default template arguments. llvm-svn: 312049
* [OPENMP] Capture global variables in all target executable regions.Alexey Bataev2017-08-291-1/+1
| | | | | | | | Capturing of the global variables occurs only in target regions. Patch fixes it and allows capturing of globals in all target executable directives. llvm-svn: 312024
* revert r311839 (ongoing cwg discussion)Faisal Vali2017-08-291-1/+1
| | | | | | apologies. llvm-svn: 311975
* [OPENMP] Remove unused header files, NFC.Alexey Bataev2017-08-281-3/+0
| | | | llvm-svn: 311908
* revert changes from r311851.Faisal Vali2017-08-271-7/+7
| | | | | | | | The right answers here (and how clang needs to be tweaked) require further analysis (ongoing cwg thread). sorry. llvm-svn: 311855
* Don't see through 'using member-declarations' when determining the relation ↵Faisal Vali2017-08-271-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | of any potential implicit object expression to the parent class of the member function containing the function call. Prior to this patch clang would not error here: template <class T> struct B; template <class T> struct A { void foo(); void foo2(); void test1() { B<T>::foo(); // OK, foo is declared in A<int> - matches type of 'this'. B<T>::foo2(); // This should be an error! // foo2 is found in B<int>, 'base unrelated' to 'this'. } }; template <class T> struct B : A<T> { using A<T>::foo2; }; llvm-svn: 311851
* Pass the correct object argument when a member call to an 'unrelated' class ↵Faisal Vali2017-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | is made. Prior to this patch, clang would do the wrong thing here (see inline comments for pre-patch behavior): struct A { void bar(int) { } static void bar(double) { } void g(int*); static void g(char *); }; struct B { void f() { A::bar(3); // selects (double) ??!! A::g((int*)0); // Instead of no object argument, states conversion error?!! } }; The fix is as follows: When we detect that what appears to be an implicit member function call (A::bar) is actually a call to a member of a class (A) unrelated to the type (B) that contains the member function (B::f) from which the call is being made, don't treat it (A::bar) as an Implicit Member Call Expression. P.S. I wonder if there is an existing bug report related to this? (Surprisingly, a cursory search did not find one). llvm-svn: 311839
* [NFC] Remove a cstyle cast and replace some uses of Decl with NamedDecl ↵Faisal Vali2017-08-251-2/+2
| | | | | | during the processing of TemplateParameterLists. llvm-svn: 311788
* [ObjC] Add a -Wobjc-messaging-id warningAlex Lorenz2017-08-251-0/+3
| | | | | | | | | | | | -Wobjc-messaging-id is a new, non-default warning that warns about message sends to unqualified id in Objective-C. This warning is useful for projects that would like to avoid any potential future compiler errors/warnings, as the system frameworks might add a method with the same selector which could make the message send to id ambiguous. rdar://33303354 llvm-svn: 311779
* [OPENMP] Fix for PR34321: ustom OpenMP reduction in C++ template causesAlexey Bataev2017-08-251-1/+2
| | | | | | | | | SEGFAULT at compile time Compiler crashed when tried to rebuild non-template expression in dependent context. llvm-svn: 311777
* [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric ↵Gor Nishanov2017-08-251-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | control transfer) Summary: If await_suspend returns a coroutine_handle, as in the example below: ``` coroutine_handle<> await_suspend(coroutine_handle<> h) { coro.promise().waiter = h; return coro; } ``` suspensionExpression processing will resume the coroutine pointed at by that handle. Related LLVM change rL311751 makes resume calls of this kind `musttail` at any optimization level. This enables unlimited symmetric control transfer from coroutine to coroutine without blowing up the stack. Reviewers: GorNishanov Reviewed By: GorNishanov Subscribers: rsmith, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D37131 llvm-svn: 311762
* [c++2a] P0704R1: Allow pointers to const& member functions to be called on ↵Richard Smith2017-08-251-3/+10
| | | | | | | | rvalues. Patch by Blitz Rakete! llvm-svn: 311744
* Fix typos, remove unused private members of CommonOptionsParser, NFCJohannes Altmanninger2017-08-231-1/+1
| | | | llvm-svn: 311544
* [OPENMP] Fix for PR34014: OpenMP 4.5: Target construct in static methodAlexey Bataev2017-08-221-0/+1
| | | | | | | | | | of class fails to map class static variable. If the global variable is captured and it has several redeclarations, sometimes it may lead to a compiler crash. Patch fixes this by working only with canonical declarations. llvm-svn: 311479
* [ObjC] Check written attributes only when synthesizing ambiguous propertyAlex Lorenz2017-08-221-2/+2
| | | | | | | | | | | | | | | | | This commit fixes a bug introduced in r307903. The attribute ambiguity checker that was introduced in r307903 checked all property attributes, which caused errors for source-compatible properties, like: @property (nonatomic, readonly) NSObject *prop; @property (nonatomic, readwrite) NSObject *prop; because the readwrite property would get implicit 'strong' attribute. The ambiguity checker should be concerned about explicitly specified attributes only. rdar://33748089 llvm-svn: 311443
* [c++2a] Implement P0409R2 - Allow lambda capture [=,this] (by hamzasood)Faisal Vali2017-08-191-11/+9
| | | | | | | | | | This patch, by hamzasood, implements P0409R2, and allows [=, this] pre-C++2a as an extension (with appropriate warnings) for consistency. https://reviews.llvm.org/D36572 Thanks Hamza! llvm-svn: 311224
* [Sema] Don't emit -Wunguarded-availability for switch casesErik Pilkington2017-08-181-0/+4
| | | | | | | | | This made it awkward to switch over an enum where some entries are partial and is unlikley to catch any bugs. Differential revision: https://reviews.llvm.org/D36777 llvm-svn: 311191
* Unguarded availability diagnoser should use TraverseStmt instead ofAlex Lorenz2017-08-171-2/+1
| | | | | | | | | Base::TraverseStmt when visiting the then/else branches of if statements This ensures that the statement stack is correctly tracked and correct multi-statement fixit is generated inside of an if (@available) llvm-svn: 311088
* Fix typos in comments; NFCGeorge Burgess IV2017-08-161-1/+1
| | | | llvm-svn: 311051
* PR19668, PR23034: Fix handling of move constructors and deleted copyRichard Smith2017-08-161-3/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | constructors when deciding whether classes should be passed indirectly. This fixes ABI differences between Clang and GCC: * Previously, Clang ignored the move constructor when making this determination. It now takes the move constructor into account, per https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may seem recent, but the ABI change was agreed on the Itanium C++ ABI list a long time ago). * Previously, Clang's behavior when the copy constructor was deleted was unstable -- depending on whether the lazy declaration of the copy constructor had been triggered, you might get different behavior. We now eagerly declare the copy constructor whenever its deletedness is unclear, and ignore deleted copy/move constructors when looking for a trivial such constructor. This also fixes an ABI difference between Clang and MSVC: * If the copy constructor would be implicitly deleted (but has not been lazily declared yet), for instance because the class has an rvalue reference member, we would pass it directly. We now pass such a class indirectly, matching MSVC. Based on a patch by Vassil Vassilev, which was based on a patch by Bernd Schmidt, which was based on a patch by Reid Kleckner! This is a re-commit of r310401, which was reverted in r310464 due to ARM failures (which should now be fixed). llvm-svn: 310983
* Do not look through pack expansions when looking for unexpanded parameter packs.Richard Smith2017-08-151-18/+64
| | | | | | | Fixes a selection of rejects-valids when pack-expanding a lambda that itself contains a pack expansion. llvm-svn: 310972
* Allow the target field of a CK_ToUnion to be more easily recovered.John McCall2017-08-151-13/+6
| | | | llvm-svn: 310963
* PR33082: Improve tracking of unexpanded parameter packs within variadic ↵Richard Smith2017-08-151-39/+87
| | | | | | generic lambdas. llvm-svn: 310946
* [OpenCL] Support variable memory scope in atomic builtinsYaxun Liu2017-08-151-26/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D36580 llvm-svn: 310924
* [Sema] Silence -Wobjc-missing-property-synthesis for unavailable propertiesAlex Lorenz2017-08-151-1/+1
| | | | | | rdar://30296911 llvm-svn: 310916
* [Sema] Improve some -Wunguarded-availability diagnosticsErik Pilkington2017-08-141-75/+78
| | | | | | | rdar://33543523 Differential revision: https://reviews.llvm.org/D36200 llvm-svn: 310874
* Set the lexical context for dummy tag decl inside createTagFromNewDeclAlex Lorenz2017-08-141-1/+1
| | | | | | | This is a follow-up to r310706. This change has been recommended by Bruno Cardoso Lopes and Richard Smith. llvm-svn: 310829
* Rename cxx1z -> cxx17 across all diagnostic IDs.Richard Smith2017-08-134-5/+5
| | | | llvm-svn: 310805
* PR34163: Don't cache an incorrect key function for a class if queried betweenRichard Smith2017-08-122-2/+5
| | | | | | | | | | | the class becoming complete and its inline methods being parsed. This replaces the hack of using the "late parsed template" flag to track member functions with bodies we've not parsed yet; instead we now use the "will have body" flag, which carries the desired implication that the function declaration *is* a definition, and that we've just not parsed its body yet. llvm-svn: 310776
* [modules] Set the lexical DC for dummy tag decls that refer to hiddenAlex Lorenz2017-08-111-0/+1
| | | | | | | | | | | | | | declarations that are made visible after the dummy is parsed and ODR verified Prior to this commit the "(getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one.")," assertion failure was triggered during semantic analysis of the dummy tag declaration that was declared in another tag declaration because its lexical context did not point to the outer tag decl. rdar://32292196 llvm-svn: 310706
* Revert "Thread Safety Analysis: warn on nonsensical attributes."Josh Gao2017-08-111-46/+11
| | | | | | | This reverts commit rL310403, which caused spurious warnings in libc++, because it didn't properly handle templated scoped lockable types. llvm-svn: 310698
* [Sema][ObjC] Fix spurious -Wcast-qual warnings.Akira Hatanaka2017-08-111-1/+8
| | | | | | | | | | We do not meaningfully track object const-ness of Objective-C object types. Silence the -Wcast-qual warning that is issued when casting to or from Objective-C object types results in losing const qualification. rdar://problem/33807915 llvm-svn: 310672
* [X86] Implement __builtin_cpu_isCraig Topper2017-08-101-0/+23
| | | | | | | | This patch adds support for __builtin_cpu_is. I've tried to match the strings supported to the latest version of gcc. Differential Revision: https://reviews.llvm.org/D35449 llvm-svn: 310657
* Place implictly declared functions at block scopeMomchil Velikov2017-08-101-2/+6
| | | | | | | | | | | | Such implicitly declared functions behave as if the enclosing block contained the declaration extern int name() (C90, 6.3.3.2 Function calls), thus their names should have block scope (C90, 6.1.2.1 Scope of identifiers). This patch fixes https://bugs.llvm.org/show_bug.cgi?id=33224 Differential Revision: https://reviews.llvm.org/D33676 llvm-svn: 310616
* [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of ↵Gabor Horvath2017-08-091-1/+1
| | | | | | | | | | -Wenum-compare Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D36526 llvm-svn: 310521
* Fix broken getAttributeSpellingListIndex for pragma attributesErich Keane2017-08-091-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We noticed when implementing a new pragma that the TableGen-generated function getAttributeSpellingListIndex() did not work for pragma attributes. It relies on the values in the enum AttributeList::Syntax and a new value AS_ContextSensitiveKeyword was added changing the value for AS_Pragma. Apparently no tests failed since no pragmas currently make use of the generated function. To fix this we can move AS_Pragma back to the value that TableGen code expects. Also to prevent changes in the enum from breaking that routine again I added calls to getAttributeSpellingListIndex() in the unroll pragma code. That will cause some lit test failures if the order is changed. I added a comment to remind of this issue in the future. This assumes we don’t need/want full TableGen support for AS_ContextSensitiveKeyword. It currently only appears in getAttrKind and no other TableGen-generated routines. Patch by: mikerice Differential Revision: https://reviews.llvm.org/D36473 llvm-svn: 310483
* Reapply Sema: allow imaginary constants via GNU extension if UDL overloads ↵Tim Northover2017-08-092-14/+27
| | | | | | | | | | | | | | | | | | not present. C++14 added user-defined literal support for complex numbers so that you can write something like "complex<double> val = 2i". However, there is an existing GNU extension supporting this syntax and interpreting the result as a _Complex type. This changes parsing so that such literals are interpreted in terms of C++14's operators if an overload is present but otherwise falls back to the original GNU extension. (We now have more robust diagnostics for implicit conversions so the libc++ test that caused the original revert still passes). llvm-svn: 310478
* [OpenCL] Minor refactoring to reduce copy/pasted codeJoey Gouly2017-08-091-8/+5
| | | | | | | Set the type of TheCall inside SemaBuiltinReserveRWPipe to reduce duplicated code. llvm-svn: 310477
* [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class ↵Coby Tayree2017-08-091-8/+19
| | | | | | | | | | | pointers aliases MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct pointer typedef. This patch enhance its implementation with this behavior. Differential Revision: https://reviews.llvm.org/D36450 llvm-svn: 310472
* [Sema] -Wenum-compare no longer warn on anonymous enums in switch statementsGabor Horvath2017-08-091-0/+6
| | | | | | Patch by: Reka Nikolett Kovacs llvm-svn: 310468
* Revert "PR19668, PR23034: Fix handling of move constructors and deleted copy ↵Diana Picus2017-08-091-53/+3
| | | | | | | | | constructors when deciding whether classes should be passed indirectly." This reverts commit r310401 because it seems to have broken some ARM bot(s). llvm-svn: 310464
* [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch ↵Gabor Horvath2017-08-091-8/+28
| | | | | | | | | | statements Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D36407 llvm-svn: 310449
* Allow operator delete to be an invalid Decl.Richard Trieu2017-08-091-3/+0
| | | | | | | | Do not discard invalid Decl when searching for the operator delete function. The lookup for this function always expects to find a result, so sometimes the invalid Decl is the only choice possible. This fixes PR34109. llvm-svn: 310435
* Sema: disable implicit conversion from _Complex to real types in C++.Tim Northover2017-08-082-2/+11
| | | | | | | | | | | Converting a _Complex type to a real one simply discards the imaginary part. This can easily lead to loss of information so for safety (and GCC compatibility) this patch disallows that when the conversion would be implicit. The one exception is bool, which actually compares both real and imaginary parts and so is safe. llvm-svn: 310427
* Thread Safety Analysis: warn on nonsensical attributes.Josh Gao2017-08-081-11/+46
| | | | | | | | | | | | | Add warnings in cases where an implicit `this` argument is expected to attributes because either `this` doesn't exist because the attribute is on a free function, or because `this` is on a type that doesn't have a corresponding capability/lockable/scoped_lockable attribute. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310403
* Reland "Thread Safety Analysis: fix assert_capability."Josh Gao2017-08-081-1/+5
| | | | | | | | | | | Delete the test that was broken by rL309725, and add it back in a follow up commit. Also, improve the tests a bit. Reviewers: delesley, aaron.ballman Differential Revision: https://reviews.llvm.org/D36237 llvm-svn: 310402
OpenPOWER on IntegriCloud