summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Add sizeof diagnostics for bzeroBruno Cardoso Lopes2016-08-041-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | For memset (and others) we can get diagnostics like: struct stat { int x; }; void foo(struct stat *stamps) { bzero(stamps, sizeof(stamps)); memset(stamps, 0, sizeof(stamps)); } t.c:7:28: warning: 'memset' call operates on objects of type 'struct stat' while the size is based on a different type 'struct stat *' [-Wsizeof-pointer-memaccess] memset(stamps, 0, sizeof(stamps)); ~~~~~~ ^~~~~~ t.c:7:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)? memset(stamps, 0, sizeof(stamps)); ^~~~~~ This patch implements the same class of warnings for bzero. Differential Revision: https://reviews.llvm.org/D22525 rdar://problem/18963514 llvm-svn: 277787
* [X86] Block pbroadcastq instructions on 32-bit targets instead of pbroadcastb.Craig Topper2016-07-241-3/+3
| | | | | | Thanks to Simon Pilgrim for catching the mistake. llvm-svn: 276564
* [Sema,X86] Add explicit check to ensure that builtins that require x86-64 ↵Craig Topper2016-07-211-0/+50
| | | | | | | | | | target throw an error if used on 32-bit target. If these builtins are allowed to go through on a 32-bit target they will fire assertions in the backend. Fixes PR28635. llvm-svn: 276250
* [Sema] Fix PR28623.George Burgess IV2016-07-211-1/+5
| | | | | | | | | | | | | | | In atomic builtins, we assumed that the LValue conversion on the first argument would succeed. So, we would crash given code like: ``` void ovl(char); void ovl(int); __atomic_store_n(ovl, 0, 0); ``` This patch makes us not assume that said conversion is successful. :) llvm-svn: 276232
* [NFC] Header cleanupMehdi Amini2016-07-181-3/+2
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Reverting 275417Roger Ferrer Ibanez2016-07-141-67/+0
| | | | | | This change has triggered unexpected failures. llvm-svn: 275462
* Diagnose taking address and reference binding of packed membersRoger Ferrer Ibanez2016-07-141-0/+67
| | | | | | | | | | | | | | | | | | | | | | | This patch implements PR#22821. Taking the address of a packed member is dangerous since the reduced alignment of the pointee is lost. This can lead to memory alignment faults in some architectures if the pointer value is dereferenced. This change adds a new warning to clang emitted when taking the address of a packed member. A packed member is either a field/data member declared as attribute((packed)) or belonging to a struct/class declared as such. The associated flag is -Waddress-of-packed-member. Conversions (either implicit or via a valid casting) to pointer types with lower or equal alignment requirements (e.g. void* or char*) silence the warning. This change also adds a new error diagnostic when the user attempts to bind a reference to a packed member, regardless of the alignment. Differential Revision: https://reviews.llvm.org/D20561 llvm-svn: 275417
* [AVX512] Remove masked shufps/shudpd builtins. These are all handled with ↵Craig Topper2016-07-101-6/+0
| | | | | | __builtin_shufflevector. llvm-svn: 275018
* [X86] Remove dead builtins that don't exist in the backend intrinsic file ↵Craig Topper2016-07-081-1/+0
| | | | | | and don't have custom handling in CGBuiltins.cpp either. llvm-svn: 274825
* Ensuring the bit-fields have the same type; MSVC will place the fields in ↵Aaron Ballman2016-07-061-1/+1
| | | | | | different allocation units otherwise. llvm-svn: 274654
* [OpenCL] An implementation of device side enqueue (DSE) from OpenCL v2.0 ↵Anastasia Stulova2016-07-051-11/+253
| | | | | | | | | | | | | | | | | s6.13.17. - Added new Builtins: enqueue_kernel, get_kernel_work_group_size and get_kernel_preferred_work_group_size_multiple. These Builtins use custom check to diagnose parameters of the passed Blocks i. e. variable number of 'local void*' type params, and check different overloads specified in Table 6.31 of OpenCL v2.0. - IR is generated as an internal library call for each OpenCL Builtin, reusing ObjC Block implementation. Review: http://reviews.llvm.org/D20249 llvm-svn: 274540
* [AVX512] Remove VPERMD/VPERMQ/VPERMILPS/VPERMILPD builtins. These were made ↵Craig Topper2016-07-041-6/+0
| | | | | | unused in r274492 and r274502. llvm-svn: 274516
* [OpenCL] Make OpenCL Builtins added according to the right version.Anastasia Stulova2016-07-041-8/+2
| | | | | | | | | | Currently we only have OpenCL 2.0 Builtins i.e. pipes or address space conversions. They have to be added only in the version 2.0 compilation mode to make the identifiers available for use in the other versions. Review: http://reviews.llvm.org/D20249 llvm-svn: 274509
* [X86] Replace 128-bit and 256 masked vpermilps/vpermilpd builtins with ↵Craig Topper2016-07-021-4/+0
| | | | | | native IR. llvm-svn: 274425
* [AVX512][BUILTIN][vpermilps][intrinsics] Fixing two incorrect IMM check.Michael Zuckerman2016-06-301-3/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D21836 llvm-svn: 274224
* Use even more ArrayRefsDavid Majnemer2016-06-241-4/+4
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273650
* Use more ArrayRefsDavid Majnemer2016-06-241-5/+2
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Use ranges to concisely express iterationDavid Majnemer2016-06-231-5/+4
| | | | | | | No functional change is intended, this should just clean things up a little. llvm-svn: 273522
* Apply some suggestions from clang-tidy's performance-unnecessary-value-param.Benjamin Kramer2016-06-151-19/+14
| | | | | | No functionality change intended. llvm-svn: 272789
* Add a "declared 'nonnull' here" note to warnings where an expression is ↵Nick Lewycky2016-06-151-7/+9
| | | | | | checked against null. llvm-svn: 272755
* [AVX512] Implement masked and 512-bit pshufd intrinsics directly with ↵Craig Topper2016-06-111-3/+0
| | | | | | __builtin_shufflevector and __builtin_ia32_select. llvm-svn: 272467
* [AVX512] Implement 512-bit and masked shufflelo and shufflehi intrinsics ↵Craig Topper2016-06-111-6/+0
| | | | | | directly with __builtin_shufflevector and __builtin_ia32_select. Also improve the formatting of the AVX2 version. llvm-svn: 272452
* [OpenCL] Add to_{global|local|private} builtin functions.Yaxun Liu2016-05-201-0/+52
| | | | | | | | | | | | | | | | | | OpenCL builtin functions to_{global|local|private} accepts argument of pointer type to arbitrary pointee type, and return a pointer to the same pointee type in different addr space, i.e. global gentype *to_global(gentype *p); It is not desirable to declare it as global void *to_global(void *); in opencl header file since it misses diagnostics. This patch implements these builtin functions as Clang builtin functions. In the builtin def file they are defined to have signature void*(void*). When handling call expressions, their declarations are re-written to have correct parameter type and return type corresponding to the call argument. In codegen call to addr void *to_addr(void*) is generated with addrcasts or bitcasts to facilitate implementation in builtin library. Differential Revision: http://reviews.llvm.org/D19932 llvm-svn: 270261
* [Sema,CodeGen] Remove comment from SemaChecking about a ↵Craig Topper2016-05-181-2/+1
| | | | | | | | builtin_shufflevector form that it doesn't support. Remove CodeGen support for the same form since it could never have been used due to the missing support in Sema. I couldn't find any documentation that this form existed either. Nor is there documentation for one of the remaining two forms, but there is a testcase that uses it. llvm-svn: 269879
* [X86] Add immediate range checks for many of the builtins.Craig Topper2016-05-181-33/+241
| | | | | | This time allow -128 to 255 for builtins that use a char type immediate." llvm-svn: 269878
* Revert "[X86] Add immediate range checks for many of the builtins."Filipe Cabecinhas2016-05-171-234/+32
| | | | | | This reverts commit r269619. llvm-svn: 269765
* [X86] Add immediate range checks for many of the builtins.Craig Topper2016-05-151-32/+234
| | | | llvm-svn: 269619
* Improve diagnostic checking for va_start to also warn on other instances of ↵Aaron Ballman2016-04-241-3/+10
| | | | | | | | undefined behavior, such as a parameter declared with the register keyword in C, or a parameter of a type that undergoes default argument promotion. This helps cover some more of the CERT secure coding rule EXP58-CPP. Pass an object of the correct type to va_start (https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start). llvm-svn: 267338
* Revert the bool portion of r267054Richard Trieu2016-04-221-12/+4
| | | | | | | Remove the floating point to bool conversion warnings. Some of these conversions will be caught by -Wliteral-conversion and -Wfloat-conversion llvm-svn: 267234
* Split interesting warnings off from -Wfloat-conversionRichard Trieu2016-04-211-27/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restructure the implict floating point to integer conversions so that interesting sub-groups are under different flags. Breakdown of warnings: No warning: Exact conversions from floating point to integer: int x = 10.0; int x = 1e10; -Wliteral-conversion - Floating point literal to integer with rounding: int x = 5.5; int x = -3.4; -Wfloat-conversion - All conversions not covered by the above two: int x = GetFloat(); int x = 5.5 + 3.5; -Wfloat-zero-conversion - The expression converted has a non-zero floating point value that gets converted to a zero integer value, excluded the cases falling under -Wliteral-conversion. Subset of -Wfloat-conversion. int x = 1.0 / 2.0; -Wfloat-overflow-conversion - The floating point value is outside the range of the integer type, exluding cases from -Wliteral conversion. Subset of -Wfloat-conversion. char x = 500; char x = -1000; -Wfloat-bool-conversion - Any conversion of a floating point type to bool. Subset of -Wfloat-conversion. if (GetFloat()) {} bool x = 5.0; -Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable floating point value to bool. Subset of -Wfloat-bool-conversion. bool x = 1.0; bool x = 4.0 / 20.0; Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but for floating point values. llvm-svn: 267054
* Clarifying the wording of this diagnostic; it confused parameter and argument.Aaron Ballman2016-04-181-1/+1
| | | | llvm-svn: 266644
* NFC: unify clang / LLVM atomic orderingJF Bastien2016-04-181-7/+7
| | | | | | | | | | | | | This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM, as discussed in http://reviews.llvm.org/D18200#inline-151433 This re-applies r266574 which I had reverted in r266575. Depends on http://reviews.llvm.org/D18875 Original review: http://reviews.llvm.org/D18876 llvm-svn: 266641
* Revert "NFC: unify clang / LLVM atomic ordering"JF Bastien2016-04-171-7/+7
| | | | | | | | This reverts commit b0495df9eae2824bee830cc4c94f5441f0d4cbc9. Same as for the corresponding LLVM revert, an assert seems to fire. llvm-svn: 266575
* NFC: unify clang / LLVM atomic orderingJF Bastien2016-04-171-7/+7
| | | | | | | | | | | | | | | Summary: Depends on http://reviews.llvm.org/D18875 This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM, as discussed in http://reviews.llvm.org/D18200#inline-151433 Reviewers: jyknight, reames Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18876 llvm-svn: 266574
* AArch64: allow 64-bit access to sysregs.Tim Northover2016-04-131-1/+1
| | | | | | | | Although all the registers are actually 32-bits, I think we have to assume the high 32-bits could be RES0 (the ARM ARM is unclear). If so, reading as a 32-bit register can require extra zero extension operations. llvm-svn: 266212
* Fix -Wdynamic-class-memaccess to skip invalid classes.Richard Trieu2016-03-311-1/+1
| | | | | | | | | This warning sometimes will infinitely recurse on CXXRecordDecl's from ill-formed recursive classes that have fields of themselves. Skip processing these classes to prevent this from happening. Fixes https://llvm.org/bugs/show_bug.cgi?id=27142 llvm-svn: 264991
* Fix deduction of __atomic_load's parameter types.Eric Fiselier2016-03-301-10/+13
| | | | | | | | | | | | | | Summary: __atomic_load's allows it's first argument to be a pointer to a const type. However the second argument is an output parameter and must be a pointer to non-const. This patch fixes the signature of __atomic_load generated by clang so that it respects the above requirements. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13420 llvm-svn: 264967
* [OpenCL] Fix pipe builtin bugsXiuli Pan2016-03-301-6/+8
| | | | | | | | | | | | | | | Summary: 1. Diag should be output if types are not the same. 2. Should compare using canonical type. 3. Refine the diag to be more clear. Reviewers: yaxunl, Anastasia Subscribers: MatsPetersson, pekka.jaaskelainen, cfe-commits Differential Revision: http://reviews.llvm.org/D17955 llvm-svn: 264825
* [Sema] Handle UTF-8 invalid format string specifiersBruno Cardoso Lopes2016-03-291-6/+37
| | | | | | | | | | | | | | | | | Improve invalid format string specifier handling by printing out invalid specifiers characters with \x, \u and \U. Previously clang would print gargabe whenever the character is unprintable. Example, before: NSLog(@"%\u25B9"); => warning: invalid conversion specifier ' [-Wformat-invalid-specifier] after: NSLog(@"%\u25B9"); => warning: invalid conversion specifier '\u25b9' [-Wformat-invalid-specifier] Differential Revision: http://reviews.llvm.org/D18296 rdar://problem/24672159 llvm-svn: 264752
* Move the fixit for -Wformat-security to a note.Bob Wilson2016-03-151-5/+6
| | | | | | | | r263299 added a fixit for the -Wformat-security warning, but that runs into complications with our guideline that error recovery should be done as-if the fixit had been applied. Putting the fixit on a note avoids that. llvm-svn: 263584
* Add fix-it for format-security warnings.Bob Wilson2016-03-111-9/+21
| | | | llvm-svn: 263299
* [OpenCL] Refine pipe builtin supportXiuli Pan2016-03-041-44/+52
| | | | | | | | | | | | | | Summary: Refine the type builtin support as the request with http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160201/148637.html Reviewers: pekka.jaaskelainen, Anastasia, yaxunl Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D16876 llvm-svn: 262692
* Reduce false positives in printf/scanf format checkerAndy Gibbs2016-02-261-34/+145
| | | | | | | | | | | | | | | Summary: The printf/scanf format checker is a little over-zealous in handling the conditional operator. This patch reduces work by not checking code-paths that are never used and reduces false positives regarding uncovered arguments, for example in the code fragment: printf(minimal ? "%i\n" : "%i: %s\n", code, msg); Reviewers: rtrieu Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15636 llvm-svn: 262025
* [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttrXiuli Pan2016-02-261-6/+4
| | | | | | | | | | | | | | | Summary: OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading, Add semacheck for OpenCL access qualifier as well as test caees. Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D16040 llvm-svn: 261961
* Make Sema::CheckFormatString a static function inside SemaChecking.cppAndy Gibbs2016-02-221-31/+46
| | | | | | | No functionality change. Change at the request of Richard Trieu, see http://reviews.llvm.org/D15636#357858. llvm-svn: 261522
* Remove use of builtin comma operator.Richard Trieu2016-02-181-9/+42
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* Sema: prevent assertion on stack return checkingSaleem Abdulrasool2016-02-151-2/+4
| | | | | | | | | | | | | | In the case that the array indexing itself is within a type dependent context, bail out of the evaluation. We would previously try to symbolically evaluate the expression which would then try to evaluate a non-address expression as an address, triggering an assertion in Asserts builds. We only need to consider the array subscript expression itself as in the case that the base itself being type dependent is handled appropriately in EvalAddr. Resolves PR26599. llvm-svn: 260867
* Sema: constify EvalAddr, EvalValSaleem Abdulrasool2016-02-151-139/+146
| | | | | | | Propagate const throughout these methods as they are non-mutating analyzers of state. NFC. llvm-svn: 260864
* Make -Wnull-conversion more useful.Richard Trieu2016-02-131-7/+14
| | | | | | | | | | When a null constant is used in a macro, walk through the macro stack to determine where the null constant is written and where the context is located. Only warn if both locations are within the same macro expansion. This helps function-like macros which involve pointers be treated as if they were functions. llvm-svn: 260776
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-121-92/+62
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
OpenPOWER on IntegriCloud