summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r221702 until I address Richard Trieu'sFariborz Jahanian2014-11-111-11/+0
| | | | | | comments. llvm-svn: 221714
* Patch to warn when logical evaluation of operand evalutes to a true value;Fariborz Jahanian2014-11-111-0/+11
| | | | | | | That this is a c-only patch. c++ already has this warning. This addresses rdar://18716393 llvm-svn: 221702
* This patch reverts r220496 which issues warning on comparing Fariborz Jahanian2014-11-031-31/+1
| | | | | | | | parameters with nonnull attribute when comparison is always true/false. Patch causes false positive when parameter is modified in the function. llvm-svn: 221163
* patch to issue warning on comparing parameters withFariborz Jahanian2014-10-231-1/+31
| | | | | | | | nonnull attribute when comparison is always true/false. Patch by Steven Wu with few fixes and minor refactoring and adding tests by me. rdar://18712242 llvm-svn: 220496
* Improvements to -Wnull-conversionRichard Trieu2014-10-151-13/+36
| | | | | | | | | Split logic to separate checking function Refine the macro checking Catch nullptr->bool conversions Add some explanatory comments llvm-svn: 219774
* Patch to warn on interger overflow in presence ofFariborz Jahanian2014-10-141-2/+2
| | | | | | | implicit casts. Reviewed by Reid Kleckner. rdar://18405357 llvm-svn: 219712
* [complex] Teach the other two binary operators on complex numbers (==Chandler Carruth2014-10-111-2/+7
| | | | | | | | | | | | | | | | | and !=) to support mixed complex and real operand types. This requires removing an assert from SemaChecking, and adding support both to the constant evaluator and the code generator to synthesize the imaginary part when needed. This seemed somewhat cleaner than having just the comparison operators force real-to-complex conversions. I've added test cases for these operations. I'm really terrified that there were *no* tests in-tree which exercised this. This turned up when trying to build R after my change to the complex type lowering. llvm-svn: 219570
* Add __sync_fetch_and_nand (again)Hal Finkel2014-10-021-10/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to GCC 4.4, __sync_fetch_and_nand was implemented as: { tmp = *ptr; *ptr = ~tmp & value; return tmp; } but this was changed in GCC 4.4 to be: { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } in response to this change, support for sync_fetch_and_nand (and sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code depending on the old semantics. However, at this point: 1. Many years have passed, and the amount of code relying on the old semantics is likely smaller. 2. Through the work of many contributors, all LLVM backends have been updated such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process was complete July of 2014 (added to the release notes in r212635). 3. The lack of this intrinsic is now a needless impediment to porting codes from GCC to Clang (I've now seen several examples of this). It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC 4.2). To compensate for this, and to address the original concern regarding code relying on the old semantics, I've added a warning that specifically details the fact that the semantics have changed and that we provide the newer semantics. Fixes PR8842. llvm-svn: 218905
* Don't trap when passing non-POD arguments to variadic functions in ↵Hans Wennborg2014-09-291-0/+1
| | | | | | | | | | | | | | | | | | MS-compatibility mode Clang warns (treated as error by default, but still ignored in system headers) when passing non-POD arguments to variadic functions, and generates a trap instruction to crash the program if that code is ever run. Unfortunately, MSVC happily generates code for such calls without a warning, and there is code in system headers that use it. This makes Clang not insert the trap instruction when in -fms-compatibility mode, while still generating the warning/error message. Differential Revision: http://reviews.llvm.org/D5492 llvm-svn: 218640
* Support the assume_aligned function attributeHal Finkel2014-09-261-1/+1
| | | | | | | | | In addition to __builtin_assume_aligned, GCC also supports an assume_aligned attribute which specifies the alignment (and optional offset) of a function's return value. Here we implement support for the assume_aligned attribute by making use of the @llvm.assume intrinsic. llvm-svn: 218500
* Fix the argument index error of __builtin___memccpy_chkSteven Wu2014-09-241-1/+3
| | | | | | | memccpy_check should have source and dest size at arg 3 and 4 rdar://18431336 llvm-svn: 218367
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-181-1/+48
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-121-1/+2
| | | | | | | | for __builtin___strlcpy_chk/__builtin___strlcat_chk. Patch by Jacques Fortier with monir change by me and addition of test. rdar://18259539 llvm-svn: 217700
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-111-20/+40
| | | | | | | | | off by default, issue a warning if %s directive is used in formart argument of a function/method declared as __attribute__((format(CF/NSString, ...))) To complete rdar://18182443 llvm-svn: 217619
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-091-0/+47
| | | | | | | | off by default, issue a warning if %s directive is used in certain CF/NS formatting APIs, to assist user in deprecating use of such %s in these APIs. rdar://18182443 llvm-svn: 217467
* Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel2014-09-071-1/+45
| | | | | | | | | | | This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-5/+4
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
* Fix representation of __attribute__((nonnull)) to support correctly modelingRichard Smith2014-08-271-8/+28
| | | | | | | | | | | | | | | the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B, C))) attribute, since that does the wrong thing for function templates and varargs functions. In passing, fix a grammar error in the diagnostic, a crash if __attribute__((nonnull(N))) is applied to a varargs function, a bug where the same null argument could be diagnosed multiple times if there were multiple nonnull attributes referring to it, and a bug where nonnull attributes would not be accumulated correctly across redeclarations. llvm-svn: 216520
* ARM: Add dbg builtin intrinsicYi Kong2014-08-261-2/+2
| | | | llvm-svn: 216452
* AArch64: Prefetch intrinsicYi Kong2014-08-131-0/+7
| | | | llvm-svn: 215569
* ARM: Prefetch intrinsicsYi Kong2014-08-131-0/+5
| | | | llvm-svn: 215568
* Extend tautological pointer compare and pointer to bool conversion warnings toRichard Trieu2014-08-081-1/+21
| | | | | | | | | | | | | | | macro arguments. Previously, these warnings skipped any code in a macro expansion. Preform an additional check and warn when the expression and context locations are both in the macro argument. The most obvious case not caught is passing a pointer directly to a macro, i.e 'assert(&array)' but 'assert(&array && "valid array")' is caught. This is because macro arguments are not typed and the conversion happens inside the macro. llvm-svn: 215251
* Update the context location of the condition of a conditional operator to theRichard Trieu2014-08-071-1/+1
| | | | | | | question mark instead of the context of the conditional operator. The condition does not need the context of the conditional operator at all. llvm-svn: 215048
* AArch64: update Clang for merged arm64/aarch64 triples.Tim Northover2014-07-231-4/+1
| | | | | | | | | | | | | | The main subtlety here is that the Darwin tools still need to be given "-arch arm64" rather than "-arch aarch64". Fortunately this already goes via a custom function to handle weird edge-cases in other architectures, and it tested. I removed a few arm64_be tests because that really isn't an interesting thing to worry about. No-one using big-endian is also referring to the target as arm64 (at least as far as toolchains go). Mostly they date from when arm64 was a separate target and we *did* need a parallel name simply to test it at all. Now aarch64_be is sufficient. llvm-svn: 213744
* Sema: correct handling for __va_start for WoASaleem Abdulrasool2014-07-221-1/+66
| | | | | | | | | | | | | | | | | | Windows ARM indicates __va_start as a variadic function. However, the function itself is treated as having 4 formal arguments: - (out) pointer to the va_list - (in) address of the last named argument - (in) slot size for the type of the last argument - address of the last named argument The last argument does not seem to have any bearing on codegen, and thus is not explicitly type checked at this point. Unlike the previous handling for __va_start, it does not currently validate if the parameter is the last named parameter (it seems that MSVC currently accepts this). llvm-svn: 213595
* Sema: Handle C11 atomics when diagnosing out of range comparisonsJustin Bogner2014-07-211-0/+6
| | | | | | | | This fixes a couple of asserts when analyzing comparisons involving C11 atomics that were uncovered by r205608 when we extended the applicability of -Wtautological-constant-out-of-range-compare. llvm-svn: 213573
* Add an __assume side-effects warningHal Finkel2014-07-171-0/+18
| | | | | | | | | | | | In MS-compatibility mode, we support the __assume builtin. The __assume builtin does not evaluate its arguments, and we should issue a warning if __assume is provided with an argument with side effects (because these effects will be discarded). This is similar in spirit to the warnings issued by other compilers (Intel Diagnostic 2261, MS Compiler Warning C4557). llvm-svn: 213266
* Port memory barriers intrinsics to AArch64Yi Kong2014-07-171-1/+12
| | | | | | | | | | | | | Memory barrier __builtin_arm_[dmb, dsb, isb] intrinsics are required to implement their corresponding ACLE and MSVC intrinsics. This patch ports ARM dmb, dsb, isb intrinsic to AArch64. Requires LLVM r213247. Differential Revision: http://reviews.llvm.org/D4521 llvm-svn: 213250
* Consolidate header inclusion diagnosticsAlp Toker2014-07-111-3/+4
| | | | | | | Make argument orders match, unify diagnostic IDs and reword the message to be a little less saccharine. llvm-svn: 212845
* [ARM] Implement ISB memory barrier intrinsicYi Kong2014-07-031-3/+4
| | | | | | | Adds support for __builtin_arm_isb. Also corrects DSB and ISB instructions modelling by adding has-side-effects property. llvm-svn: 212277
* ARM: add support for v8 ldaex/stlex builtins.Tim Northover2014-07-021-4/+14
| | | | | | | | | | | | | | ARMv8 adds (to both AArch32 and AArch64) acquiring and releasing variants of the exclusive operations, in line with the C++11 memory model. This adds support for two new intrinsics to expose them to C & C++ developers directly: __builtin_arm_ldaex and __builtin_arm_stlex, in direct analogy with the versions with no implicit barrier. rdar://problem/15885451 llvm-svn: 212175
* Prevent Clang from crashing on template code.Richard Trieu2014-07-021-1/+8
| | | | | | | | | | Fixes PR20110, where Clang hits an assertion failure when it expects that the sub-expression of a bit cast to pointer to also be a pointer, but gets a value instead. Differential Revision: http://reviews.llvm.org/D4280 llvm-svn: 212160
* Extend -Wtautological-undefined-compare and -Wundefined-bool-conversion toRichard Trieu2014-06-281-12/+46
| | | | | | | trigger on taking the address of a reference that is returned from a function call. llvm-svn: 211989
* Extend -Wdynamic-class-memaccess to records containing dynamic classesReid Kleckner2014-06-271-12/+33
| | | | | | | | | | Reviewers: rtrieu Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4325 llvm-svn: 211972
* Convert an llvm_unreachable in an 'else' block to a removal of the 'if' and ↵Craig Topper2014-06-181-3/+3
| | | | | | an assertion of its condition. Suggestion from David Blaikie. llvm-svn: 211142
* Replace some assert(0)'s with llvm_unreachable.Craig Topper2014-06-181-1/+1
| | | | llvm-svn: 211139
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-12/+6
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Objective-C ARC. Blocks that strongly capture themselvesFariborz Jahanian2014-06-121-3/+20
| | | | | | | | | | | to call themselves will get the warning: "Capturing <itself> strongly in this block is likely to lead to a retain cycle". Cut down on the amount of noise by noticing that user at some point sets the captured variable to null in order to release it (and break the cycle). // rdar://16944538 llvm-svn: 210823
* Removing an "if (this == nullptr)" check from two print methods. The conditionRichard Trieu2014-06-091-0/+2
| | | | | | | will never be true in a well-defined context. The checking for null pointers has been moved into the caller logic so it does not rely on undefined behavior. llvm-svn: 210498
* Add -Wtautological-undefined-compare and -Wundefined-bool-conversion warningsRichard Trieu2014-06-061-2/+14
| | | | | | to detect underfined behavior involving pointers. llvm-svn: 210372
* Add __builtin_operator_new and __builtin_operator_delete, which act like callsRichard Smith2014-06-031-1/+15
| | | | | | | to the normal non-placement ::operator new and ::operator delete, but allow optimizations like new-expressions and delete-expressions do. llvm-svn: 210137
* Format strings: check against an enum's underlying type.Jordan Rose2014-05-311-11/+18
| | | | | | | | | | | | | This allows us to be more careful when dealing with enums whose fixed underlying type requires special handling in a format string, like NSInteger. A refinement of r163266 from a year and a half ago, which added the special handling for NSInteger and friends in the first place. <rdar://problem/16616623> llvm-svn: 209966
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-9/+8
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-7/+7
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-54/+55
| | | | llvm-svn: 209613
* AArch64/ARM64: rename ARM64 components to AArch64Tim Northover2014-05-241-7/+7
| | | | | | This keeps Clang consistent with backend naming conventions. llvm-svn: 209579
* AArch64/ARM64: update Clang after AArch64 removal.Tim Northover2014-05-241-13/+2
| | | | | | | | | | | A few (mostly CodeGen) parts of Clang were tightly coupled to the AArch64 backend. Now that it's gone, they will not even compile. I've also deduplicated RUN lines in many of the AArch64 tests. This might improve "make check-all" time noticably: some of those NEON tests were monsters. llvm-svn: 209578
* Tweak diagnostic wording for init list narrowingAlp Toker2014-05-171-2/+2
| | | | | | | | | The conventional form is '<action> to silence this warning'. Also call the diagnostic an 'issue' rather than a 'message' because the latter term is more widely used with reference to message expressions. llvm-svn: 209052
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-20/+14
| | | | llvm-svn: 207896
* Updated the attribute tablegen emitter for variadic arguments to emit a ↵Aaron Ballman2014-05-021-5/+2
| | | | | | range accessor in addition to the iterators. Updated code using iterators to use range-based for loops. llvm-svn: 207837
OpenPOWER on IntegriCloud