summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* IsTailPaddedMemberArray uses a FieldDecl'sSean Callanan2012-05-041-5/+9
| | | | | | | | | | | | | getTypeSourceInfo() without checking for NULL. FieldDecls may have NULL TypeSourceInfo, and in fact some FieldDecls generated by Clang -- and all FieldDecls generated by LLDB -- have no TypeSourceInfo. This patch makes IsTailPaddedMemberArray check for NULL. llvm-svn: 156186
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-1/+1
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* Fix handling of wint_t - we can't assume wint_t is purely an integer ↵James Molloy2012-05-041-1/+2
| | | | | | | | | | | | promotion of wchar_t - they may differ in signedness. Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned. There'll be a followup commit to fix that. Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8 llvm-svn: 156165
* Disable -Wformat-extra-args for arguments defined in system headers.Bob Wilson2012-05-031-3/+6
| | | | | | | | | | | | | Some of the NSAssert macros in OS X 10.7 are implemented in a way that adds extra arguments that trigger the -Wformat-extra-args warning. Earlier versions of clang failed to detect those -Wformat issues, but now that clang is reporting those problems, we need to quiet them since there's nothing to be done to fix them. <rdar://problem/11317765> I don't know how to write a testcase for this. Suggestions welcome. Patch by Ted Kremenek! llvm-svn: 156092
* Turn the mixed-sign-comparison diagnostic into a runtime behaviorDouglas Gregor2012-05-011-3/+4
| | | | | | diagnostic, from Eitan Adler! llvm-svn: 155876
* When going through references to check if the function returns the addressArgyrios Kyrtzidis2012-04-301-24/+34
| | | | | | | | | | | | | | | | of a local variable, make sure we don't infinitely recurse when the reference binds to itself. e.g: int* func() { int& i = i; // assign non-exist variable to a reference which has same name. return &i; // return pointer } rdar://11345441 llvm-svn: 155856
* Add FixItHint for -Wnull-conversion to initialize with an appropriate literal.David Blaikie2012-04-301-1/+2
| | | | | | Reviewed by Doug Gregor. llvm-svn: 155839
* Currently __builtin_annotation() only annotates an i32.Julien Lerouge2012-04-281-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | i32 __builtin_annotation(i32, string); Applying it to i64 (e.g., long long) generates the following IR. trunc i64 {{.*}} to i32 call i32 @llvm.annotation.i32 zext i32 {{.*}} to i64 The redundant truncation and extension make the result difficult to use. This patch makes __builtin_annotation() generic. type __builtin_annotation(type, string); For the i64 example, it simplifies the generated IR to: call i64 @llvm.annotation.i64 Patch by Xi Wang! llvm-svn: 155764
* Implement __atomic_fetch_nand and __atomic_nand_fetch to complete our set ofRichard Smith2012-04-131-0/+2
| | | | | | GNU __atomic builtins. llvm-svn: 154659
* Warn on 64-to-32 for source value of x bits where 64 >= x > 32.David Blaikie2012-04-121-1/+1
| | | | | | | | | The codepath already only works for source bits > target bits, it's just that it was testing for the source expr bits to be exactly 64. This meant simple cases (int i = x_long / 2) were missed & ended up under the general -Wconversion warning, which a user might not have enabled. llvm-svn: 154626
* Implement support for 18 of the GNU-compatible __atomic builtins.Richard Smith2012-04-121-98/+212
| | | | | | | | | | | | This is not quite sufficient for libstdc++'s <atomic>: we still need __atomic_test_and_set and __atomic_clear, and may need a more complete __atomic_is_lock_free implementation. We are also missing an implementation of __atomic_always_lock_free, __atomic_nand_fetch, and __atomic_fetch_nand, but those aren't needed for libstdc++. llvm-svn: 154579
* Provide, and document, a set of __c11_atomic_* intrinsics to implement C11'sRichard Smith2012-04-111-5/+16
| | | | | | | | | <stdatomic.h> header. In passing, fix LanguageExtensions to note that C11 and C++11 are no longer "upcoming standards" but are now actually standardized. llvm-svn: 154513
* Remove dead assignment to local variable.Ted Kremenek2012-04-041-1/+0
| | | | llvm-svn: 153985
* Pass parameters in the correct order when assembling an AtomicExpr.David Chisnall2012-03-291-1/+1
| | | | llvm-svn: 153665
* Suppress macro expansion of NULL in NULL warnings.David Blaikie2012-03-161-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For "int i = NULL;" we would produce: null.cpp:5:11: warning: implicit conversion of NULL constant to integer [-Wconversion] int i = NULL; ~ ^~~~ null.cpp:1:14: note: expanded from macro 'NULL' \#define NULL __null ^~~~~~ But we really shouldn't trace that macro expansion back into the header, yet we still want macro back traces for code like this: \#define FOO NULL int i = FOO; or \#define FOO int i = NULL; FOO While providing appropriate tagging at different levels of the expansion, etc. The included test case exercises these cases & does some basic validation (to ensure we don't have macro expansion notes where we shouldn't, and do where we should) - but doesn't go as far as to validate the source location/ranges used in those notes and warnings. llvm-svn: 152940
* Provide the specific target type in the -Wnull-conversion warning.David Blaikie2012-03-151-1/+1
| | | | llvm-svn: 152835
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-10/+10
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-11/+1
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* -Wformat-non-iso: warn about positional arguments (pr12017)Hans Wennborg2012-03-091-2/+12
| | | | | | | | | This renames the -Wformat-non-standard flag to -Wformat-non-iso, rewords the current warnings a bit (pointing out that a format string is not supported by ISO C rather than being "non standard"), and adds a warning about positional arguments. llvm-svn: 152403
* Fix a couple bugs in the way we handle array indexes in array bounds ↵Eli Friedman2012-02-271-4/+4
| | | | | | checking. Specifically, make sure we don't ignore explicit casts in indexes, and make sure we use unsigned extension/comparisons on indexes. Fixes <rdar://problem/10916006>. llvm-svn: 151569
* Modernize some code which processes CastExprs to use CastKinds. No intended ↵Eli Friedman2012-02-231-29/+21
| | | | | | functional change. llvm-svn: 151298
* 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
OpenPOWER on IntegriCloud