summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Diagnose references to unbound arrays in function definitionsDavid Majnemer2015-04-091-0/+4
| | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse on reference types while looking for it, causing us to crash in CodeGen instead of rejecting it. llvm-svn: 234528
* [Sema] Correctly recurse when looking for [*] in function definitionsDavid Majnemer2015-04-071-9/+28
| | | | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse while looking for it, causing us to crash in CodeGen instead of rejecting it. This fixes PR23151. llvm-svn: 234363
* [SystemZ] Support transactional execution on zEC12Ulrich Weigand2015-04-011-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The zEC12 provides the transactional-execution facility. This is exposed to users via a set of builtin routines on other compilers. This patch adds clang support to enable those builtins. In partciular, the patch: - enables the transactional-execution feature by default on zEC12 - allows to override presence of that feature via the -mhtm/-mno-htm options - adds a predefined macro __HTM__ if the feature is enabled - adds support for the transactional-execution GCC builtins - adds Sema checking to verify the __builtin_tabort abort code - adds the s390intrin.h header file (for GCC compatibility) - adds s390 sections to the htmintrin.h and htmxlintrin.h header files Since this is first use of target-specific intrinsics on the platform, the patch creates the include/clang/Basic/BuiltinsSystemZ.def file and hooks it up in TargetBuiltins.h and lib/Basic/Targets.cpp. An associated LLVM patch adds the required LLVM IR intrinsics. For reference, the transactional-execution instructions are documented in the z/Architecture Principles of Operation for the zEC12: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/DZ9ZR009.pdf The associated builtins are documented in the GCC manual: http://gcc.gnu.org/onlinedocs/gcc/S_002f390-System-z-Built-in-Functions.html The htmxlintrin.h intrinsics provided for compatibility with the IBM XL compiler are documented in the "z/OS XL C/C++ Programming Guide". llvm-svn: 233804
* [PPC] Move argument range checks for HTM and crypto builtins to SemaKit Barton2015-03-301-0/+27
| | | | | | | | | | | The argument range checks for the HTM and Crypto builtins were implemented in CGBuiltin.cpp, not in Sema. This change moves them to the appropriate location in SemaChecking.cpp. It requires the creation of a new method in the Sema class to do checks for PPC-specific builtins. http://reviews.llvm.org/D8672 llvm-svn: 233586
* -Wdynamic-class-memaccess: Also warn about array types.Nico Weber2015-03-211-0/+2
| | | | | | | It looks like not warning on this was an oversight in the original implementation of this warning. llvm-svn: 232900
* Dedent code for -Wdynamic-class-memaccess warning. No behavior change.Nico Weber2015-03-211-39/+44
| | | | | | | | | | | | The diff looks intimidating, but this just moves the -Wdynamic-class-memaccess code out a scope, protected by a if (PointeeTy == QualType()) continue; check so that it still only runs when it should. llvm-svn: 232899
* MS ABI: Accept calls to an unprototyped declaration of _setjmpDavid Majnemer2015-03-201-0/+5
| | | | | | This fixes PR22961. llvm-svn: 232824
* [clang] Replacing asserts with static_asserts where appropriateGabor Horvath2015-03-161-3/+4
| | | | | | | | | | | | | | Summary: This patch consists of the suggestions of clang-tidy/misc-static-assert check. Reviewers: alexfh Subscribers: dblaikie, xazax.hun, cfe-commits Differential Revision: http://reviews.llvm.org/D8344 Patch by Szabolcs Sipos! llvm-svn: 232367
* -Wempty-body: fix false negative triggered by macrosDmitri Gribenko2015-03-151-1/+1
| | | | | | | | | | | | | When if statement condition ended in a macro: if (ptr == NULL); the check used to consider the definition location of NULL, instead of the current line. Patch by Manasij Mukherjee. llvm-svn: 232295
* MS ABI: Implement __GetExceptionInfo for std::make_exception_ptrDavid Majnemer2015-03-131-0/+13
| | | | | | | | | std::make_exception_ptr calls std::__GetExceptionInfo in order to figure out how to properly copy the exception object. Differential Revision: http://reviews.llvm.org/D8280 llvm-svn: 232188
* [X86, AVX2] Replace inserti128 and extracti128 intrinsics with generic shufflesSanjay Patel2015-03-121-2/+0
| | | | | | | | | | | | This is nearly identical to the v*f128_si256 parts of r231792 and r232052. AVX2 introduced proper integer variants of the hacked integer insert/extract C intrinsics that were created for this same functionality with AVX1. This should complete the front end fixes for insert/extract128 intrinsics. Corresponding LLVM patch to follow. llvm-svn: 232109
* [X86, AVX] replace vextractf128 intrinsics with generic shufflesSanjay Patel2015-03-121-3/+0
| | | | | | | | | | | This is very much like D8088 (checked in at r231792). Now that we've replaced the vinsertf128 intrinsics, do the same for their extract twins. Differential Revision: http://reviews.llvm.org/D8275 llvm-svn: 232052
* Under duress, move check for target support of __builtin_setjmp/Joerg Sonnenberger2015-03-111-1/+20
| | | | | | __builtin_longjmp to Sema as requested by John McCall. llvm-svn: 231986
* [X86, AVX] Replace vinsertf128 intrinsics with generic shuffles.Sanjay Patel2015-03-101-3/+0
| | | | | | | | | | | | | | We want to replace as much custom x86 shuffling via intrinsics as possible because pushing the code down the generic shuffle optimization path allows for better codegen and less complexity in LLVM. This is the sibling patch for the LLVM half of this change: http://reviews.llvm.org/D8086 Differential Revision: http://reviews.llvm.org/D8088 llvm-svn: 231792
* Make helper functions staticBenjamin Kramer2015-03-091-2/+2
| | | | | | NFC. llvm-svn: 231657
* New ObjC warning: circular containers.Alex Denisov2015-03-041-0/+230
| | | | | | | | | | | | | | | | | | | | | This commit adds new warning to prevent user from creating 'circular containers'. Mutable collections from NSFoundation allows user to add collection to itself, e.g.: NSMutableArray *a = [NSMutableArray new]; [a addObject:a]; The code above leads to really weird behaviour (crashes, 'endless' recursion) and retain cycles (collection retains itself) if ARC enabled. Patch checks the following collections: - NSMutableArray, - NSMutableDictionary, - NSMutableSet, - NSMutableOrderedSet, - NSCountedSet. llvm-svn: 231265
* Move one more diagnostic into the new -Wformat-pedantic group.Daniel Jasper2015-03-041-8/+10
| | | | | | This was apparently overlooked in r231211. llvm-svn: 231242
* AT.isValid() should come before AT.matchesType()Seth Cantrell2015-03-041-30/+36
| | | | llvm-svn: 231213
* Add a format warning for "%p" with non-void* argsSeth Cantrell2015-03-041-31/+41
| | | | | | | | | | | | | | | | | | GCC -pedantic produces a format warning when the "%p" specifier is used with arguments that are not void*. It's useful for portability to be able to catch such warnings with clang as well. The warning is off by default in both gcc and with this patch. This patch enables it either when extensions are disabled with -pedantic, or with the specific flag -Wformat-pedantic. The C99 and C11 specs do appear to require arguments corresponding to 'p' specifiers to be void*: "If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined." [7.19.6.1 p9], and of the 'p' format specifier "The argument shall be a pointer to void." [7.19.6.1 p8] Both printf and scanf format checking are covered. llvm-svn: 231211
* Sema: Remove stray staticBenjamin Kramer2015-03-011-1/+1
| | | | | | | This is a real bug if the code path is ever used with different pointer sizes in the same process. llvm-svn: 230893
* Patch to prevent crash when default argument expressionFariborz Jahanian2015-02-261-2/+5
| | | | | | | is null due to its previous bad declaration, etc. rdar://19871240 llvm-svn: 230649
* [X86] Remove the blendps/blendpd builtins. They aren't used by the intrinsic ↵Craig Topper2015-02-261-3/+0
| | | | | | headers. We use appropriate shuffle vector instead. llvm-svn: 230616
* [X86] Correct immediate range checking for blendps/blendpd/blendpd256 builtins.Craig Topper2015-02-261-4/+4
| | | | llvm-svn: 230615
* Sema: __assume with side effects shouldn't result in invalid AST nodesDavid Majnemer2015-02-261-1/+1
| | | | | | | | We'd diagnose an __assume expression which contained a function call. This would result in us wrongly returning ExprError, causing mysterious failures later on. llvm-svn: 230597
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-251-2/+2
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* Add support for inserting ArrayRef<FixItHint> into DiagnosticBuilder.Alexander Kornienko2015-02-251-8/+2
| | | | | | This is going to be needed in clang-tidy as more checks add complex fixits. llvm-svn: 230495
* [Objective-C]. Provide a new formatting kind, "os_trace" whichFariborz Jahanian2015-02-211-2/+3
| | | | | | | can take a "const char*" format but supports standard printf and CF/NS types . rdar://19904147 llvm-svn: 230109
* Add support for analyzing FreeBSD kernel printf extensions.Dimitry Andric2015-02-191-2/+42
| | | | | | | | | | | | This adds a new __freebsd_kprintf__ format string type, which enables checking when used in __attribute__((format(...))) attributes. It can check the FreeBSD kernel specific %b, %D, %r and %y specifiers, using existing diagnostic messages. Also adds test cases for all these specifiers. Differential Revision: http://reviews.llvm.org/D7154 llvm-svn: 229921
* [X86] Add range checking on immediate arguments on XOP vpcom builtins.Craig Topper2015-02-131-0/+8
| | | | llvm-svn: 229067
* [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
* 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
* [X86] Add immediate range checking to AVX512 integer comparision builtins.Craig Topper2015-01-251-0/+24
| | | | llvm-svn: 227066
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering looks a lot like normal EH lowering, with the exception that the exceptions are caught by executing filter expression code instead of matching typeinfo globals. The filter expressions are outlined into functions which are used in landingpad clauses where typeinfo would normally go. Major aspects that still need work: - Non-call exceptions in __try bodies won't work yet. The plan is to outline the __try block in the frontend to keep things simple. - Filter expressions cannot use local variables until capturing is implemented. - __finally blocks will not run after exceptions. Fixing this requires work in the LLVM SEH preparation pass. The IR lowering looks like this: // C code: bool safe_div(int n, int d, int *r) { __try { *r = normal_div(n, d); } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) { return false; } return true; } ; LLVM IR: define i32 @filter(i8* %e, i8* %fp) { %ehptrs = bitcast i8* %e to i32** %ehrec = load i32** %ehptrs %code = load i32* %ehrec %matches = icmp eq i32 %code, i32 u0xC0000094 %matches.i32 = zext i1 %matches to i32 ret i32 %matches.i32 } define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) { %rr = invoke i32 @normal_div(i32 %n, i32 %d) to label %normal unwind to label %lpad normal: store i32 %rr, i32* %r ret i1 1 lpad: %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*) %ehptr = extractvalue {i8*, i32} %ehvals, i32 0 %sel = extractvalue {i8*, i32} %ehvals, i32 1 %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*)) %matches = icmp eq i32 %sel, %filter_sel br i1 %matches, label %eh.except, label %eh.resume eh.except: ret i1 false eh.resume: resume } Reviewers: rjmccall, rsmith, majnemer Differential Revision: http://reviews.llvm.org/D5607 llvm-svn: 226760
* [x86] Teach Sema to check size of comparison immediate on avx512 cmpps/cmppd ↵Craig Topper2015-01-191-1/+3
| | | | | | buitins. llvm-svn: 226422
* Extend the self move warning to record types.Richard Trieu2015-01-131-0/+90
| | | | | | | Move the logic for checking self moves into SemaChecking and add that function to Sema since it is now used in multiple places. llvm-svn: 225756
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-2/+2
| | | | llvm-svn: 225624
* [x86] Add range checking to the constant argument of cmpps/pd/ss/sd builtinas.Craig Topper2014-12-271-4/+8
| | | | llvm-svn: 224880
* [c Sema]. Patch fixes pointer-bool-conversion warning on C codeFariborz Jahanian2014-12-181-2/+2
| | | | | | | | when source range is incorrect causing the warning to be issued when it should not because expression is in a macro. rdar://19256338 llvm-svn: 224549
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-2/+2
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* Implement the __builtin_call_with_static_chain GNU extension.Peter Collingbourne2014-12-121-0/+68
| | | | | | | | | | | | | | | | The extension has the following syntax: __builtin_call_with_static_chain(Call, Chain) where Call must be a function call expression and Chain must be of pointer type This extension performs a function call Call with a static chain pointer Chain passed to the callee in a designated register. This is useful for calling foreign language functions whose ABI uses static chain pointers (e.g. to implement closures). Differential Revision: http://reviews.llvm.org/D6332 llvm-svn: 224167
* When checking for nonnull parameter attributes, also check the ParmVarDecl ↵Aaron Ballman2014-12-111-1/+2
| | | | | | since the attribute may reside there, instead of just on the FunctionDecl. Fixes PR21668. llvm-svn: 224039
* PR21706: -Wunsequenced was missing warnings when leaving a sequenced region ↵Richard Smith2014-12-031-5/+6
| | | | | | that contained side effects. llvm-svn: 223184
* Add the exception for strings in logical and expressions to -Wstring-conversionRichard Trieu2014-11-191-2/+9
| | | | | | for C code. llvm-svn: 222327
* [Sema] Patch to issue warning on comparing parameters withFariborz Jahanian2014-11-181-1/+33
| | | | | | | | | | | nonnull attribute when comparison is always true/false. Original patch by Steven Wu. I have added extra code to prevent issuing of warning when the nonnull parameter is modified prior to the comparison. This addition prevents false positives in the most obvious cases. There may still be false positive warnings in some cases (as one of my tests indicates), but benefit far outweighs such cases. rdar://18712242 llvm-svn: 222264
* Fix issues missed during the review of r222099.Richard Trieu2014-11-151-15/+17
| | | | | | | Shift some functions around, make a method in Sema private, call the correct overloaded function. No functional change. llvm-svn: 222081
* Recommit r222044 with a test fix - it does not make sense to huntAnton Korobeynikov2014-11-141-21/+67
| | | | | | for a typedef before arithmetic conversion in all rare corner cases. llvm-svn: 222049
* Again revert r222044 to resolve darwin objc test fails.Anton Korobeynikov2014-11-141-67/+21
| | | | llvm-svn: 222047
* Follow-up to D6217Anton Korobeynikov2014-11-141-21/+67
| | | | | | | | | | | | | | | | | Summary: Ok, here is somewhat addition to D6217 aiming to preserve old darwin behavior wrt the typedefed types. The actual change to SemaChecking turned out to be pretty gross, in particular: 1. We need to extract the typedef'ed type for proper diagnostics 2. We need to walk over paren expressions as well Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6256 llvm-svn: 222044
* [Sema]. Warn when logical expression is a pointerFariborz Jahanian2014-11-141-0/+19
| | | | | | | which evaluates to true. rdar://18716393. Reviewed by Richard Trieu llvm-svn: 222009
OpenPOWER on IntegriCloud