summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* [ARM64] Add arm64_be where it was accidentally missed from a bunch of ↵James Molloy2014-04-301-0/+1
| | | | | | | | | if-conditions. I think this is the last commit for ARM64 big endian in clang. This commit makes arm_neon.h compile correctly. llvm-svn: 207624
* Sema: Factor out argument range checks for builtin functionsRichard Sandiford2014-04-161-109/+19
| | | | | | No behavioural change intended. llvm-svn: 206364
* Make -Wabsolute-value C++-aware.Richard Trieu2014-04-151-43/+104
| | | | | | | | Warn on std::abs() with unsigned argument. Suggest std::abs as replacement for the C absolute value functions. Suggest C++ headers if the specific std::abs overload is not found. llvm-svn: 206340
* Revert r205646 (keeping the test in its modified form) asFariborz Jahanian2014-04-071-10/+1
| | | | | | it is subsumed by r205521. llvm-svn: 205718
* Vector [Sema]. Vector "splats" which are truncated should have a warningFariborz Jahanian2014-04-041-1/+10
| | | | | | with -Wconversion. // rdar://16502418 llvm-svn: 205646
* Extend -Wtautological-constant-out-of-range-compare to handle boolean valuesRichard Trieu2014-04-041-74/+167
| | | | | | | | | | | | | | | better. This warning will now trigger on the following conditionals: bool b; int i; if (b > 1) {} // always false if (0 <= (i > 5)) {} // always true if (-1 > b) {} // always false Patch by Per Viberg. llvm-svn: 205608
* Improved semantics for implicit scalar -> extvector conversions.Stephen Canon2014-04-031-0/+2
| | | | llvm-svn: 205521
* ARM64: initial clang support commit.Tim Northover2014-03-291-12/+40
| | | | | | | | | | | This adds Clang support for the ARM64 backend. There are definitely still some rough edges, so please bring up any issues you see with this patch. As with the LLVM commit though, we think it'll be more useful for merging with AArch64 from within the tree. llvm-svn: 205100
* Add ARM big endian Target (armeb, thumbeb)Christian Pirker2014-03-281-0/+2
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D3096 llvm-svn: 205008
* -fms-extensions: Add __va_start builtin, which is used for x64Reid Kleckner2014-03-261-0/+1
| | | | | | | | | | The main difference between __va_start and __builtin_va_start is that the address of the va_list has already been taken, and the va_list is always a char*. __va_end and __va_arg are not needed. llvm-svn: 204821
* remove a bunch of unused private methodsNuno Lopes2014-03-231-3/+0
| | | | | | | | | | | | | | | | | | found with a smarter version of -Wunused-member-function that I'm playwing with. Appologies in advance if I removed someone's WIP code. ARCMigrate/TransProperties.cpp | 8 ----- AST/MicrosoftMangle.cpp | 1 Analysis/AnalysisDeclContext.cpp | 5 --- Analysis/LiveVariables.cpp | 14 ---------- Index/USRGeneration.cpp | 10 ------- Sema/Sema.cpp | 33 +++++++++++++++++++++--- Sema/SemaChecking.cpp | 3 -- Sema/SemaDecl.cpp | 20 ++------------ StaticAnalyzer/Checkers/GenericTaintChecker.cpp | 1 9 files changed, 34 insertions(+), 61 deletions(-) llvm-svn: 204561
* scanf format checking: include the buffer length in the fix-it for %s.Jordan Rose2014-03-201-2/+3
| | | | | | Patch by Zach Davis! llvm-svn: 204300
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-21/+22
| | | | | | class. llvm-svn: 203640
* Sema: demote invalid atomic ordering message to warning.Tim Northover2014-03-111-3/+3
| | | | | | | | | | | | | | Someone could write: if (0) { __c11_atomic_load(ptr, memory_order_release); } or the equivalent, which is perfectly valid, so we shouldn't outright reject invalid orderings on purely static grounds. rdar://problem/16242991 llvm-svn: 203564
* Sema: produce error when invalid ordering is passed to atomic builtinTim Northover2014-03-111-1/+37
| | | | | | | | | This is a conservative check, because it's valid for the expression to be non-constant, and in cases like that we just don't know whether it's valid. rdar://problem/16242991 llvm-svn: 203561
* [C++11] Replacing DeclBase iterators specific_attr_begin() and ↵Aaron Ballman2014-03-101-20/+6
| | | | | | specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203474
* Remove trailing whitespace.Bob Wilson2014-03-091-1/+1
| | | | llvm-svn: 203422
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-9/+4
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203355
* Zap another dead 'break' statement.Ted Kremenek2014-03-071-1/+0
| | | | llvm-svn: 203282
* Suppress diagnostics during name lookup for absolute value type.Richard Trieu2014-03-061-0/+1
| | | | llvm-svn: 203061
* Move private classes into anonymous namespaces.Benjamin Kramer2014-03-011-1/+1
| | | | llvm-svn: 202595
* Add a -Wclass-varargs to warn on objects of any class type being passed ↵Richard Smith2014-02-281-6/+21
| | | | | | | | | | | | through an ellipsis. Since C++11 relaxed the rules on this, we allow a lot more bad code through silently, such as: const char *format = "%s"; std::experimental::string_view view = "foo"; printf(format, view); In this case, not only warn about a class type being used here, but also suggest that calling c_str() might be a good idea. llvm-svn: 202461
* PR16074, implement warnings to catch pointer to boolean true and pointer toRichard Trieu2014-02-261-29/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | null comparison when the pointer is known to be non-null. This catches the array to pointer decay, function to pointer decay and address of variables. This does not catch address of function since this has been previously used to silence a warning. Pointer to bool conversion is under -Wbool-conversion. Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group of -Wtautological-compare. void foo() { int arr[5]; int x; // warn on these conditionals if (foo); if (arr); if (&x); if (foo == null); if (arr == null); if (&x == null); if (&foo); // no warning } llvm-svn: 202216
* Add -Wabsolute-value, warnings about absolute value functions.Richard Trieu2014-02-261-0/+325
| | | | | | | | | | | | | | | | | | The warnings fall into three groups. 1) Using an absolute value function of the wrong type, for instance, using the int absolute value function when the argument is a floating point type. 2) Using the improper sized absolute value function, for instance, using abs when the argument is a long long. llabs should be used instead. From these two cases, an implicit conversion will occur which may cause unexpected behavior. Where possible, suggest the proper absolute value function to use, and which header to include if the function is not available. 3) Taking the absolute value of an unsigned value. In addition to this warning, suggest to remove the function call. This usually indicates a logic error since the programmer assumed negative values would have been possible. llvm-svn: 202211
* Add AArch64 big endian Target (aarch64_be)Christian Pirker2014-02-251-0/+1
| | | | llvm-svn: 202151
* [AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.Kevin Qin2014-02-241-2/+6
| | | | | | | | | | Most 64-bit targets define int64_t as long int, and AArch64 should make same definition to follow LP64 model. In GNU tool chain, int64_t is defined as long int for 64-bit target. So to get consistent with GNU, it's better Changing int64_t from 'long long int' to 'long int', otherwise clang will get different name mangling suffix compared with g++. llvm-svn: 202004
* Sema: Simplify away one-iteration loops.Benjamin Kramer2014-02-231-14/+5
| | | | | | No functionality change. llvm-svn: 201981
* Reapply 201734 but with appropriate gcc compatibilityWarren Hunt2014-02-211-0/+34
| | | | | | | | | | Because GCC incorrectly defines _mm_prefetch to take anything that casts to void*, people have started using that behavior. The previous patch that made _mm_prefetch actually take a const char * broke compatibility with existing code. This update to the patch leaves the macro that defines _mm_prefetch with the (void*) cast when _MSC_VER is not defined. llvm-svn: 201901
* Sema: Emit a warning for non-null terminated format strings and other ↵Benjamin Kramer2014-02-201-2/+18
| | | | | | | | pathological cases. PR18905. llvm-svn: 201795
* Revert r201734 and r201742.Daniel Jasper2014-02-201-34/+0
| | | | | | | | | | | | | | | | | | | | | This breaks backwards compatibility with existing code. Previously, this was defined as #define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel))) Which basically accepts any pointer. Changing this to char* simply breaks a lot of existing code. I have tried changing char* to "const void*", which seems to be the right thing as per Intel specification this should work on basically any pointer. However, apparently this breaks windows compatibility (because of a conflicting declaration in windows.h). So, we probably need to #ifdef this based on whether clang is compiling for windows. According to Chandler, this might be done by introducing an additional symbol to a fake type in BuiltinsX86.def and then condition the type expansion on the platform. llvm-svn: 201775
* Add _mm_prefetch and some others as MS builtinsWarren Hunt2014-02-191-0/+34
| | | | | | | | | | | | | This patch adds several built-ins that are required for ms compatibility. _mm_prefetch must be a built-in because it takes a compile-time constant argument and our prior approach of using a #define to the current built-in doesn't work in the presence of re-declaration of _mm_prefetch. The others can be obtained by including the windows system headers. If a user includes the windows system headers but not intrin.h they still need to work and therefore must be built-in because we don't get a chance to implement them in intrin.h in this case. llvm-svn: 201734
* ARM & AArch64: merge the semantic checking of NEON intrinsicsTim Northover2014-02-191-56/+21
| | | | | | | | | | | | | | | | | | | | | There are two kinds of automatically generated tests for NEON intrinsics, both of which can be merged without adversely affecting users. 1. We check that a valid kind of __builtin_neon_XYZ overload is requested (e.g. we're not asking for a float32x4_t version when it only accepts integers. Since the __builtin_neon_XYZ intrinsics should only be used in arm_neon.h, relaxing this test and permitting AArch64 types for AArch32 should not cause a problem. The extra arm_neon.h definitions should be #ifdefed out anyway. 2. We check that intrinsics which take immediates are actually given compile-time constants within range. Since all NEON intrinsics should be backwards compatible, these tests should be identical on AArch64 and AArch32 anyway. This patch, therefore, merges the separate AArch64 and 32-bit checks. rdar://problem/16035743 llvm-svn: 201659
* ARM NEON: fix range checking on immediates.Tim Northover2014-02-121-2/+2
| | | | | | | | | | Previously, range checking on the __builtin_neon_XYZ_v Clang intrinsics didn't take account of the type actually passed to the call, which meant a request like "vext_s16(a, b, 7)" was allowed through (TableGen was conservative and allowed 0-7 for all types). This caused an assert in the backend because the lane doesn't make sense. llvm-svn: 201232
* Objective-C. Revert patch r193003 for furtherFariborz Jahanian2014-02-071-21/+0
| | | | | | internal discussions. // rdar://16006401 llvm-svn: 200986
* Don't produce a 'returning reference to local' warning if a lambda returns aRichard Smith2014-01-301-0/+8
| | | | | | | reference (or pointer) to a variable from the closure object or from the surrounding function scope. llvm-svn: 200494
* A new conversion warning for when an Objective-C object literal is implicitlyRichard Trieu2014-01-281-0/+7
| | | | | | | | | cast into a boolean true value. This warning will catch code like: if (@0) {} if (@"foo") {} llvm-svn: 200356
* PR17052 / DR1560 (+DR1550): In a conditional expression between a glvalue and aRichard Smith2014-01-271-9/+17
| | | | | | | throw-expression, the result is also a glvalue and isn't unnecessarily coerced to a prvalue. llvm-svn: 200189
OpenPOWER on IntegriCloud