summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Remove extra code transformation.Alexey Bataev2016-03-291-282/+184
| | | | | | | | | For better support of some specific GNU extensions some extra transformation of AST nodes were introduced. These transformations are very hard to handle. The code is improved in handling of these extensions by using captured expressions construct. llvm-svn: 264709
* P0138R2: Allow direct-list-initialization of an enumeration from an integralRichard Smith2016-03-282-15/+64
| | | | | | value that can convert to the enum's underlying type. llvm-svn: 264564
* Fix serialization/deserialization for __uuidofDavid Majnemer2016-03-281-7/+9
| | | | | | | | I broke this back in r264529 because I forgot to serialize the UuidAttr member. Fix this by replacing the UuidAttr with a StringRef which is properly serialized and deserialized. llvm-svn: 264562
* Improve the representation of CXXUuidofExprDavid Majnemer2016-03-271-16/+55
| | | | | | | | Keep a pointer to the UuidAttr that the CXXUuidofExpr corresponds to. This makes translating from __uuidof to the underlying constant a lot more straightforward. llvm-svn: 264529
* [NFC] Tweak diagnostic for template template arguments, to include template ↵Faisal Vali2016-03-261-2/+2
| | | | | | | | aliases. The prior diagnostic (err_template_arg_not_class_template) would state that the template argument to a template template parameter can only be a class template, when it can also be a template alias. The newly renamed diagnostic (err_template_arg_not_valid_template) mentions template aliases. llvm-svn: 264522
* [Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier ↵Faisal Vali2016-03-262-5/+20
| | | | | | | | | | | | | | | | | | | | | | (and its inference) on lambda expressions Support the constexpr specifier on lambda expressions - and support its inference from the lambda call operator's body. i.e. auto L = [] () constexpr { return 5; }; static_assert(L() == 5); // OK auto Implicit = [] (auto a) { return a; }; static_assert(Implicit(5) == 5); We do not support evaluation of lambda's within constant expressions just yet. Implementation Strategy: - teach ParseLambdaExpressionAfterIntroducer to expect a constexpr specifier and mark the invented function call operator's declarator's decl-specifier with it; Have it emit fixits for multiple decl-specifiers (mutable or constexpr) in this location. - for cases where constexpr is not explicitly specified, have buildLambdaExpr check whether the invented function call operator satisfies the requirements of a constexpr function, by calling CheckConstexprFunctionDecl/Body. Much obliged to Richard Smith for his patience and his care, in ensuring the code is clang-worthy. llvm-svn: 264513
* Don't warn on "use" of undefined inline function that isn't actually an ODRRichard Smith2016-03-251-15/+16
| | | | | | | | use. In order for this to fire, the function needed to be a templated function marked 'constexpr' and declared but not defined. This weird pattern appears in libstdc++'s alloc_traits.h. llvm-svn: 264471
* Store list of undefined-but-used objects in a deterministic order to fixRichard Smith2016-03-252-28/+13
| | | | | | | | non-deterministic diagnostics (and non-deterministic PCH files). Check these when building a module rather than serializing it; it's not reasonable for a module's use to be satisfied by a definition in the user of the module. llvm-svn: 264466
* Fix nondeterminism in computation of builtin operator overload sets.Richard Smith2016-03-251-3/+4
| | | | llvm-svn: 264363
* Change ADL to produce lookup results in a deterministic order. This fixes someRichard Smith2016-03-241-2/+2
| | | | | | | rare issues with nondeterministic diagnostic order, and some very common issues with nondeterministic module builds. llvm-svn: 264323
* ObjC: add getter/setter for class properties to global pool.Manman Ren2016-03-231-0/+5
| | | | | | rdar://problem/25323072 llvm-svn: 264196
* Make SemaAccess smarter about determining when a dependent class mightRichard Smith2016-03-231-10/+5
| | | | | | | instantiate to match a friend class declaration. It's still pretty dumb, though. llvm-svn: 264189
* Make sure to perform dependent access checks when instantiating aRichard Smith2016-03-232-12/+12
| | | | | | | | lambda-expression. We don't actually instantiate the closure type / operator() in the template in order to produce the closure type / operator() in the instantiation, so this isn't caught by the normal path. llvm-svn: 264184
* [NFC] Delete an unused function parameter from a static function Faisal Vali2016-03-231-3/+2
| | | | llvm-svn: 264170
* ObjC: Handle boolean fixed type for enum.Manman Ren2016-03-231-1/+4
| | | | | | | | | | | | | Before this commit, we assert failure in ImplicitCastExpr "unheralded conversion to bool". This commit fixes the assertion by using the correct cast type when the fixed type is boolean. This commit also fixes the behavior for Microsoft mode as well, since Obj-C and Microsoft mode share the same code path. rdar://24999533 llvm-svn: 264167
* Use an enum instead of hardcoded indices. NFC.Alexander Kornienko2016-03-231-7/+11
| | | | llvm-svn: 264158
* [Sema] Allow implicit conversions of &overloaded_fn in C.George Burgess IV2016-03-231-11/+20
| | | | | | | | | | | | | | | | | | | | | | | Also includes a minor ``enable_if`` docs update. Currently, our address-of overload machinery will only allow implicit conversions of overloaded functions to void* in C. For example: ``` void f(int) __attribute__((overloadable)); void f(double) __attribute__((overloadable, enable_if(0, ""))); void *fp = f; // OK. This is C and the target is void*. void (*fp2)(void) = f; // Error. This is C, but the target isn't void*. ``` This patch makes the assignment of `fp2` select the `f(int)` overload, rather than emitting an error (N.B. you'll still get a warning about the `fp2` assignment if you use -Wincompatible-pointer-types). Differential Revision: http://reviews.llvm.org/D13704 llvm-svn: 264132
* [CUDA] Don't allow templated variadic functions.Justin Lebar2016-03-221-22/+22
| | | | | | | | | | Reviewers: tra Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18373 llvm-svn: 264106
* [MS ABI] Assign an inheritance model for the dest of a member pointer upcastDavid Majnemer2016-03-221-1/+3
| | | | | | | | | While we correctly assigned an inheritance model for the source of a member pointer upcast, we did not do so for the destination. This fixes PR27030. llvm-svn: 264065
* [Objective-c] Do not set IsExact to true when the receiver is a class.Akira Hatanaka2016-03-221-3/+1
| | | | | | | | | | | | IsExact shouldn't be set to true in WeakObjectProfileTy::getBaseInfo when the receiver is a class because having a class as the receiver doesn't guarantee that the Base is exact. This is a follow-up to r263818. rdar://problem/25208167 llvm-svn: 264025
* [sema] [CUDA] Use std algorithms in EraseUnwantedCUDAMatchesImpl.Justin Lebar2016-03-221-17/+14
| | | | | | | | | | | | Summary: NFC Reviewers: tra Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18327 llvm-svn: 264008
* Add replacement = "xxx" to AvailabilityAttr.Manman Ren2016-03-212-3/+14
| | | | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This was commited in r263687 and reverted in 263752 due to misaligned access. rdar://20588929 llvm-svn: 263958
* [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)Faisal Vali2016-03-215-38/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement lambda capture of *this by copy. For e.g.: struct A { int d = 10; auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; } }; auto L = A{}.foo(); // A{}'s lifetime is gone. // Below is still ok, because *this was captured by value. assert(L(10) == 20); assert(L(100) == 120); If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined. Implementation Strategy: - amend the parser to accept *this in the lambda introducer - add a new king of capture LCK_StarThis - teach Sema::CheckCXXThisCapture to handle by copy captures of the enclosing object (i.e. *this) - when CheckCXXThisCapture does capture by copy, the corresponding initializer expression for the closure's data member direct-initializes it thus making a copy of '*this'. - in codegen, when assigning to CXXThisValue, if *this was captured by copy, make sure it points to the corresponding field member, and not, unlike when captured by reference, what the field member points to. - mark feature as implemented in svn Much gratitude to Richard Smith for his carefully illuminating reviews! llvm-svn: 263921
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-202-22/+32
| | | | | | loops to differ. llvm-svn: 263895
* [Sema] Make type deduction work with some overloadable functionsGeorge Burgess IV2016-03-191-0/+5
| | | | | | | | | | | Some functions can't have their address taken. If we encounter an overload set where only one of the candidates can have its address taken, we should automatically select that candidate's type in type deduction. Differential Revision: http://reviews.llvm.org/D15591 llvm-svn: 263888
* [Sema] Allow casting of some overloaded functionsGeorge Burgess IV2016-03-192-14/+82
| | | | | | | | | | | Some functions can't have their address taken. If we encounter an overload set where only one of the candidates can have its address taken, we should automatically select that candidate in cast expressions. Differential Revision: http://reviews.llvm.org/D17701 llvm-svn: 263887
* [OPENMP] Implementation of codegen for firstprivate clause of target directiveCarlo Bertolli2016-03-181-0/+41
| | | | | | | | | | | | | | | This patch implements the following aspects: It extends sema to check that a variable is not reference in both a map clause and firstprivate or private. This is needed to ensure correct functioning at codegen level, apart from being useful for the user. It implements firstprivate for target in codegen. The implementation applies to both host and nvptx devices. It adds regression tests for codegen of firstprivate, host and device side when using the host as device, and nvptx side. Please note that the regression test for nvptx codegen is missing VLAs. This is because VLAs currently require saving and restoring the stack which appears not to be a supported operation by nvptx backend. It adds a check in sema regression tests for target map, firstprivate, and private clauses. http://reviews.llvm.org/D18203 llvm-svn: 263837
* [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo.Akira Hatanaka2016-03-181-5/+9
| | | | | | | | | | | | | The crash occurs in WeakObjectProfileTy::getBaseInfo when getBase() is called on an ObjCPropertyRefExpr object whose receiver is an interface. This commit fixes the crash by checking the type of the receiver and setting IsExact to true if it is an interface. rdar://problem/25208167 Differential Revision: http://reviews.llvm.org/D18268 llvm-svn: 263818
* Revert r263687 for ubsan bot failure.Manman Ren2016-03-172-14/+3
| | | | llvm-svn: 263752
* Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner2016-03-171-2/+2
| | | | | | | | | This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
* For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner2016-03-171-2/+2
| | | | | | | | | | | | Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
* [OPENMP 4.5] Allow to use private data members in 'copyprivate' clause.Alexey Bataev2016-03-171-43/+31
| | | | | | | | OpenMP 4.5 allows privatization of non-static data members in non-static member functions. This patch adds support of private data members in 'copyprivate' clauses. llvm-svn: 263706
* [OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.Alexey Bataev2016-03-172-181/+388
| | | | | | | | OpenMP 4.0 allows to define custom reduction operations using '#pragma omp declare reduction' construct. Patch allows to use this custom defined reduction operations in 'reduction' clauses. llvm-svn: 263701
* Add an optional named argument (replacement = "xxx") to AvailabilityAttr.Manman Ren2016-03-172-3/+14
| | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This enables the compiler to provide Fix-Its for deprecated declarations. rdar://20588929 llvm-svn: 263687
* Add an optional string argument to DeprecatedAttr for Fix-It.Manman Ren2016-03-161-4/+36
| | | | | | | | We only add this to __attribute__((deprecated)). Differential Revision: http://reviews.llvm.org/D17865 llvm-svn: 263652
* Add attributes for preserve_mostcc/preserve_allcc calling conventions to the ↵Roman Levenstein2016-03-162-2/+23
| | | | | | | | | | | | | | | C/C++ front-end Till now, preserve_mostcc/preserve_allcc calling convention attributes were only available at the LLVM IR level. This patch adds attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end. The code was mostly written by Juergen Ributzka. I just added support for the AArch64 target and tests. Differential Revision: http://reviews.llvm.org/D18025 llvm-svn: 263647
* Fix destructor definition of invalid classesOlivier Goffart2016-03-161-8/+10
| | | | | | | | | | | | The declaration of the destructor of an invalid class was not properly marked as noexcept. As a result, the definition of the same destructor, which was properly implicitly marked as noexcept, would not match the definition. This would cause the definition CXXDestructorDecl to be matked as invalid and omited from the AST. Differential Revision: http://reviews.llvm.org/D17988 llvm-svn: 263639
* Avoid using LookupResult's implicit copy ctor and assignment operator to ↵Marina Yatsina2016-03-161-11/+9
| | | | | | | | | | | | | avoid warnings The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed. This patch is meant to help the following review: http://reviews.llvm.org/D18123. The functionality is covered by the tests in my original commit (255890) The test case in this patch was added to test a bug caught in the review of the first version of this fix. Differential Revision: http://reviews.llvm.org/D18175 llvm-svn: 263630
* Move the fixit for -Wformat-security to a note.Bob Wilson2016-03-151-5/+6
| | | | | | | | r263299 added a fixit for the -Wformat-security warning, but that runs into complications with our guideline that error recovery should be done as-if the fixit had been applied. Putting the fixit on a note avoids that. llvm-svn: 263584
* Add fix-it for format-security warnings.Bob Wilson2016-03-111-9/+21
| | | | llvm-svn: 263299
* Allow sizeof(UnrelatedClass::field) in C++11 class template methodsReid Kleckner2016-03-111-3/+16
| | | | | | | | | | | | | | | | | This feature works outside of templates by forming a DeclRefExpr to a FieldDecl instead of a MemberExpr, which requires a base object in addition to the FieldDecl. Previously, while building up the template AST before instantiation, we formed a CXXDependentScopeMemberExpr, which always instantiates to a MemberExpr. Now, in unevaluated contexts we form a DependentScopeDeclRefExpr, which is a more flexible node that can instantiate to either a MemberExpr or a DeclRefExpr depending on lookup results. Fixes PR26893. llvm-svn: 263279
* [OpenMP] NFC fix compilation warning about unused variableDmitry Polukhin2016-03-111-2/+1
| | | | | | lib/Sema/SemaOpenMP.cpp:9243:13: warning: variable ‘IsRightMostExpression’ set but not used llvm-svn: 263202
* Add TreatUnavailableAsInvalid for the verification-only mode in InitListChecker.Manman Ren2016-03-103-33/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given the following test case: typedef struct { const char *name; id field; } Test9; extern void doSomething(Test9 arg); void test9() { Test9 foo2 = {0, 0}; doSomething(foo2); } With a release compiler, we don't emit any message and silently ignore the variable "foo2". With an assert compiler, we get an assertion failure. The root cause ————————————— Back in r140457 we gave InitListChecker a verification-only mode, and will use CanUseDecl instead of DiagnoseUseOfDecl for verification-only mode. These two functions handle unavailable issues differently: In Sema::CanUseDecl, we say the decl is invalid when the Decl is unavailable and the current context is available. In Sema::DiagnoseUseOfDecl, we say the decl is usable by ignoring the return code of DiagnoseAvailabilityOfDecl So with an assert build, we will hit an assertion in diagnoseListInit assert(DiagnoseInitList.HadError() && "Inconsistent init list check result."); The fix ------------------- If we follow what is implemented in CanUseDecl and treat Decls with unavailable issues as invalid, the variable decl of “foo2” will be marked as invalid. Since unavailable checking is processed in delayed diagnostics (r197627), we will silently ignore the diagnostics when we find out that the variable decl is invalid. We add a flag "TreatUnavailableAsInvalid" for the verification-only mode. For overload resolution, we want to say decls with unavailable issues are invalid; but for everything else, we should say they are valid and emit diagnostics. Depending on the value of the flag, CanUseDecl can return different values for unavailable issues. rdar://23557300 Differential Revision: http://reviews.llvm.org/D15314 llvm-svn: 263149
* Fix false positives for for-loop-analysis warningSteven Wu2016-03-101-0/+12
| | | | | | | | | | | | | | | Summary: For PseudoObjectExpr, the DeclMatcher need to search only all the semantics but also need to search pass OpaqueValueExpr for all potential uses for the Decl. Reviewers: thakis, rtrieu, rjmccall, doug.gregor Subscribers: xazax.hun, rjmccall, doug.gregor, cfe-commits Differential Revision: http://reviews.llvm.org/D17627 llvm-svn: 263087
* Implement support for [[maybe_unused]] in C++1z that is based off existing ↵Aaron Ballman2016-03-093-6/+33
| | | | | | support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects. llvm-svn: 263025
* [OpenMP] Add support for multidimensional array sections in map clause SEMA.Samuel Antao2016-03-091-23/+144
| | | | | | | | | | | | Summary: In some cases it can be proved statically that multidimensional array section refer to contiguous storage and can therefore be allowed in a map clause. This patch adds support for those cases in SEMA. Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev Subscribers: cfe-commits, fraggamuffin, caomhin Differential Revision: http://reviews.llvm.org/D17547 llvm-svn: 263019
* [GCC] PR23529 Sema part of attrbute abi_tag supportDmitry Polukhin2016-03-092-0/+57
| | | | | | | | | | | | | | | | | Original patch by Stefan Bühler http://reviews.llvm.org/D12834 Difference between original and this one: - fixed all comments in original code review - added more tests, all new diagnostics now covered by tests - moved abi_tag on re-declaration checks to Sema::mergeDeclAttributes where they actually may work as designed - clang-format + other stylistic changes Mangle part will be sent for review as a separate patch. Differential Revision: http://reviews.llvm.org/D17567 llvm-svn: 263015
* [OPENMP 4.5] Codegen for data members in 'linear' clause.Alexey Bataev2016-03-091-6/+43
| | | | | | | OpenMP 4.5 allows to use data members in private clauses. Patch adds codegen support for 'linear' clause. llvm-svn: 263002
* Fix crash in access check for aggregate initialization of base classes. It'sRichard Smith2016-03-081-1/+5
| | | | | | | not obvious how to access-check these, so pick a conservative rule until we get feedback from CWG. llvm-svn: 262966
* P0017R1: In C++1z, an aggregate class can have (public non-virtual) base ↵Richard Smith2016-03-081-25/+106
| | | | | | classes; these are initialized as if they were data members. llvm-svn: 262963
OpenPOWER on IntegriCloud