summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-1/+1
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Broaden -Wstring-conversion to catch string literals in logical or expressions.Richard Trieu2014-01-251-5/+6
| | | | | | | | | | | | Previously, string literals were ignored in all logical expressions. This reduces it to only ignore in logical and expressions. assert(0 && "error"); // No warning assert(0 || "error"); // Warn Fixes PR17565 llvm-svn: 200056
* Combine the checks for returns_nonnull and for operator new returning null, ↵Artyom Skrobov2014-01-241-5/+22
| | | | | | in Sema::CheckReturnValExpr. Add the missing handling of value-dependent expressions for returns_nonnull. llvm-svn: 199989
* Add basic checking for returning null from functions/methods marked ↵Ted Kremenek2014-01-221-18/+49
| | | | | | | | | | 'returns_nonnull'. This involved making CheckReturnStackAddr into a static function, which is now called by a top-level return value checking routine called CheckReturnValExpr. llvm-svn: 199790
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-24/+16
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Enhance attribute 'nonnull' to be applicable to parameters directly (infix).Ted Kremenek2014-01-171-0/+16
| | | | | | | | | | | | | | | | | | | | | This allows the following syntax: void baz(__attribute__((nonnull)) const char *str); instead of: void baz(const char *str) __attribute__((nonnull(1))); This also extends to Objective-C methods. The checking logic in Sema is not as clean as I would like. Effectively now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters, so the point of truth is spread in two places, but the logic isn't that cumbersome. Implements <rdar://problem/14691443>. llvm-svn: 199467
* Push NonNullAttr inspection loop into CheckNonNullArguments.Ted Kremenek2014-01-171-23/+30
| | | | | | No functionality change. llvm-svn: 199465
* Make 'CheckNonNullArguments' a static function. No functionality change.Ted Kremenek2014-01-171-27/+27
| | | | llvm-svn: 199464
* Follow-up to r199120: don't try referencing the dtor if the param decl isn't ↵Hans Wennborg2014-01-131-8/+10
| | | | | | | | valid. This was caught by running test/SemaCXX/destructor.cpp in MS ABI mode. llvm-svn: 199128
* [ms-cxxabi] Elide dtor access checks for pass-by-val objects in calleesHans Wennborg2014-01-131-3/+12
| | | | | | | | | | | | | | | The ABI requires the destructor to be invoked in the callee, but the standard does not require access checks here so we avoid doing direct access checks on the destructor. If we end up needing to define an implicit destructor, we don't skip access checks for the base class, etc. Those checks are effectively part of generating the destructor definition, and aren't affected by which TU the check is performed in. Differential Revision: http://llvm-reviews.chandlerc.com/D2409 llvm-svn: 199120
* Make the tautological out of range warning use Sema::DiagRuntimeBehavior so thatRichard Trieu2014-01-101-3/+5
| | | | | | the warning will not trigger on code protected by compile time checks. llvm-svn: 198913
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Removing some more unnecessary manual quotes from attribute diagnostics.Aaron Ballman2014-01-031-1/+1
| | | | llvm-svn: 198392
OpenPOWER on IntegriCloud