summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Format string checking: selectively ignore implicit casts to 'int'Ted Kremenek2010-02-011-6/+17
| | | | | | | | when checking if the format specifier matches the type of the data argument and the length modifier indicates the data type is 'char' or 'short'. llvm-svn: 94992
* Fix for PR5185. C99 [*] VLA notation should be disallowed in function ↵Sam Weinig2010-02-011-0/+14
| | | | | | definitions. llvm-svn: 94972
* Add basic type checking of format string conversion specifiers and their ↵Ted Kremenek2010-01-301-6/+63
| | | | | | arguments. Thanks to Cristian Draghici for his help with this patch! llvm-svn: 94864
* Be a little more permissive than C99: allow 'unsigned' to be used forTed Kremenek2010-01-291-2/+6
| | | | | | | the field width and precision of a format specifier instead of just 'int'. This matches GCC, and fixes <rdar://problem/6079850>. llvm-svn: 94856
* Switch Sema over to using the new implementation of format stringTed Kremenek2010-01-291-268/+39
| | | | | | | | | checking. It passes all existing tests, and the diagnostics have been refined to provide better range information (we now highlight individual format specifiers) and more precise wording in the diagnostics. llvm-svn: 94837
* Alternate format string checking: issue warnings for incomplete format ↵Ted Kremenek2010-01-291-12/+19
| | | | | | | | | | specifiers. In addition, move ParseFormatString() and FormatStringHandler() from the clang::analyze_printf to the clang namespace. Hopefully this will resolve some link errors on Linux. llvm-svn: 94794
* Alternate format string checking: issue a warning for invalid conversion ↵Ted Kremenek2010-01-291-8/+27
| | | | | | specifiers. llvm-svn: 94792
* Alternate format string checking: check for excess data arguments.Ted Kremenek2010-01-291-0/+11
| | | | llvm-svn: 94787
* Alternate format string checking: check if the number of format specifiers ↵Ted Kremenek2010-01-291-0/+12
| | | | | | exceeds the number of arguments. llvm-svn: 94785
* Alternate format string checking: warn of '%n' as being potentially insecure.Ted Kremenek2010-01-291-1/+11
| | | | llvm-svn: 94782
* Add precision/field width checking to AlternateCheckPrintfString().Ted Kremenek2010-01-291-3/+68
| | | | llvm-svn: 94774
* Start fleshing out Sema::AlternateCheckPrintfString():Ted Kremenek2010-01-281-0/+94
| | | | | | | | | | - Add an anonymous class 'CheckPrintfHandler' which will do the checking of specific format specifiers - Add checking for using the '@' conversion specifier outside an ObjC string literal - Add checking for null characters within the string llvm-svn: 94761
* Add placeholder function in Sema for new format string checking logic.Ted Kremenek2010-01-281-1/+18
| | | | | | | | This function will use the format string parsing logic in libAnalysis, and once it is shown to be better than the current implementation it will replace AlternateCheckPrintfString() entirely. llvm-svn: 94721
* Fix 80 col violation.Ted Kremenek2010-01-281-1/+3
| | | | llvm-svn: 94717
* Remove invalid conversion specifiers from format string checking.Ted Kremenek2010-01-281-5/+0
| | | | llvm-svn: 94707
* Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek2010-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | (1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. llvm-svn: 94406
* Wire up the new range reporting for unreachable code.Mike Stump2010-01-211-6/+16
| | | | llvm-svn: 94118
* Improve unreachable code warnings with respect to dead member andMike Stump2010-01-211-0/+12
| | | | | | dead array references. llvm-svn: 94115
* Improve unreachable code warnings for with respect to dead functional casts ↵Mike Stump2010-01-211-0/+5
| | | | | | in C++. llvm-svn: 94106
* Improve unreachable code warnings for with respect to c-style casts.Mike Stump2010-01-211-0/+5
| | | | llvm-svn: 94094
* Improve unreachable code warnings for with respect to ? :.Mike Stump2010-01-211-4/+15
| | | | llvm-svn: 94093
* Improve unreachable code warnings for with respect to compoundMike Stump2010-01-211-0/+6
| | | | | | assignments. llvm-svn: 94086
* Improve unreachable code warnings with respect to dead binary andMike Stump2010-01-211-6/+20
| | | | | | unary operators. llvm-svn: 94084
* Speed up compilation by avoiding generating exceptional edges fromMike Stump2010-01-211-2/+36
| | | | | | | | | | | | | CallExprs as those edges help cause a n^2 explosion in the number of destructor calls. Other consumers, such as static analysis, that would like to have more a more complete CFG can select the inclusion of those edges as CFG build time. This also fixes up the two compilation users of CFGs to be tolerant of having or not having those edges. All catch code is assumed be to live if we didn't generate the exceptional edges for CallExprs. llvm-svn: 94074
* Move some recent checking code into SemaChecking instead.Mike Stump2010-01-211-0/+430
| | | | llvm-svn: 94067
* Roll out ASTContext::getTypeSizeInChars(), replacing instances ofKen Dyck2010-01-111-1/+2
| | | | | | | | | | "ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits ones as appropriate. Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, fromQuantity(), and getQuantity() for clarity. llvm-svn: 93153
* Don't assert when dealing with unsigned casts of lvalues. Fixes PR5961.John McCall2010-01-061-6/+11
| | | | llvm-svn: 92866
* Derive tighter ranges for & and >> in the conversion-checking code.John McCall2010-01-061-6/+38
| | | | llvm-svn: 92862
* Significantly rework the calculation of effective integer-expression rangesJohn McCall2010-01-061-176/+221
| | | | | | | | | | | | for -Wsign-compare and -Wconversion, and use that coordinated logic to drive both diagnostics. The new logic works more transparently with implicit conversions, conditional operators, etc., as well as bringing -Wconversion's ability to deal with pseudo-closed operations (e.g. arithmetic on shorts) to -Wsign-compare. Fixes PRs 5887, 5937, 5938, and 5939. llvm-svn: 92823
* Remove stale comment. We already do format string checking for functions ↵Ted Kremenek2010-01-051-3/+0
| | | | | | with the format attribute. llvm-svn: 92553
* Move the -Wconversion logic into SemaChecking.cpp. There's a fair amount ofJohn McCall2010-01-041-0/+309
| | | | | | | overlap between this and -Wsign-compare, which is why I want them in the same place. llvm-svn: 92543
* Move the -Wsign-compare logic into SemaChecking.cpp.John McCall2010-01-041-0/+81
| | | | llvm-svn: 92541
* Update for the intrinsic changes in llvm: the object size intrinsicEric Christopher2009-12-231-0/+1
| | | | | | | only takes a boolean second argument now. Update tests accordingly. Currently the builtin still accepts the full range for compatibility. llvm-svn: 91983
* fix a bug handling the gnu ?: extension. Patch by Storlek on IRC,Chris Lattner2009-12-221-1/+1
| | | | | | who prefers to be stealthy and mysterious. llvm-svn: 91888
* Fix for PR5679: make __builtin_prefetch a bit more flexible in what it acceptsEli Friedman2009-12-041-9/+9
| | | | | | | as a constant integer. Also, some minor cleanup and improvements to the diagnostics. llvm-svn: 90504
* Adjust format attribute index for implicit object arguments. Fixes PR5521.Sebastian Redl2009-11-171-1/+19
| | | | llvm-svn: 89113
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* warn about returning the address of a label.Chris Lattner2009-10-301-1/+6
| | | | llvm-svn: 85576
* Eliminate QualifiedDeclRefExpr, which captured the notion of aDouglas Gregor2009-10-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | qualified reference to a declaration that is not a non-static data member or non-static member function, e.g., namespace N { int i; } int j = N::i; Instead, extend DeclRefExpr to optionally store the qualifier. Most clients won't see or care about the difference (since QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the number of top-level expression types that clients need to cope with, brings the implementation of DeclRefExpr into line with MemberExpr, and simplifies and unifies our handling of declaration references. Extended DeclRefExpr to (optionally) store explicitly-specified template arguments. This occurs when naming a declaration via a template-id (which will be stored in a TemplateIdRefExpr) that, following template argument deduction and (possibly) overload resolution, is replaced with a DeclRefExpr that refers to a template specialization but maintains the template arguments as written. llvm-svn: 84962
* Remove default argument for ImpCastExprToType. Add appropriate argument Eli Friedman2009-10-201-2/+1
| | | | | | | | | | | | | to all callers. Switch a few other users of CK_Unknown to proper cast kinds. Note that there are still some situations where we end up with CK_Unknown; they're pretty easy to find with grep. There are still a few missing conversion kinds, specifically pointer/int/float->bool and the various combinations of real/complex float/int->real/complex float/int. llvm-svn: 84623
* Fix checking for a null pointer constant when the expression itself isDouglas Gregor2009-09-251-2/+3
| | | | | | | | | | | | value-dependent. Audit (and fixed) all calls to Expr::isNullPointerConstant() to provide the correct behavior with value-dependent expressions. Fixes PR5041 and a crash in libstdc++ <locale>. In the same vein, properly compute value- and type-dependence for ChooseExpr. Fixes PR4996. llvm-svn: 82748
* implement support for __builtin_eh_return_data_regno on x86-32 and x86-64.Chris Lattner2009-09-231-3/+19
| | | | | | This implements PR5034 and rdar://6836445. llvm-svn: 82614
* Revert "Switch a few clients over to StringLiteral::getString.", this is ↵Daniel Dunbar2009-09-221-7/+11
| | | | | | breaking some projects, but I don't have a test case yet. llvm-svn: 82539
* Switch a few clients over to StringLiteral::getString.Daniel Dunbar2009-09-221-11/+7
| | | | | | - Switching all of them out-of-my-current-scope-of-interest, sorry. llvm-svn: 82515
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-7/+7
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Remove unnecessary ASTContext parameter from FunctionDecl::isBuiltinIDDouglas Gregor2009-09-121-1/+1
| | | | llvm-svn: 81590
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-170/+170
| | | | llvm-svn: 81346
* reject returning a block expr even when it has parens and casts in the way.Chris Lattner2009-09-081-3/+1
| | | | llvm-svn: 81176
* Eliminate CXXAdornedMemberExpr entirely. Instead, optionally allocateDouglas Gregor2009-08-311-2/+1
| | | | | | | | space within the MemberExpr for the nested-name-specifier and its source range. We'll do the same thing with explicitly-specified template arguments, assuming I don't flip-flop again. llvm-svn: 80642
* Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we willDouglas Gregor2009-08-311-1/+1
| | | | | | | also be adding explicit template arguments as an additional "adornment". No functionality change. llvm-svn: 80628
OpenPOWER on IntegriCloud