summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Warn about non-standard format strings (pr12017)Hans Wennborg2012-02-221-2/+60
| | | | | | | | | This adds the -Wformat-non-standard flag (off by default, enabled by -pedantic), which warns about non-standard things in format strings (such as the 'q' length modifier, the 'S' conversion specifier, etc.) llvm-svn: 151154
* Generate an AST for the conversion from a lambda closure type to aDouglas Gregor2012-02-221-3/+5
| | | | | | | | | | | | | | | block pointer that returns a block literal which captures (by copy) the lambda closure itself. Some aspects of the block literal are left unspecified, namely the capture variable (which doesn't actually exist) and the body (which will be filled in by IRgen because it can't be written as an AST). Because we're switching to this model, this patch also eliminates tracking the copy-initialization expression for the block capture of the conversion function, since that information is now embedded in the synthesized block literal. -1 side tables FTW. llvm-svn: 151131
* When calling a non variadic format function(vprintf, vscanf, NSLogv, …), ↵Jean-Daniel Dupas2012-02-211-7/+21
| | | | | | warn if the format string argument is a parameter that is not itself declared as a format string with compatible format. llvm-svn: 151080
* Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg2012-02-151-2/+4
| | | | | | | | | | | | | | | | | This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType() only fix a conversion specification enough that Clang wouldn't warn about it, as opposed to always changing it to use the "canonical" conversion specifier. (PR11975) This preserves the user's choice of conversion specifier in cases like: printf("%a", (long double)1); where we previously suggested "%Lf", we now suggest "%La" printf("%x", (long)1); where we previously suggested "%ld", we now suggest "%lx". llvm-svn: 150578
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-141-0/+127
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Support all null pointer literals in format strings.David Blaikie2012-02-101-8/+7
| | | | llvm-svn: 150276
* Enhance checking for null format string literal to take into account __null. ↵Ted Kremenek2012-02-101-0/+1
| | | | | | Fixes <rdar://problem/8269537>. llvm-svn: 150260
* Implement return type deduction for lambdas per C++11Douglas Gregor2012-02-091-1/+1
| | | | | | | | | [expr.prim.lambda]p4, including the current suggested resolution of core isue 975, which allows multiple return statements so long as the types match. ExtWarn when user code is actually making use of this extension. llvm-svn: 150168
* Various interrelated cleanups for lambdas:Douglas Gregor2012-02-091-1/+4
| | | | | | | | | | | | | | - Complete the lambda class when we finish the lambda expression (previously, it was left in the "being completed" state) - Actually return the LambdaExpr object and bind to the resulting temporary when needed. - Detect when cleanups are needed while capturing a variable into a lambda (e.g., due to default arguments in the copy constructor), and make sure those cleanups apply for the whole of the lambda expression. llvm-svn: 150123
* non-literal strftime format string is not unsafe.Jean-Daniel Dupas2012-02-071-0/+5
| | | | llvm-svn: 150009
* Implements support of format_arg attribute on C++ member.Jean-Daniel Dupas2012-02-071-19/+14
| | | | llvm-svn: 149998
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-4/+4
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Do not show macro expansion in strncat warnings, which can be defined asAnna Zaks2012-02-031-7/+16
| | | | | | a builtin. llvm-svn: 149657
* Change the check for constant-conversion with width-1 bitfields so it ↵Eli Friedman2012-02-021-2/+2
| | | | | | doesn't suppress quite as many cases. Based off a testcase in the gcc testsuite. llvm-svn: 149572
* Add a new compiler warning, which flags anti-patterns used as the sizeAnna Zaks2012-02-011-4/+109
| | | | | | | | | | | argument in strncat. The warning is ignored by default since it needs more qualification. TODO: The warning message and the note are messy when strncat is a builtin due to the macro expansion. llvm-svn: 149524
* Revert r149359. This was a hack to a problem with an easy workaround, and ↵Ted Kremenek2012-01-311-14/+4
| | | | | | it doesn't feel like general solution. llvm-svn: 149404
* FormatCheckers should emit all diagnostics using EmitFormatDiagnostic().Jean-Daniel Dupas2012-01-311-15/+21
| | | | llvm-svn: 149394
* Don't warn about -Wshorten-64-to-32 in unreachable code. Fixes ↵Ted Kremenek2012-01-311-4/+14
| | | | | | <rdar://problem/10759934>. Apparently this is a common idiom in Linux (among other places). llvm-svn: 149359
* Make a bunch of local functions 'static'.Ted Kremenek2012-01-311-22/+23
| | | | llvm-svn: 149358
* Let %S, %ls, %C match 16bit types in NSStrings.Nico Weber2012-01-311-1/+2
| | | | | | As discussed at http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120130/052200.html llvm-svn: 149325
* Disable "non literal format string" for NSString that result from a macro ↵Jean-Daniel Dupas2012-01-301-0/+7
| | | | | | | | | expansion. This is to prevent diagnostic when using NSLocalizedString or CFCopyLocalizedString macros which are usually used in place of NS and CF strings literals. llvm-svn: 149268
* Update on format attribute handling.Jean-Daniel Dupas2012-01-301-58/+40
| | | | | | | - Remove the printf0 special handling as we treat it as printf anyway. - Perform basic checks (non-literal, empty) for all formats and not only printf/scanf. llvm-svn: 149236
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-0/+1
| | | | llvm-svn: 149127
* Turn off implicit truncation warning for compound assignment to bitfields; ↵Eli Friedman2012-01-261-2/+2
| | | | | | | | it might be reasonable in some cases, but it clearly doesn't make sense in some cases, like the included testcase. <rdar://problem/10238797>, part 2. llvm-svn: 149095
* Make the bitfield implicit truncation warning slightly more aggressive, and ↵Eli Friedman2012-01-261-8/+9
| | | | | | make the printed warning a bit more accurate. The new behavior matches gcc's -Wconversion. <rdar://problem/10238797>. llvm-svn: 149089
* Add support for const pointer to literal-objc string as format attribute.Jean-Daniel Dupas2012-01-251-0/+4
| | | | llvm-svn: 148948
* Add "multiple format attributes" support on block.Jean-Daniel Dupas2012-01-251-6/+6
| | | | llvm-svn: 148890
* Make sure the AST correctly represents lvalue-to-rvalue conversions where ↵Eli Friedman2012-01-231-0/+6
| | | | | | appropriate. llvm-svn: 148673
* objc-arc: when 'assign' attribute is unspecified,Fariborz Jahanian2012-01-171-4/+24
| | | | | | | | rely on property's type for its life-time to avoid bogus warning with -Warc-unsafe-retained-assign. // rdar://10694932 llvm-svn: 148355
* Fix a couples of issues in format strings checking.Jean-Daniel Dupas2012-01-171-73/+96
| | | | | | | PR 10274: format function attribute with the NSString archetype yields no compiler warnings PR 10275: format function attribute isn't checked in Objective-C methods llvm-svn: 148324
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-2/+2
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Use Builtin ID as the return valueAnna Zaks2012-01-171-18/+30
| | | | | | | | | | for FunctionDecl::getMemoryFunctionKind(). This is a follow up on the Chris's review for r148142: We don't want to pollute FunctionDecl with an extra enum. (To make this work, added memcmp and family to the library builtins.) llvm-svn: 148267
* Some improvements to the handling of C11 atomic types:David Chisnall2012-01-161-1/+7
| | | | | | | | | | | | | | | | | | - Add atomic-to/from-nonatomic cast types - Emit atomic operations for arithmetic on atomic types - Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load - Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function. - Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it. Still to do: - Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg. - Add a signal fence builtin - Properly set the fenv state in atomic operations on floating point values - Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context) - Fix the many remaining corner cases llvm-svn: 148242
* Move identification of memory setting and copying functions (memset,Anna Zaks2012-01-131-88/+20
| | | | | | | memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic could be reused in the analyzer. llvm-svn: 148142
* objc-arc: fixes a crash when trying to find out retaining cycleFariborz Jahanian2012-01-101-4/+12
| | | | | | ownership of property sent to 'super'. // rdar://10640891 llvm-svn: 147868
* Suppress -Wunused-value within macros from system headers.Matt Beaumont-Gay2012-01-061-13/+8
| | | | | | | Along the way, move a helper function from SemaChecking.cpp to a more accessible home in SourceManager. llvm-svn: 147692
* Add an APValue representation for the difference between two ↵Eli Friedman2012-01-041-1/+1
| | | | | | | | | | address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer. With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary. Fixes PR11705. llvm-svn: 147561
* Small refactoring and simplification of constant evaluation and some of itsRichard Smith2011-12-281-4/+2
| | | | | | clients. No functionality change. llvm-svn: 147318
* PR11594: Don't blindly build a UnaryOperator UO_Minus on an expression whichRichard Smith2011-12-161-1/+3
| | | | | | | might not be an rvalue when checking array accesses. Instead, pass through a flag indicating the array index is negated. llvm-svn: 146753
* Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg2011-12-151-2/+4
| | | | | | | | | extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). llvm-svn: 146649
* Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning ↵Eli Friedman2011-12-151-1/+1
| | | | | | in the case of a shifted bitfield. PR11572. llvm-svn: 146634
* r146430 lost some compile-time performance on ↵Matt Beaumont-Gay2011-12-141-19/+24
| | | | | | MultiSource/Benchmarks/MiBench/security-rijndael; this gets most of it back. llvm-svn: 146562
* Suppress -Warray-bounds in certain cases involving macros from system headers.Matt Beaumont-Gay2011-12-121-1/+11
| | | | | | The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large. llvm-svn: 146430
* Check that arguments to a scanf call match the format specifier,Hans Wennborg2011-12-101-2/+32
| | | | | | and offer fixits when there is a mismatch. llvm-svn: 146326
* Add notes for suppressing and (if it's a zero-arg function returning bool) ↵David Blaikie2011-12-091-0/+10
| | | | | | fixing the function-to-bool conversion warning. llvm-svn: 146280
* Make printf warnings refer to wint_t and wchar_t by nameHans Wennborg2011-12-091-3/+0
| | | | | | in addition to underlying type. llvm-svn: 146254
* Make printf warnings refer to intmax_t et al. by nameHans Wennborg2011-12-071-3/+3
| | | | | | | | | | | | in addition to underlying type. For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" (This is a second attempt after r145697, which got reverted.) llvm-svn: 146032
* Switch a cast to a dyn_cast and check the pointer before using. Fixes a crashRichard Trieu2011-12-061-4/+5
| | | | | | | | | | in the following code: void test4(bool (&x)(void)) { while (x); } llvm-svn: 145918
* Add a warning for implicit conversion from function literals (and staticLang Hames2011-12-051-0/+19
| | | | | | | | | | | | | methods) to bool. E.g. void foo() {} if (f) { ... // <- Warns here. } Only applies to non-weak functions, and does not apply if the function address is taken explicitly with the addr-of operator. llvm-svn: 145849
OpenPOWER on IntegriCloud