summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Rename isBuiltinCall() to getBuiltinCallee()Alp Toker2013-12-281-4/+4
| | | | | | | | This better describes what the function does. Cleanup only. llvm-svn: 198127
* Warn on mismatched parentheses in memcmp and friends.Nico Weber2013-12-261-2/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thisadds a new warning that warns on code like this: if (memcmp(a, b, sizeof(a) != 0)) The warning looks like: test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison] if (memcmp(a, b, sizeof(a) != 0)) ~~~~~~~~~~^~~~ test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead? if (memcmp(a, b, sizeof(a) != 0)) ^ ~ ) test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning if (memcmp(a, b, sizeof(a) != 0)) ^ (size_t)( ) 1 warning generated. This found 2 bugs in chromium and has 0 false positives on both chromium and llvm. The idea of triggering this warning on a binop in the size argument is due to rnk. llvm-svn: 198063
* [AArch64 NEON] Support poly128_t and implement relevant intrinsic.Kevin Qin2013-12-101-0/+4
| | | | llvm-svn: 196888
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* [ms-cxxabi] Construct and destroy call arguments in the correct orderReid Kleckner2013-12-041-2/+3
| | | | | | | | | | | | | | | | | | | Summary: MSVC destroys arguments in the callee from left to right. Because C++ objects have to be destroyed in the reverse order of construction, Clang has to construct arguments from right to left and destroy arguments from left to right. This patch fixes the ordering by reversing the order of evaluation of all call arguments under the MS C++ ABI. Fixes PR18035. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2275 llvm-svn: 196402
* [AArch64 neon] support poly64 and relevant intrinsic functions.Kevin Qin2013-11-141-6/+10
| | | | llvm-svn: 194660
* add intrinsics: __builtin_arm_{dmb,dsb} for ARMWeiming Zhao2013-11-121-0/+2
| | | | llvm-svn: 194513
* Fixed bug in return type of __builtin_va_start().Enea Zaffanella2013-11-071-0/+1
| | | | llvm-svn: 194197
* Simplify: we don't care why constant evaluation might have failed when we'reRichard Smith2013-11-051-4/+2
| | | | | | checking an expression for constant overflow. llvm-svn: 194099
* Disable -Wtautological-compare in template instantiations.Richard Trieu2013-11-011-0/+4
| | | | llvm-svn: 193888
* Disable -Wtautological-constant-out-of-range-compare in template instantiations.Richard Trieu2013-11-011-0/+4
| | | | llvm-svn: 193887
* ARM: fix AST for __builtin_arm_strex callTim Northover2013-10-291-1/+4
| | | | | | | | | | | The AST was constructed so that this builtin returned the default BoolTy and since I'd opted for custom SemaChecking, I should have set it properly at that point. This caused an assertion failure when the types didn't match up with what we generated. This makes it return an IntTy, which is as good as anything. llvm-svn: 193606
* ObjectiveC. Added support for methods annotated with format_argFariborz Jahanian2013-10-181-0/+21
| | | | | | | attributes when such methods are actually envoked in message expression. // rdar://15242010 llvm-svn: 193003
* Special case '%C' handling in ObjC format strings to handle integer literals ↵Ted Kremenek2013-10-151-1/+9
| | | | | | | | that can represent unicode characters Fixes <rdar://problem/13991617>. llvm-svn: 192673
* GetExprRange() (used by -Wconversion checking) should look through ↵Ted Kremenek2013-10-141-0/+3
| | | | | | | | | | OpaqueValueExprs. Fixes a false positive with -Wconversion involving Objective-C properties. Fixes <rdar://problem/14415662>. llvm-svn: 192611
* PR17290: Use 'false' macro in fix-it hint for initializing a variable of typeRichard Smith2013-09-201-1/+2
| | | | | | | | | _Bool in C, if the macro is defined. Also teach FixItUtils to look at whether the macro was defined at the source location for which it is creating a fixit, rather than looking at whether it's defined *now*. This is especially relevant for analysis-based warnings which are delayed until end of TU. llvm-svn: 191057
* Add the intrinsic __builtin_convertvectorHal Finkel2013-09-181-0/+31
| | | | | | | | | | | | | | | | | | LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to cause such instructions to be generated when using builtin vector types. C-style casting on vectors is already defined in terms of bitcasts, and so cannot be used for these conversions as well (without leading to a very confusing set of semantics). As a result, this adds a __builtin_convertvector intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is intended to aid the creation of vector intrinsic headers that create generic IR instead of target-dependent intrinsics (in other words, this is a generic _mm_cvtepi32_ps). As noted in the documentation, the action of __builtin_convertvector is defined in terms of the action of a C-style cast on each vector element. llvm-svn: 190915
* volatile types are not trivially copyable.Eli Friedman2013-09-111-1/+2
| | | | | | PR17123. llvm-svn: 190484
* Switched FormatAttr to using an IdentifierArgument instead of a ↵Aaron Ballman2013-09-031-1/+1
| | | | | | StringArgument since that is a more accurate modeling. llvm-svn: 189851
* Adjust clang for change to APFloat::toString.Eli Friedman2013-08-291-1/+9
| | | | | | | | I changed the diagnostic printing code because it's probably better to cut off a digit from DBL_MAX than to print something like 1.300000001 when the user wrote 1.3. llvm-svn: 189625
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-2/+1
| | | | | | No functionality change intended. llvm-svn: 189112
* Split isFromMainFile into two functions.Eli Friedman2013-08-221-1/+1
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* Omit llvm:: before SmallVector and SmallVectorImpl. We have using directive ↵Robert Wilhelm2013-08-101-13/+12
| | | | | | in include/clang/Basic/LLVM.h. llvm-svn: 188138
* Put back a microoptimization with a comment to make it more obvious.Benjamin Kramer2013-08-091-2/+5
| | | | llvm-svn: 188063
* Remove unused variable. No functionality change.Benjamin Kramer2013-08-081-8/+6
| | | | llvm-svn: 187975
* Implement C++'s restrictions on the type of an expression passed to a varargRichard Smith2013-08-051-73/+124
| | | | | | | | | | | | | function: it can't be 'void' and it can't be an initializer list. We give a hard error for these rather than treating them as undefined behavior (we can and probably should do the same for non-POD types in C++11, but as of this change we don't). Slightly rework the checking of variadic arguments in a function with a format attribute to ensure that certain kinds of format string problem (non-literal string, too many/too few arguments, ...) don't suppress this error. llvm-svn: 187735
* Add support for passing -1 to __builtin_shufflevector to signify an ↵Craig Topper2013-08-031-0/+4
| | | | | | undefined element value to match IR capabilities. llvm-svn: 187694
* Fix indentation. No functional change.Craig Topper2013-08-021-1/+1
| | | | llvm-svn: 187644
* AArch64: initial NEON supportTim Northover2013-08-011-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Ana Pazos - Completed implementation of instruction formats: AdvSIMD three same AdvSIMD modified immediate AdvSIMD scalar pairwise - Completed implementation of instruction classes (some of the instructions in these classes belong to yet unfinished instruction formats): Vector Arithmetic Vector Immediate Vector Pairwise Arithmetic - Initial implementation of instruction formats: AdvSIMD scalar two-reg misc AdvSIMD scalar three same - Intial implementation of instruction class: Scalar Arithmetic - Initial clang changes to support arm v8 intrinsics. Note: no clang changes for scalar intrinsics function name mangling yet. - Comprehensive test cases for added instructions To verify auto codegen, encoding, decoding, diagnosis, intrinsics. llvm-svn: 187568
* Return ExprError if both arguments to the mask form of ↵Craig Topper2013-07-291-13/+13
| | | | | | | | __builtin_shufflvector don't have the same number of elements or the mask isn't an integer vector. Previously a diagnostic was issued, but the code went ahead and built the ShuffleVectorExpr. While I'm here also simplify a couple lines by wrapping the return ExprError around the Diag calls. llvm-svn: 187344
* Fix up formatting. No functional change.Craig Topper2013-07-281-6/+6
| | | | llvm-svn: 187334
* Remove trailing whitespace.Craig Topper2013-07-191-5/+4
| | | | llvm-svn: 186652
* ARM: implement low-level intrinsics for the atomic exclusive operations.Tim Northover2013-07-161-0/+108
| | | | | | | | | | | | This adds three overloaded intrinsics to Clang: T __builtin_arm_ldrex(const volatile T *addr) int __builtin_arm_strex(T val, volatile T *addr) void __builtin_arm_clrex() The intent is that these do what users would expect when given most sensible types. Currently, "sensible" translates to ints, floats and pointers. llvm-svn: 186394
* Add a __builtin_addressof that performs the same functionality as the built-inRichard Smith2013-07-111-0/+20
| | | | | | | | | | | & operator (ignoring any overloaded operator& for the type). The purpose of this builtin is for use in std::addressof, to allow it to be made constexpr; the existing implementation technique (reinterpret_cast to some reference type, take address, reinterpert_cast back) does not permit this because reinterpret_cast between reference types is not permitted in a constant expression in C++11 onwards. llvm-svn: 186053
* Fix Sema for compares with _Atomic vars.Eli Friedman2013-07-081-16/+19
| | | | | | | | | | | | | | | | Use UsualArithmeticConversions unconditionally in analysis of comparisons and conditional operators: the method performs the usual arithmetic conversions if both sides are arithmetic, and usual unary conversions if they are not. This is just a cleanup for conditional operators; for comparisons, it fixes the issue that we would try to check isArithmetic() on an atomic type. Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables of atomic type correctly. Fixes PR15537. llvm-svn: 185857
* Remove some useless declarations (found by scan-build)Sylvestre Ledru2013-07-061-2/+1
| | | | llvm-svn: 185752
* Teach -Wunsequenced that the side-effects of a function evaluation are sequencedRichard Smith2013-06-301-4/+21
| | | | | | | | | before the value computation of the result. In C, this is implied by there being a sequence point after their evaluation, and in C++, it's implied by the side-effects being sequenced before the expressions and statements in the function body. llvm-svn: 185282
OpenPOWER on IntegriCloud