summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Add a warning for direct-list-initialization of a variable with a deduced typeRichard Smith2015-02-111-0/+8
| | | | | | | | (or of a lambda init-capture, which is sort-of such a variable). The semantics of such constructs will change when we implement N3922, so we intend to warn on this in Clang 3.6 then change the semantics in Clang 3.7. llvm-svn: 228792
* PR21857: weaken an incorrect assertion.Richard Smith2015-02-111-2/+12
| | | | llvm-svn: 228785
* [modules] When determining whether a name from a module replaces a name weRichard Smith2015-02-101-0/+5
| | | | | | | | | already have, check whether the name from the module is actually newer than the existing declaration. If it isn't, we might (say) replace a visible declaration with an injected friend, and thus make it invisible (or lose a default argument or an array bound). llvm-svn: 228661
* A temporary fix for backward compatibility breakages caused by PR12117.Larisse Voufo2015-02-101-4/+15
| | | | llvm-svn: 228654
* Sema: Don't give attribute alias vars with struct type an init exprDavid Majnemer2015-02-081-0/+2
| | | | | | | | | | We'd give the VarDecl a CXXConstructExpr even though it is annotated with an alias attribute. This would make us trip over sanity checking asserts. This fixes PR22493. llvm-svn: 228523
* Revert "OpenCL: handle shift operator with vector operands"Tom Stellard2015-02-061-65/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r228382. This breaks the following case: Reported by Jeroen Ketema: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150202/122961.html typedef __attribute__((ext_vector_type(3))) char char3; void foo() { char3 v = {1,1,1}; char3 w = {1,2,3}; w <<= v; } If I compile with: clang -x cl file.c Then an error is produced: file.c:10:5: error: expression is not assignable w <<= v; ~ ^ 1 error generated. llvm-svn: 228406
* Update APIs that return a pair of iterators to return an iterator_range instead.Benjamin Kramer2015-02-064-65/+30
| | | | | | Convert uses of those APIs into ranged for loops. NFC. llvm-svn: 228404
* OpenCL: handle shift operator with vector operandsSameer Sahasrabuddhe2015-02-061-1/+65
| | | | | | | | | | | | | | | | | | | | Introduce a number of checks: 1. If LHS is a scalar, then RHS cannot be a vector. 2. Operands must be of integer type. 3. If both are vectors, then the number of elements must match. Relax the requirement for "usual arithmetic conversions": When LHS is a vector, a scalar RHS can simply be expanded into a vector; OpenCL does not require that its rank be lower than the LHS. For example, the following code is not an error even if the implicit type of the constant literal is "int". char2 foo(char2 v) { return v << 1; } Consolidate existing tests under CodeGenOpenCL, and add more tests under SemaOpenCL. llvm-svn: 228382
* Fix \param in r228276. [-Wdocumentation]NAKAMURA Takumi2015-02-051-1/+1
| | | | llvm-svn: 228355
* Re-land r228258 and make clang-cl's /EHs- disable -fexceptions againReid Kleckner2015-02-051-9/+24
| | | | | | | | | | | After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready to deal with, even when exceptions were disabled with /EHs-. This time, make /EHs- turn off -fexceptions while still emitting exceptional constructs in functions using __try. Since Sema rejects C++ exception handling constructs before CodeGen, landingpads should only appear in such functions as the result of a __try. llvm-svn: 228329
* PR22465: when performing list-initialization for a class type C, if we see anRichard Smith2015-02-051-16/+19
| | | | | | | | | | initializer of the form {x}, where x is of type C or a type derived from C, perform *non-list* initialization of the entity from x, but create a CXXConstructExpr that knows that we used list-initialization syntax. Plus some fixes to ensure we mangle correctly in this and related cases. llvm-svn: 228276
* Various fixes to mangling of list-initialization.Richard Smith2015-02-052-2/+12
| | | | llvm-svn: 228274
* Revert r228258.Nico Weber2015-02-051-24/+9
| | | | | | | | | It caused a chromium base unittest that tests throwing and catching SEH exceptions to fail (http://crbug.com/455488) and I suspect it might also be the cause of the chromium clang win 64-bit shared release builder timing out during compiles. So revert to see if that's true. llvm-svn: 228262
* Sema: Add support for __declspec(restrict)David Majnemer2015-02-042-17/+17
| | | | | | | | | | __declspec(restrict) and __attribute(malloc) are both handled identically by clang: they are allowed to the noalias LLVM attribute. Seeing as how noalias models the C99 notion of 'restrict', rename the internal clang attribute to Restrict from Malloc. llvm-svn: 228120
* OpenCL: handle ternary operator when the condition is a vectorSameer Sahasrabuddhe2015-02-041-42/+194
| | | | | | | | | | When the condition is a vector, OpenCL specifies additional requirements on the operand types, and also the operations required to determine the result type of the operator. This is a combination of OpenCL v1.1 s6.3.i and s6.11.6, and the semantics remain unchanged in later versions of OpenCL. llvm-svn: 228118
* [MSVC2012] Allow 'mutable' referencesAlexey Bataev2015-02-041-3/+6
| | | | | | | | Some standard header files from MSVC2012 use 'mutable' on references, though it is directly prohibited by the standard. Fix for http://llvm.org/PR22444 Differential Revision: http://reviews.llvm.org/D7370 llvm-svn: 228113
* Generalize r228066 to give all implicit global allocation functions default ↵Larisse Voufo2015-02-041-0/+4
| | | | | | visibility. llvm-svn: 228107
* [inlineasm] Fix an incorrect warning about register constraint and modifier.Akira Hatanaka2015-02-041-23/+13
| | | | | | | | | | | | | | | Previously, when the following piece of code was compiled, clang would incorrectly warn that the size of "wide_two" does not match register size specified by the constraint and modifier": long wide_two = two; asm ("%w0 %1" : "+r" (one), "+r"(wide_two)); This was caused by a miscalculation of ConstraintIdx in Sema::ActOnGCCAsmStmt. This commit fixes PR21270 and rdar://problem/18668354. llvm-svn: 228089
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-031-5/+8
| | | | llvm-svn: 228063
* SEH: Track users of __try so we can pick a per-func EH personalityReid Kleckner2015-02-031-9/+24
| | | | | | | | | | | | | | | | | | There are four major kinds of declarations that cause code generation: - FunctionDecl (includes CXXMethodDecl etc) - ObjCMethodDecl - BlockDecl - CapturedDecl This patch tracks __try usage on FunctionDecls and diagnoses __try usage in other decls. If someone wants to use __try from ObjC, they can use it from a free function, since the ObjC code will need an ObjC-style EH personality. Eventually we will want to look through CapturedDecls and track SEH usage on the parent FunctionDecl, if present. llvm-svn: 228058
* Diagnose CXX 'this' pointer reference in funcs with naked attrWeiming Zhao2015-02-031-0/+6
| | | | | | | | | Clang asserts for this pointer reference in asms of naked functions. This patch diagnoses if this pointer reference is used. Differential Revision: http://reviews.llvm.org/D7329 llvm-svn: 228052
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-032-3/+22
| | | | | | | | | | These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. This patch also replaces calls to getAttrs() with calls to attrs() throughout ThreadSafety.cpp, which fixes the earlier issue that cause assert failures. llvm-svn: 228051
* Revert "Thread Safety Analysis: add support for before/after annotations on ↵Reid Kleckner2015-02-032-22/+3
| | | | | | | | | mutexes." This reverts r227997, as well as r228009. It does not pass check-clang for me locally on Linux. llvm-svn: 228020
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-032-3/+22
| | | | | | | These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. llvm-svn: 227997
* Implement jump scope SEHmantic analysis.Nico Weber2015-02-031-3/+29
| | | | | | | | | | | | | | | | | | | Thou shall not jump into SEH blocks. Jumping out of SEH __try and __excepts is A-ok. Jumping out of __finally blocks is B-ok (msvc doesn't error about it, but warns that it has undefined behavior). I've checked that clang's behavior with this patch matches msvc's behavior. We don't have the warning on jumping out of a __finally yet, see the FIXME in the test. clang also currently crashes on codegen for a jump out of a __finally block, see PR22414 comment 7. I also added a few tests for the interaction of indirect jumps and SEH blocks. MSVC doesn't support indirect jumps, so there's no way to know if clang behave the same way as msvc here. clang's behavior with this patch does make sense to me, but maybe it could be argued that it should be more permissive (see FIXME in the indirect jump tests -- shout if you have an opinion on this). llvm-svn: 227982
* SEH: Diagnose use of C++ EH and SEH in the same functionReid Kleckner2015-02-022-8/+22
| | | | | | | | This check does not apply when Borland extensions are enabled, as they have a checked in test case indicating that mixed usage of SEH and C++ is supported. llvm-svn: 227876
* The prefix 'Ms-' should be 'MS-'David Majnemer2015-02-022-5/+5
| | | | | | | Clang is otherwise consistent that Microsoft be abbreviated as MS, not Ms. llvm-svn: 227842
* MS ABI: Implement support for 'novtable'David Majnemer2015-02-021-0/+3
| | | | | | | | | | It is common for COM interface classes to be marked as 'novtable' to tell the compiler that constructors and destructors should not reference virtual function tables. This commit implements this feature in clang. llvm-svn: 227796
* Allow objc_bridge(id) to be used on typedefs of [cv] void*.John McCall2015-02-011-0/+16
| | | | | | rdar://19678874 llvm-svn: 227774
* [X86] Add immediate range checking for a couple XOP builtins.Craig Topper2015-01-311-0/+4
| | | | llvm-svn: 227679
* [X86] Add range checking to the immediate arguments of many of the SSE/AVX ↵Craig Topper2015-01-311-6/+26
| | | | | | builtins. llvm-svn: 227674
* Code cleanupNathan Sidwell2015-01-301-7/+4
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Fix OpenCL 1.2 double as an optional core feature behaviourFraser Cormack2015-01-302-2/+6
| | | | | | | | | | | | | | | | | | | | In OpenCL 1.2, using double no longer requires using the pragma cl_khr_fp64, instead a kernel is allowed to use double, but must first have queried clGetDeviceInfo's CL_DEVICE_DOUBLE_FP_CONFIG. Page 197, section 6.1.1 of the OpenCL 1.2 specification has a footnote 23 describing this behaviour. I've also added test cases such that the pragma must be used if targeting OpenCL 1.0 or 1.1, but is ignored in 1.2 and 2.0. Patch by Neil Henning! Reviewers: Pekka Jääskeläinen Differential Revision: http://reviews.llvm.org/D7245 llvm-svn: 227565
* Sema: Disable template instantiation once a fatal error is raisedDavid Majnemer2015-01-301-0/+6
| | | | | | | | | | | | Fatal errors disable all further diagnostics. Continuing to permit template instantiation does nothing but make it take longer for clang to finish with the TU. Instead, halt all further instantiation. Fixed in PR22396. llvm-svn: 227556
* Wrap to 80 cols by removing trailing whitespace. No behavior change.Nico Weber2015-01-301-1/+1
| | | | llvm-svn: 227553
* Weaken an assertion that isn't true for invalid input.Nico Weber2015-01-301-2/+3
| | | | llvm-svn: 227540
* Sema: Turn some applicable functions static. NBC.Francisco Lopes da Silva2015-01-291-9/+10
| | | | llvm-svn: 227418
* CXX [qoi]. Prevent a crash when initializer expression isFariborz Jahanian2015-01-281-0/+2
| | | | | | | invalid when trying to create temporary copy of the invalid initializer. rdar://19109967 llvm-svn: 227378
* PR22367: Don't forget to create a CXXFunctionalCastExpr aroundRichard Smith2015-01-281-6/+9
| | | | | | | | | list-initialization that gets converted to some form other than an InitListExpr. CXXTemporaryObjectExpr is a special case here, because it represents a fused CXXFunctionalCastExpr + CXXConstructExpr. That, in itself, is probably a design error... llvm-svn: 227377
* PR 17456Nathan Sidwell2015-01-281-0/+35
| | | | | | More helpful diagnostic on casts between unrelated class hierarchies. llvm-svn: 227371
* Revert a change from r222797 that is no longer needed and can causeKaelyn Takata2015-01-282-6/+6
| | | | | | | | | | | | | infinite recursion. Also guard against said infinite recursion by adding an assert that will trigger if CorrectDelayedTyposInExpr is called before a previous call to CorrectDelayedTyposInExpr returns (i.e. if the TreeTransform run by CorrectDelayedTyposInExpr calls a sequence of methods that end up calling CorrectDelayedTyposInExpr, as the new test case had done prior to this commit). Fixes PR22292. llvm-svn: 227368
* Remove support for pnaclcall attributeDerek Schuff2015-01-282-12/+0
| | | | | | | | | | | | | | | | | | Summary: It was used for interoperability with PNaCl's calling conventions, but it's no longer needed. Also Remove NaCl*ABIInfo which just existed to delegate to either the portable or native ABIInfo, and remove checkCallingConvention which was now a no-op override. Reviewers: jvoung Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D7206 llvm-svn: 227362
* Improves overload completion result chunks.Francisco Lopes da Silva2015-01-282-50/+117
| | | | | | | | | | | | | | | | | | | | | The code building the code completion string for overloads was providing less detail compared to the one building completion strings for function declarations. There was no information about optionals and no information about what's a parameter and what's a function identifier, everything besides ResultType, CurrentParameter and special characters was classified as Text. This makes code completion strings for overload candidates to follow a pattern very similar, but not identical, to the one in use for function declarations: - return type chunk: ResultType - function identifier chunk: Text - parameter chunks: Placeholder - optional parameter chunks: Optional - current parameter chunk: CurrentParameter llvm-svn: 227309
* Sema: Ensure that __c11_atomic_fetch_add has a pointer to complete typeDavid Majnemer2015-01-281-0/+5
| | | | | | | | Pointer arithmetic is only makes sense if the pointee type is complete. This fixes PR22361. llvm-svn: 227295
* Use the real CXXScopeSpec when setting the correction SourceRange.Kaelyn Takata2015-01-281-1/+1
| | | | | | | | | Otherwise, in the most important case and the only case where SS and TempSS are different (which is when the CXXScopeSpec should be dropped, and TempSS is NULL) the wrong SourceRange will be used in the fixit for the typo correction. Fixes the remaining issue in PR20626. llvm-svn: 227278
* Cleanups, and add some FIXMEs. No functional change.Richard Smith2015-01-271-12/+14
| | | | llvm-svn: 227267
* Fix a think-o in handling ambiguous corrections for a TypoExpr.Kaelyn Takata2015-01-272-5/+26
| | | | | | | | | | | | | | | | | | | | Under certain circumstances, the identifier mentioned in the diagnostic won't match the intended correction even though the replacement expression and the note pointing to the decl are both correct. Basically, the TreeTransform assumes the TypoExpr's Consumer points to the correct TypoCorrection, but the handling of typos that appear to be ambiguous from the point of view of TransformTypoExpr would cause that assumption to be violated by altering the Consumer's correction stream. This fix allows the Consumer's correction stream to be reset to the right TypoCorrection after successfully resolving the percieved ambiguity. Included is a fix to suppress correcting the RHS of an assignment to the LHS of that assignment for non-C++ code, to prevent a regression in test/SemaObjC/provisional-ivar-lookup.m. This fixes PR22297. llvm-svn: 227251
* Implement the remaining portion of DR1467 from r227022. I may have ↵Larisse Voufo2015-01-272-50/+84
| | | | | | overlooked a few things, but this implementation comes straight from the DR resolution itself. llvm-svn: 227224
* Properly handle typos in the conditional of ?: expressions in C.Kaelyn Takata2015-01-272-15/+9
| | | | | | | | | | In particular, remove the OpaqueExpr transformation from r225389 and move the correction of the conditional from CheckConditionalOperands to ActOnConditionalOp before the OpaqueExpr is created. This fixes the typo correction behavior in C code that uses the GNU extension for a binary ?: (without an expression between the "?" and the ":"). llvm-svn: 227220
* DR1902: if overload resolution recurses, and the inner overload resolutionRichard Smith2015-01-271-20/+27
| | | | | | | selects a deleted function, the outer function is still a candidate even though the initialization sequence is "otherwise ill-formed". llvm-svn: 227169
OpenPOWER on IntegriCloud