summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Since the enum values for each arch's builtins overlap, it is not ↵Nate Begeman2010-06-081-4/+33
| | | | | | appropriate to check them when compiling or other archs. Fixes a problem where compiling for NEON would use x86 sema rules. llvm-svn: 105593
* Extend __builtin_shufflevector to expose the full power of the llvm ↵Nate Begeman2010-06-081-28/+38
| | | | | | shufflevector instruction. This means it can now be used for vector truncation and concatenation. This will be used for the ARM NEON implementation. llvm-svn: 105589
* Preserve more information from a block's original function declarator, if oneJohn McCall2010-06-041-1/+1
| | | | | | | was given. Remove some unnecessary accounting from BlockScopeInfo. Handle typedef'ed function types until such time as we decide not. llvm-svn: 105478
* Tell the string literal parser when it's not permitted to emitDouglas Gregor2010-05-261-2/+3
| | | | | | | | diagnostics. That would be while we're parsing string literals for the sole purpose of producing a diagnostic about them. Fixes <rdar://problem/8026030>. llvm-svn: 104684
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-130/+256
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* optimize builtin_isnan/isinf to not do an extraneous extension fromChris Lattner2010-05-061-1/+14
| | | | | | | float -> double (which happens because they are modelled as int(...) functions), and add a testcase for isinf. llvm-svn: 103167
* Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ↵Ted Kremenek2010-04-291-8/+3
| | | | | | | | ObjCMethodDecl::isVariadic(). Do some minor refactoring along the way. llvm-svn: 102635
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-1/+2
| | | | llvm-svn: 102259
* isValue is set to false by default.Anders Carlsson2010-04-241-2/+1
| | | | llvm-svn: 102246
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-1/+2
| | | | llvm-svn: 102218
* Remove the argument number from the constant integer diagnostic.Eric Christopher2010-04-191-1/+1
| | | | | | Update all of the testcases accordingly. llvm-svn: 101795
* Consolidate most of the integer constant expression builtin requirementEric Christopher2010-04-171-68/+50
| | | | | | | | checking into a single function and use that throughout. Remove some now unnecessary diagnostics and update tests with now more accurate diagnostics. llvm-svn: 101610
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-3/+1
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
OpenPOWER on IntegriCloud