summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Check format strings when a called function has more than one FormatAttr ↵Ted Kremenek2010-09-091-7/+10
| | | | | | (one for 'scanf' and one for 'printf'). Fixes <rdar://problem/8409437>. llvm-svn: 113472
* It appears that technically a null format string is not warned under ↵Ted Kremenek2010-09-091-0/+7
| | | | | | | | -Wformat-nonliteral, as the function processing the format string can decided whether or not to accept a null format string (e.g., asl_log). Fixes <rdar://problem/8269537>. llvm-svn: 113469
* Avoid redundant recursive calls in SemaCheckStringLiteral by just updating ↵Ted Kremenek2010-09-091-7/+5
| | | | | | | | the expression and trying again. llvm-svn: 113468
* Have Sema check for validity of CGString literalFariborz Jahanian2010-09-071-4/+17
| | | | | | instead of asserting in IRGen. Fixes radar 8390459. llvm-svn: 113253
* Enhance return-stack-address check (in Sema) to handle fields that ↵Ted Kremenek2010-09-021-3/+8
| | | | | | themselves are references. (Fixes PR 7999; fix by Chandler Carruth). llvm-svn: 112792
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-0/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-39/+39
| | | | | | to the new constants. llvm-svn: 112047
* More incremental progress towards not including Expr.h in Sema.h.John McCall2010-08-251-2/+2
| | | | llvm-svn: 112044
* Split FunctionScopeInfo and BlockScopeInfo into their own header.John McCall2010-08-251-0/+2
| | | | llvm-svn: 112038
* Remove Sema.h's dependency on DeclCXX.h.John McCall2010-08-251-0/+1
| | | | llvm-svn: 112032
* Fix printf format string checking for '%lc' (which expects a wint_t or ↵Ted Kremenek2010-08-241-0/+3
| | | | | | compatible argument). Fixes PR 7981. llvm-svn: 111978
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-5/+5
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Generate Attr subclasses with TableGen.Alexis Hunt2010-08-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | Now all classes derived from Attr are generated from TableGen. Additionally, Attr* is no longer its own linked list; SmallVectors or Attr* are used. The accompanying LLVM commit contains the updates to TableGen necessary for this. Some other notes about newly-generated attribute classes: - The constructor arguments are a SourceLocation and a Context&, followed by the attributes arguments in the order that they were defined in Attr.td - Every argument in Attr.td has an appropriate accessor named getFoo, and there are sometimes a few extra ones (such as to get the length of a variadic argument). Additionally, specific_attr_iterator has been introduced, which will iterate over an AttrVec, but only over attributes of a certain type. It can be accessed through either Decl::specific_attr_begin/end or the global functions of the same name. llvm-svn: 111455
* Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()Benjamin Kramer2010-08-171-13/+8
| | | | | | and remove getStrData(). Patch by Peter Davies (with some tweaks). llvm-svn: 111229
* Remove dead code, caught by unused function warnings.Argyrios Kyrtzidis2010-08-151-1/+0
| | | | llvm-svn: 111091
* Zap unused UnaryOperator::OffsetOf.Eli Friedman2010-08-131-1/+0
| | | | llvm-svn: 110996
* Implement -Wcast-align. The initial design of this diagnostic diverges John McCall2010-08-121-0/+45
| | | | | | | | from GCC's in that we warn on *any* increase in alignment requirements, not just those that are enforced by hardware. Please let us know if this causes major problems for you (which it shouldn't, since it's an optional warning). llvm-svn: 110959
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | llvm-svn: 110945
* Random temporary string cleanup.Benjamin Kramer2010-08-111-3/+1
| | | | llvm-svn: 110807
* Store inheritance paths after CastExprs instead of inside them.John McCall2010-08-071-5/+5
| | | | | | | | | | | | | | | This takes some trickery since CastExpr has subclasses (and indeed, is abstract). Also, smoosh the CastKind into the bitfield from Expr. Drops two words of storage from Expr in the common case of expressions which don't need inheritance paths. Avoids a separate allocation and another word of overhead in cases needing inheritance paths. Also has the advantage of not leaking memory, since destructors for AST nodes are never run. llvm-svn: 110507
* Teach SemaChecking::CheckReturnStackAddr about ImplicitCastExprs that ↵Ted Kremenek2010-08-041-3/+15
| | | | | | convert values to an lvalue. This allows us to warn (again) about returning references to stack variables. (fixes PR 7812). llvm-svn: 110242
* Add support for VFP status & control operations for ARM.Nate Begeman2010-08-031-0/+3
| | | | llvm-svn: 110153
* Wire up sema checking for __builtin_arm_usat and __builtin_arm_ssat immediates.Nate Begeman2010-07-291-0/+2
| | | | llvm-svn: 109814
* Revert r109428 "Hoist argument type checking into CheckFormatHandler. This ↵Michael J. Spencer2010-07-271-53/+41
| | | | | | | | is prep for scanf format" Got errors about ASTContext being undefined with Visual Studio 2010. llvm-svn: 109491
* Hoist argument type checking into CheckFormatHandler. This is prep for ↵Ted Kremenek2010-07-261-41/+53
| | | | | | | | scanf format string argument type checking. llvm-svn: 109428
* Consolidate #args checking for scanf/printf format strings.Ted Kremenek2010-07-261-30/+31
| | | | llvm-svn: 109427
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-2/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Vectors are not integer types, so the type system should not classifyDouglas Gregor2010-07-231-5/+5
| | | | | | | | | | | them as such. Type::is(Signed|Unsigned|)IntegerType() now return false for vector types, and new functions has(Signed|Unsigned|)IntegerRepresentation() cover integer types and vector-of-integer types. This fixes a bunch of latent bugs. Patch from Anton Yartsev! llvm-svn: 109229
* Hookup checking for invalid length modifiers in scanf format strings.Ted Kremenek2010-07-201-3/+11
| | | | llvm-svn: 108907
* Add 'ConversionSpecifier' root class in 'analyze_format_string' namespace andTed Kremenek2010-07-201-6/+9
| | | | | | | derived 'PrintfConversionSpecifier' from this class. We will do the same for 'ScanfConversionSpecifier'. llvm-svn: 108903
* Rename 'ConsumedSoFarArg' -> 'nArg' and 'OutIntPtrArg' to 'nArg' (scanf and ↵Ted Kremenek2010-07-201-1/+1
| | | | | | printf checking). llvm-svn: 108900
* Rename diagnostic so that it can be reused with scanf checking. No ↵Ted Kremenek2010-07-201-1/+1
| | | | | | functionality change. llvm-svn: 108896
* Don't warn when a '%%' or '%*d' (scanf) is used in a format string with ↵Ted Kremenek2010-07-191-22/+26
| | | | | | | | positional arguments, since these don't actually consume an argument. llvm-svn: 108757
* Hook up 'invalid conversion' warning for scanf format strings.Ted Kremenek2010-07-191-23/+59
| | | | llvm-svn: 108750
* Fix a goof in my previous patch -- not all of the builtins return a value, someChandler Carruth2010-07-181-1/+7
| | | | | | fixed return types. llvm-svn: 108657
* Improve the representation of the atomic builtins in a few ways. First, we makeChandler Carruth2010-07-181-34/+7
| | | | | | | | | | | | | | | their call expressions synthetically have the "deduced" types based on their first argument. We only insert conversions in the AST for arguments whose values require conversion to match the value type expected. This keeps PR7600 closed by maintaining the return type, but avoids assertions due to unexpected implicit casts making the type unsigned (test case added from Daniel). The magic is moved into the codegen for the atomic builtin which inserts the casts as needed at the IR level to raise the type to an integer suitable for the LLVM intrinsic. This shouldn't cause any real change in functionality, but now we can make the builtin be more truly polymorphic. llvm-svn: 108638
* Hook up warning for an incomplete scanlist in scanf format strings.Ted Kremenek2010-07-161-0/+8
| | | | llvm-svn: 108542
* Add most of the boilerplate support for scanf format string checking. This ↵Ted Kremenek2010-07-161-196/+292
| | | | | | | | | | | | | includes handling the parsing of scanf format strings and hooking the checking into Sema. Most of this checking logic piggybacks on what was already there for checking printf format strings, but the checking logic has been refactored to support both. What is left to be done is to support argument type checking in format strings and of course fix the usual tail of bugs that will follow. llvm-svn: 108500
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-1/+1
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* Rip out the floating point return type handling from the atomic builtin. It'sChandler Carruth2010-07-091-2/+1
| | | | | | | wrong, and we don't handle floating point value type arguments yet anyways. Will add correct logic for both when I finish the patch. llvm-svn: 108004
* Fix PR7600, and correctly convert the result of an atomic builtin to theChandler Carruth2010-07-091-28/+58
| | | | | | | | | expected value type. This is necessary as the builtin is internally represented as only operating on integral types. Also, add a FIXME to add support for floating point value types. llvm-svn: 108002
* improve altivec vector bool/pixel support, patch by Anton YartsevChris Lattner2010-06-231-1/+2
| | | | | | with several tweaks by me. llvm-svn: 106619
* Bug 7377: printf checking fails to flag some undefined behavior Tom Care2010-06-211-15/+16
| | | | | | | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=7377 Updated format string highlighting and fixits to take advantage of the new CharSourceRange class. - Change HighlightRange to allow highlighting whitespace only in a CharSourceRange (for warnings about the ' ' (space) flag) - Change format specifier range helper function to allow for half-open ranges (+1 to end) - Enabled previously failing tests (FIXMEs/XFAILs removed) - Small fixes and additions to format string test cases M test/Sema/format-strings.c M test/Sema/format-strings-fixit.c M lib/Frontend/TextDiagnosticPrinter.cpp M lib/Sema/SemaChecking.cpp llvm-svn: 106480
* Bug 7377: Fixed several bad printf format string bugs.Tom Care2010-06-171-34/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added warning for undefined behavior when using field specifier - Added warning for undefined behavior when using length modifier - Fixed warnings for invalid flags - Added warning for ignored flags - Added fixits for the above warnings - Fixed accuracy of detecting several undefined behavior conditions - Receive normal warnings in addition to security warnings when using %n - Fix bug where '+' flag would remain on unsigned conversion suggestions Summary of changes: - Added expanded tests - Added/expanded warnings - Added position info to OptionalAmounts for fixits - Extracted optional flags to a wrapper class with position info for fixits - Added several methods to validate a FormatSpecifier by component, each checking for undefined behavior - Fixed conversion specifier checking to conform to C99 standard - Added hooks to detect the invalid states in CheckPrintfHandler::HandleFormatSpecifier Note: warnings involving the ' ' (space) flag are temporarily disabled until whitespace highlighting no longer triggers assertions. I will make a post about this on cfe-dev shortly. M test/Sema/format-strings.c M include/clang/Basic/DiagnosticSemaKinds.td M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp M lib/Sema/SemaChecking.cpp llvm-svn: 106233
* Generate arm_neon.inc in include/clang/Basic, which provides:Nate Begeman2010-06-171-276/+6
| | | | | | | | | 1. builtins definitions for BuiltinsARM.def 2. intrinsic validation code for SemaChecking Unsure as to whether this is the best way to handle the make dependencies or not. llvm-svn: 106208
* Remove last of the bool shifts for MS VC++, patch by dimitry andricNate Begeman2010-06-171-8/+8
| | | | llvm-svn: 106206
* Add some missing shiftsNate Begeman2010-06-141-5/+121
| | | | | | | | Fix multiplies by scalar Add SemaChecking code for all immediates Add SemaChecking-gen support to arm_neon.td llvm-svn: 105930
* Most of NEON sema checking & fix to polynomial type detectionNate Begeman2010-06-131-16/+222
| | | | llvm-svn: 105908
* Added FixIt support to printf format string checking.Tom Care2010-06-091-5/+27
| | | | | | | | | | | | | | | | - Refactored LengthModifier to be a class. - Added toString methods in all member classes of FormatSpecifier. - FixIt suggestions keep user specified flags unless incorrect. Limitations: - The suggestions are not conversion specifier sensitive. For example, if we have a 'pad with zeroes' flag, and the correction is a string conversion specifier, we do not remove the flag. Clang will warn us on the next compilation. A test/Sema/format-strings-fixit.c M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp M lib/Sema/SemaChecking.cpp llvm-svn: 105680
* Implement transpose/zip/unzip & table lookup.Nate Begeman2010-06-091-1/+22
| | | | | | Test out some basic constant-checking. llvm-svn: 105667
OpenPOWER on IntegriCloud