summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* PR4836, part 1: add Sema support for __builtin_isnan and friends; they Eli Friedman2009-08-311-0/+35
| | | | | | | are apparently used by Solaris libc despite the fact that clang claims to be compatible with gcc 4.2, which doesn't support them. llvm-svn: 80610
* When a member reference expression includes a qualifier on the memberDouglas Gregor2009-08-261-1/+2
| | | | | | | | | | | | | | | | | name, e.g., x->Base::f() retain the qualifier (and its source range information) in a new subclass of MemberExpr called CXXQualifiedMemberExpr. Provide construction, transformation, profiling, printing, etc., for this new expression type. When a virtual function is called via a qualified name, don't emit a virtual call. Instead, call that function directly. Mike, could you add a CodeGen test for this, too? llvm-svn: 80167
* update to CXXFunctionalCastExpr to support ir-gen forFariborz Jahanian2009-08-261-1/+3
| | | | | | type convesions of class objects [class.conv]. WIP. llvm-svn: 80127
* Initial patch to support definitions of id and Class from headers in ↵David Chisnall2009-08-171-1/+1
| | | | | | | | | | Objective-C code. This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable. The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa. Approved by snaroff. llvm-svn: 79248
* Move builtin call checking out into a separate function, make ↵Anders Carlsson2009-08-161-43/+49
| | | | | | CheckFunctionCall and CheckBlockCall return bool instead. No intended functionality change. llvm-svn: 79157
* Fix a fixme by allocating ShuffleVectorExprs in the ContextNate Begeman2009-08-121-2/+2
| | | | llvm-svn: 78780
* More CastKind work.Anders Carlsson2009-08-071-3/+3
| | | | llvm-svn: 78415
* add support for FreeBSD's format(printf0,x,y) attribute; allows null format ↵Ryan Flynn2009-08-061-2/+17
| | | | | | string. llvm-svn: 78276
* Canonicalize else.Mike Stump2009-08-041-7/+4
| | | | llvm-svn: 78102
* Add CK_DerivedToBase and use it PerformObjectMemberConversion.Anders Carlsson2009-07-311-2/+4
| | | | llvm-svn: 77652
* Change uses of:Ted Kremenek2009-07-291-4/+4
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-4/+4
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-4/+4
| | | | | | | | | | | | | | | | | | | | | This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. llvm-svn: 76098
* Remove the ASTContext parameter from the attribute-related methods of Decl.Argyrios Kyrtzidis2009-06-301-4/+4
| | | | | | | | | The implementations of these methods can Use Decl::getASTContext() to get the ASTContext. This commit touches a lot of files since call sites for these methods are everywhere. I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it. llvm-svn: 74501
OpenPOWER on IntegriCloud