[cfe-commits] r122421 [2/2] - in /cfe/trunk: examples/PrintFunctionNames/ examples/clang-interpreter/ examples/wpa/ lib/ lib/Checker/ lib/FrontendTool/ lib/GR/ tools/driver/
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Dec 22 10:52:30 PST 2010
Removed: cfe/trunk/lib/Checker/SimpleSValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SimpleSValBuilder.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/Checker/SimpleSValBuilder.cpp (removed)
@@ -1,883 +0,0 @@
-// SimpleSValBuilder.cpp - A basic SValBuilder -----------------------*- C++ -*-
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines SimpleSValBuilder, a basic implementation of SValBuilder.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/PathSensitive/SValBuilder.h"
-#include "clang/GR/PathSensitive/GRState.h"
-
-using namespace clang;
-
-namespace {
-class SimpleSValBuilder : public SValBuilder {
-protected:
- virtual SVal evalCastNL(NonLoc val, QualType castTy);
- virtual SVal evalCastL(Loc val, QualType castTy);
-
-public:
- SimpleSValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context,
- GRStateManager &stateMgr)
- : SValBuilder(alloc, context, stateMgr) {}
- virtual ~SimpleSValBuilder() {}
-
- virtual SVal evalMinus(NonLoc val);
- virtual SVal evalComplement(NonLoc val);
- virtual SVal evalBinOpNN(const GRState *state, BinaryOperator::Opcode op,
- NonLoc lhs, NonLoc rhs, QualType resultTy);
- virtual SVal evalBinOpLL(const GRState *state, BinaryOperator::Opcode op,
- Loc lhs, Loc rhs, QualType resultTy);
- virtual SVal evalBinOpLN(const GRState *state, BinaryOperator::Opcode op,
- Loc lhs, NonLoc rhs, QualType resultTy);
-
- /// getKnownValue - evaluates a given SVal. If the SVal has only one possible
- /// (integer) value, that value is returned. Otherwise, returns NULL.
- virtual const llvm::APSInt *getKnownValue(const GRState *state, SVal V);
-
- SVal MakeSymIntVal(const SymExpr *LHS, BinaryOperator::Opcode op,
- const llvm::APSInt &RHS, QualType resultTy);
-};
-} // end anonymous namespace
-
-SValBuilder *clang::createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc,
- ASTContext &context,
- GRStateManager &stateMgr) {
- return new SimpleSValBuilder(alloc, context, stateMgr);
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for Casts.
-//===----------------------------------------------------------------------===//
-
-SVal SimpleSValBuilder::evalCastNL(NonLoc val, QualType castTy) {
-
- bool isLocType = Loc::IsLocType(castTy);
-
- if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val)) {
- if (isLocType)
- return LI->getLoc();
-
- // FIXME: Correctly support promotions/truncations.
- unsigned castSize = Context.getTypeSize(castTy);
- if (castSize == LI->getNumBits())
- return val;
- return makeLocAsInteger(LI->getLoc(), castSize);
- }
-
- if (const SymExpr *se = val.getAsSymbolicExpression()) {
- QualType T = Context.getCanonicalType(se->getType(Context));
- if (T == Context.getCanonicalType(castTy))
- return val;
-
- // FIXME: Remove this hack when we support symbolic truncation/extension.
- // HACK: If both castTy and T are integers, ignore the cast. This is
- // not a permanent solution. Eventually we want to precisely handle
- // extension/truncation of symbolic integers. This prevents us from losing
- // precision when we assign 'x = y' and 'y' is symbolic and x and y are
- // different integer types.
- if (T->isIntegerType() && castTy->isIntegerType())
- return val;
-
- return UnknownVal();
- }
-
- if (!isa<nonloc::ConcreteInt>(val))
- return UnknownVal();
-
- // Only handle casts from integers to integers.
- if (!isLocType && !castTy->isIntegerType())
- return UnknownVal();
-
- llvm::APSInt i = cast<nonloc::ConcreteInt>(val).getValue();
- i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
- i = i.extOrTrunc(Context.getTypeSize(castTy));
-
- if (isLocType)
- return makeIntLocVal(i);
- else
- return makeIntVal(i);
-}
-
-SVal SimpleSValBuilder::evalCastL(Loc val, QualType castTy) {
-
- // Casts from pointers -> pointers, just return the lval.
- //
- // Casts from pointers -> references, just return the lval. These
- // can be introduced by the frontend for corner cases, e.g
- // casting from va_list* to __builtin_va_list&.
- //
- if (Loc::IsLocType(castTy) || castTy->isReferenceType())
- return val;
-
- // FIXME: Handle transparent unions where a value can be "transparently"
- // lifted into a union type.
- if (castTy->isUnionType())
- return UnknownVal();
-
- if (castTy->isIntegerType()) {
- unsigned BitWidth = Context.getTypeSize(castTy);
-
- if (!isa<loc::ConcreteInt>(val))
- return makeLocAsInteger(val, BitWidth);
-
- llvm::APSInt i = cast<loc::ConcreteInt>(val).getValue();
- i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
- i = i.extOrTrunc(BitWidth);
- return makeIntVal(i);
- }
-
- // All other cases: return 'UnknownVal'. This includes casting pointers
- // to floats, which is probably badness it itself, but this is a good
- // intermediate solution until we do something better.
- return UnknownVal();
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for unary operators.
-//===----------------------------------------------------------------------===//
-
-SVal SimpleSValBuilder::evalMinus(NonLoc val) {
- switch (val.getSubKind()) {
- case nonloc::ConcreteIntKind:
- return cast<nonloc::ConcreteInt>(val).evalMinus(*this);
- default:
- return UnknownVal();
- }
-}
-
-SVal SimpleSValBuilder::evalComplement(NonLoc X) {
- switch (X.getSubKind()) {
- case nonloc::ConcreteIntKind:
- return cast<nonloc::ConcreteInt>(X).evalComplement(*this);
- default:
- return UnknownVal();
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function for binary operators.
-//===----------------------------------------------------------------------===//
-
-static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
- switch (op) {
- default:
- assert(false && "Invalid opcode.");
- case BO_LT: return BO_GE;
- case BO_GT: return BO_LE;
- case BO_LE: return BO_GT;
- case BO_GE: return BO_LT;
- case BO_EQ: return BO_NE;
- case BO_NE: return BO_EQ;
- }
-}
-
-static BinaryOperator::Opcode ReverseComparison(BinaryOperator::Opcode op) {
- switch (op) {
- default:
- assert(false && "Invalid opcode.");
- case BO_LT: return BO_GT;
- case BO_GT: return BO_LT;
- case BO_LE: return BO_GE;
- case BO_GE: return BO_LE;
- case BO_EQ:
- case BO_NE:
- return op;
- }
-}
-
-SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS,
- BinaryOperator::Opcode op,
- const llvm::APSInt &RHS,
- QualType resultTy) {
- bool isIdempotent = false;
-
- // Check for a few special cases with known reductions first.
- switch (op) {
- default:
- // We can't reduce this case; just treat it normally.
- break;
- case BO_Mul:
- // a*0 and a*1
- if (RHS == 0)
- return makeIntVal(0, resultTy);
- else if (RHS == 1)
- isIdempotent = true;
- break;
- case BO_Div:
- // a/0 and a/1
- if (RHS == 0)
- // This is also handled elsewhere.
- return UndefinedVal();
- else if (RHS == 1)
- isIdempotent = true;
- break;
- case BO_Rem:
- // a%0 and a%1
- if (RHS == 0)
- // This is also handled elsewhere.
- return UndefinedVal();
- else if (RHS == 1)
- return makeIntVal(0, resultTy);
- break;
- case BO_Add:
- case BO_Sub:
- case BO_Shl:
- case BO_Shr:
- case BO_Xor:
- // a+0, a-0, a<<0, a>>0, a^0
- if (RHS == 0)
- isIdempotent = true;
- break;
- case BO_And:
- // a&0 and a&(~0)
- if (RHS == 0)
- return makeIntVal(0, resultTy);
- else if (RHS.isAllOnesValue())
- isIdempotent = true;
- break;
- case BO_Or:
- // a|0 and a|(~0)
- if (RHS == 0)
- isIdempotent = true;
- else if (RHS.isAllOnesValue()) {
- const llvm::APSInt &Result = BasicVals.Convert(resultTy, RHS);
- return nonloc::ConcreteInt(Result);
- }
- break;
- }
-
- // Idempotent ops (like a*1) can still change the type of an expression.
- // Wrap the LHS up in a NonLoc again and let evalCastNL do the dirty work.
- if (isIdempotent) {
- if (SymbolRef LHSSym = dyn_cast<SymbolData>(LHS))
- return evalCastNL(nonloc::SymbolVal(LHSSym), resultTy);
- return evalCastNL(nonloc::SymExprVal(LHS), resultTy);
- }
-
- // If we reach this point, the expression cannot be simplified.
- // Make a SymExprVal for the entire thing.
- return makeNonLoc(LHS, op, RHS, resultTy);
-}
-
-SVal SimpleSValBuilder::evalBinOpNN(const GRState *state,
- BinaryOperator::Opcode op,
- NonLoc lhs, NonLoc rhs,
- QualType resultTy) {
- // Handle trivial case where left-side and right-side are the same.
- if (lhs == rhs)
- switch (op) {
- default:
- break;
- case BO_EQ:
- case BO_LE:
- case BO_GE:
- return makeTruthVal(true, resultTy);
- case BO_LT:
- case BO_GT:
- case BO_NE:
- return makeTruthVal(false, resultTy);
- case BO_Xor:
- case BO_Sub:
- return makeIntVal(0, resultTy);
- case BO_Or:
- case BO_And:
- return evalCastNL(lhs, resultTy);
- }
-
- while (1) {
- switch (lhs.getSubKind()) {
- default:
- return UnknownVal();
- case nonloc::LocAsIntegerKind: {
- Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
- switch (rhs.getSubKind()) {
- case nonloc::LocAsIntegerKind:
- return evalBinOpLL(state, op, lhsL,
- cast<nonloc::LocAsInteger>(rhs).getLoc(),
- resultTy);
- case nonloc::ConcreteIntKind: {
- // Transform the integer into a location and compare.
- llvm::APSInt i = cast<nonloc::ConcreteInt>(rhs).getValue();
- i.setIsUnsigned(true);
- i = i.extOrTrunc(Context.getTypeSize(Context.VoidPtrTy));
- return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
- }
- default:
- switch (op) {
- case BO_EQ:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- return makeTruthVal(true, resultTy);
- default:
- // This case also handles pointer arithmetic.
- return UnknownVal();
- }
- }
- }
- case nonloc::SymExprValKind: {
- nonloc::SymExprVal *selhs = cast<nonloc::SymExprVal>(&lhs);
-
- // Only handle LHS of the form "$sym op constant", at least for now.
- const SymIntExpr *symIntExpr =
- dyn_cast<SymIntExpr>(selhs->getSymbolicExpression());
-
- if (!symIntExpr)
- return UnknownVal();
-
- // Is this a logical not? (!x is represented as x == 0.)
- if (op == BO_EQ && rhs.isZeroConstant()) {
- // We know how to negate certain expressions. Simplify them here.
-
- BinaryOperator::Opcode opc = symIntExpr->getOpcode();
- switch (opc) {
- default:
- // We don't know how to negate this operation.
- // Just handle it as if it were a normal comparison to 0.
- break;
- case BO_LAnd:
- case BO_LOr:
- assert(false && "Logical operators handled by branching logic.");
- return UnknownVal();
- case BO_Assign:
- case BO_MulAssign:
- case BO_DivAssign:
- case BO_RemAssign:
- case BO_AddAssign:
- case BO_SubAssign:
- case BO_ShlAssign:
- case BO_ShrAssign:
- case BO_AndAssign:
- case BO_XorAssign:
- case BO_OrAssign:
- case BO_Comma:
- assert(false && "'=' and ',' operators handled by GRExprEngine.");
- return UnknownVal();
- case BO_PtrMemD:
- case BO_PtrMemI:
- assert(false && "Pointer arithmetic not handled here.");
- return UnknownVal();
- case BO_LT:
- case BO_GT:
- case BO_LE:
- case BO_GE:
- case BO_EQ:
- case BO_NE:
- // Negate the comparison and make a value.
- opc = NegateComparison(opc);
- assert(symIntExpr->getType(Context) == resultTy);
- return makeNonLoc(symIntExpr->getLHS(), opc,
- symIntExpr->getRHS(), resultTy);
- }
- }
-
- // For now, only handle expressions whose RHS is a constant.
- const nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs);
- if (!rhsInt)
- return UnknownVal();
-
- // If both the LHS and the current expression are additive,
- // fold their constants.
- if (BinaryOperator::isAdditiveOp(op)) {
- BinaryOperator::Opcode lop = symIntExpr->getOpcode();
- if (BinaryOperator::isAdditiveOp(lop)) {
- // resultTy may not be the best type to convert to, but it's
- // probably the best choice in expressions with mixed type
- // (such as x+1U+2LL). The rules for implicit conversions should
- // choose a reasonable type to preserve the expression, and will
- // at least match how the value is going to be used.
- const llvm::APSInt &first =
- BasicVals.Convert(resultTy, symIntExpr->getRHS());
- const llvm::APSInt &second =
- BasicVals.Convert(resultTy, rhsInt->getValue());
- const llvm::APSInt *newRHS;
- if (lop == op)
- newRHS = BasicVals.evalAPSInt(BO_Add, first, second);
- else
- newRHS = BasicVals.evalAPSInt(BO_Sub, first, second);
- return MakeSymIntVal(symIntExpr->getLHS(), lop, *newRHS, resultTy);
- }
- }
-
- // Otherwise, make a SymExprVal out of the expression.
- return MakeSymIntVal(symIntExpr, op, rhsInt->getValue(), resultTy);
- }
- case nonloc::ConcreteIntKind: {
- const nonloc::ConcreteInt& lhsInt = cast<nonloc::ConcreteInt>(lhs);
-
- if (isa<nonloc::ConcreteInt>(rhs)) {
- return lhsInt.evalBinOp(*this, op, cast<nonloc::ConcreteInt>(rhs));
- } else {
- const llvm::APSInt& lhsValue = lhsInt.getValue();
-
- // Swap the left and right sides and flip the operator if doing so
- // allows us to better reason about the expression (this is a form
- // of expression canonicalization).
- // While we're at it, catch some special cases for non-commutative ops.
- NonLoc tmp = rhs;
- rhs = lhs;
- lhs = tmp;
-
- switch (op) {
- case BO_LT:
- case BO_GT:
- case BO_LE:
- case BO_GE:
- op = ReverseComparison(op);
- continue;
- case BO_EQ:
- case BO_NE:
- case BO_Add:
- case BO_Mul:
- case BO_And:
- case BO_Xor:
- case BO_Or:
- continue;
- case BO_Shr:
- if (lhsValue.isAllOnesValue() && lhsValue.isSigned())
- // At this point lhs and rhs have been swapped.
- return rhs;
- // FALL-THROUGH
- case BO_Shl:
- if (lhsValue == 0)
- // At this point lhs and rhs have been swapped.
- return rhs;
- return UnknownVal();
- default:
- return UnknownVal();
- }
- }
- }
- case nonloc::SymbolValKind: {
- nonloc::SymbolVal *slhs = cast<nonloc::SymbolVal>(&lhs);
- SymbolRef Sym = slhs->getSymbol();
- // Does the symbol simplify to a constant? If so, "fold" the constant
- // by setting 'lhs' to a ConcreteInt and try again.
- if (Sym->getType(Context)->isIntegerType())
- if (const llvm::APSInt *Constant = state->getSymVal(Sym)) {
- // The symbol evaluates to a constant. If necessary, promote the
- // folded constant (LHS) to the result type.
- const llvm::APSInt &lhs_I = BasicVals.Convert(resultTy, *Constant);
- lhs = nonloc::ConcreteInt(lhs_I);
-
- // Also promote the RHS (if necessary).
-
- // For shifts, it is not necessary to promote the RHS.
- if (BinaryOperator::isShiftOp(op))
- continue;
-
- // Other operators: do an implicit conversion. This shouldn't be
- // necessary once we support truncation/extension of symbolic values.
- if (nonloc::ConcreteInt *rhs_I = dyn_cast<nonloc::ConcreteInt>(&rhs)){
- rhs = nonloc::ConcreteInt(BasicVals.Convert(resultTy,
- rhs_I->getValue()));
- }
-
- continue;
- }
-
- // Is the RHS a symbol we can simplify?
- if (const nonloc::SymbolVal *srhs = dyn_cast<nonloc::SymbolVal>(&rhs)) {
- SymbolRef RSym = srhs->getSymbol();
- if (RSym->getType(Context)->isIntegerType()) {
- if (const llvm::APSInt *Constant = state->getSymVal(RSym)) {
- // The symbol evaluates to a constant.
- const llvm::APSInt &rhs_I = BasicVals.Convert(resultTy, *Constant);
- rhs = nonloc::ConcreteInt(rhs_I);
- }
- }
- }
-
- if (isa<nonloc::ConcreteInt>(rhs)) {
- return MakeSymIntVal(slhs->getSymbol(), op,
- cast<nonloc::ConcreteInt>(rhs).getValue(),
- resultTy);
- }
-
- return UnknownVal();
- }
- }
- }
-}
-
-// FIXME: all this logic will change if/when we have MemRegion::getLocation().
-SVal SimpleSValBuilder::evalBinOpLL(const GRState *state,
- BinaryOperator::Opcode op,
- Loc lhs, Loc rhs,
- QualType resultTy) {
- // Only comparisons and subtractions are valid operations on two pointers.
- // See [C99 6.5.5 through 6.5.14] or [C++0x 5.6 through 5.15].
- // However, if a pointer is casted to an integer, evalBinOpNN may end up
- // calling this function with another operation (PR7527). We don't attempt to
- // model this for now, but it could be useful, particularly when the
- // "location" is actually an integer value that's been passed through a void*.
- if (!(BinaryOperator::isComparisonOp(op) || op == BO_Sub))
- return UnknownVal();
-
- // Special cases for when both sides are identical.
- if (lhs == rhs) {
- switch (op) {
- default:
- assert(false && "Unimplemented operation for two identical values");
- return UnknownVal();
- case BO_Sub:
- return makeZeroVal(resultTy);
- case BO_EQ:
- case BO_LE:
- case BO_GE:
- return makeTruthVal(true, resultTy);
- case BO_NE:
- case BO_LT:
- case BO_GT:
- return makeTruthVal(false, resultTy);
- }
- }
-
- switch (lhs.getSubKind()) {
- default:
- assert(false && "Ordering not implemented for this Loc.");
- return UnknownVal();
-
- case loc::GotoLabelKind:
- // The only thing we know about labels is that they're non-null.
- if (rhs.isZeroConstant()) {
- switch (op) {
- default:
- break;
- case BO_Sub:
- return evalCastL(lhs, resultTy);
- case BO_EQ:
- case BO_LE:
- case BO_LT:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- case BO_GT:
- case BO_GE:
- return makeTruthVal(true, resultTy);
- }
- }
- // There may be two labels for the same location, and a function region may
- // have the same address as a label at the start of the function (depending
- // on the ABI).
- // FIXME: we can probably do a comparison against other MemRegions, though.
- // FIXME: is there a way to tell if two labels refer to the same location?
- return UnknownVal();
-
- case loc::ConcreteIntKind: {
- // If one of the operands is a symbol and the other is a constant,
- // build an expression for use by the constraint manager.
- if (SymbolRef rSym = rhs.getAsLocSymbol()) {
- // We can only build expressions with symbols on the left,
- // so we need a reversible operator.
- if (!BinaryOperator::isComparisonOp(op))
- return UnknownVal();
-
- const llvm::APSInt &lVal = cast<loc::ConcreteInt>(lhs).getValue();
- return makeNonLoc(rSym, ReverseComparison(op), lVal, resultTy);
- }
-
- // If both operands are constants, just perform the operation.
- if (loc::ConcreteInt *rInt = dyn_cast<loc::ConcreteInt>(&rhs)) {
- SVal ResultVal = cast<loc::ConcreteInt>(lhs).evalBinOp(BasicVals, op,
- *rInt);
- if (Loc *Result = dyn_cast<Loc>(&ResultVal))
- return evalCastL(*Result, resultTy);
- else
- return UnknownVal();
- }
-
- // Special case comparisons against NULL.
- // This must come after the test if the RHS is a symbol, which is used to
- // build constraints. The address of any non-symbolic region is guaranteed
- // to be non-NULL, as is any label.
- assert(isa<loc::MemRegionVal>(rhs) || isa<loc::GotoLabel>(rhs));
- if (lhs.isZeroConstant()) {
- switch (op) {
- default:
- break;
- case BO_EQ:
- case BO_GT:
- case BO_GE:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- case BO_LT:
- case BO_LE:
- return makeTruthVal(true, resultTy);
- }
- }
-
- // Comparing an arbitrary integer to a region or label address is
- // completely unknowable.
- return UnknownVal();
- }
- case loc::MemRegionKind: {
- if (loc::ConcreteInt *rInt = dyn_cast<loc::ConcreteInt>(&rhs)) {
- // If one of the operands is a symbol and the other is a constant,
- // build an expression for use by the constraint manager.
- if (SymbolRef lSym = lhs.getAsLocSymbol())
- return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
-
- // Special case comparisons to NULL.
- // This must come after the test if the LHS is a symbol, which is used to
- // build constraints. The address of any non-symbolic region is guaranteed
- // to be non-NULL.
- if (rInt->isZeroConstant()) {
- switch (op) {
- default:
- break;
- case BO_Sub:
- return evalCastL(lhs, resultTy);
- case BO_EQ:
- case BO_LT:
- case BO_LE:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- case BO_GT:
- case BO_GE:
- return makeTruthVal(true, resultTy);
- }
- }
-
- // Comparing a region to an arbitrary integer is completely unknowable.
- return UnknownVal();
- }
-
- // Get both values as regions, if possible.
- const MemRegion *LeftMR = lhs.getAsRegion();
- assert(LeftMR && "MemRegionKind SVal doesn't have a region!");
-
- const MemRegion *RightMR = rhs.getAsRegion();
- if (!RightMR)
- // The RHS is probably a label, which in theory could address a region.
- // FIXME: we can probably make a more useful statement about non-code
- // regions, though.
- return UnknownVal();
-
- // If both values wrap regions, see if they're from different base regions.
- const MemRegion *LeftBase = LeftMR->getBaseRegion();
- const MemRegion *RightBase = RightMR->getBaseRegion();
- if (LeftBase != RightBase &&
- !isa<SymbolicRegion>(LeftBase) && !isa<SymbolicRegion>(RightBase)) {
- switch (op) {
- default:
- return UnknownVal();
- case BO_EQ:
- return makeTruthVal(false, resultTy);
- case BO_NE:
- return makeTruthVal(true, resultTy);
- }
- }
-
- // The two regions are from the same base region. See if they're both a
- // type of region we know how to compare.
-
- // FIXME: If/when there is a getAsRawOffset() for FieldRegions, this
- // ElementRegion path and the FieldRegion path below should be unified.
- if (const ElementRegion *LeftER = dyn_cast<ElementRegion>(LeftMR)) {
- // First see if the right region is also an ElementRegion.
- const ElementRegion *RightER = dyn_cast<ElementRegion>(RightMR);
- if (!RightER)
- return UnknownVal();
-
- // Next, see if the two ERs have the same super-region and matching types.
- // FIXME: This should do something useful even if the types don't match,
- // though if both indexes are constant the RegionRawOffset path will
- // give the correct answer.
- if (LeftER->getSuperRegion() == RightER->getSuperRegion() &&
- LeftER->getElementType() == RightER->getElementType()) {
- // Get the left index and cast it to the correct type.
- // If the index is unknown or undefined, bail out here.
- SVal LeftIndexVal = LeftER->getIndex();
- NonLoc *LeftIndex = dyn_cast<NonLoc>(&LeftIndexVal);
- if (!LeftIndex)
- return UnknownVal();
- LeftIndexVal = evalCastNL(*LeftIndex, resultTy);
- LeftIndex = dyn_cast<NonLoc>(&LeftIndexVal);
- if (!LeftIndex)
- return UnknownVal();
-
- // Do the same for the right index.
- SVal RightIndexVal = RightER->getIndex();
- NonLoc *RightIndex = dyn_cast<NonLoc>(&RightIndexVal);
- if (!RightIndex)
- return UnknownVal();
- RightIndexVal = evalCastNL(*RightIndex, resultTy);
- RightIndex = dyn_cast<NonLoc>(&RightIndexVal);
- if (!RightIndex)
- return UnknownVal();
-
- // Actually perform the operation.
- // evalBinOpNN expects the two indexes to already be the right type.
- return evalBinOpNN(state, op, *LeftIndex, *RightIndex, resultTy);
- }
-
- // If the element indexes aren't comparable, see if the raw offsets are.
- RegionRawOffset LeftOffset = LeftER->getAsArrayOffset();
- RegionRawOffset RightOffset = RightER->getAsArrayOffset();
-
- if (LeftOffset.getRegion() != NULL &&
- LeftOffset.getRegion() == RightOffset.getRegion()) {
- int64_t left = LeftOffset.getByteOffset();
- int64_t right = RightOffset.getByteOffset();
-
- switch (op) {
- default:
- return UnknownVal();
- case BO_LT:
- return makeTruthVal(left < right, resultTy);
- case BO_GT:
- return makeTruthVal(left > right, resultTy);
- case BO_LE:
- return makeTruthVal(left <= right, resultTy);
- case BO_GE:
- return makeTruthVal(left >= right, resultTy);
- case BO_EQ:
- return makeTruthVal(left == right, resultTy);
- case BO_NE:
- return makeTruthVal(left != right, resultTy);
- }
- }
-
- // If we get here, we have no way of comparing the ElementRegions.
- return UnknownVal();
- }
-
- // See if both regions are fields of the same structure.
- // FIXME: This doesn't handle nesting, inheritance, or Objective-C ivars.
- if (const FieldRegion *LeftFR = dyn_cast<FieldRegion>(LeftMR)) {
- // Only comparisons are meaningful here!
- if (!BinaryOperator::isComparisonOp(op))
- return UnknownVal();
-
- // First see if the right region is also a FieldRegion.
- const FieldRegion *RightFR = dyn_cast<FieldRegion>(RightMR);
- if (!RightFR)
- return UnknownVal();
-
- // Next, see if the two FRs have the same super-region.
- // FIXME: This doesn't handle casts yet, and simply stripping the casts
- // doesn't help.
- if (LeftFR->getSuperRegion() != RightFR->getSuperRegion())
- return UnknownVal();
-
- const FieldDecl *LeftFD = LeftFR->getDecl();
- const FieldDecl *RightFD = RightFR->getDecl();
- const RecordDecl *RD = LeftFD->getParent();
-
- // Make sure the two FRs are from the same kind of record. Just in case!
- // FIXME: This is probably where inheritance would be a problem.
- if (RD != RightFD->getParent())
- return UnknownVal();
-
- // We know for sure that the two fields are not the same, since that
- // would have given us the same SVal.
- if (op == BO_EQ)
- return makeTruthVal(false, resultTy);
- if (op == BO_NE)
- return makeTruthVal(true, resultTy);
-
- // Iterate through the fields and see which one comes first.
- // [C99 6.7.2.1.13] "Within a structure object, the non-bit-field
- // members and the units in which bit-fields reside have addresses that
- // increase in the order in which they are declared."
- bool leftFirst = (op == BO_LT || op == BO_LE);
- for (RecordDecl::field_iterator I = RD->field_begin(),
- E = RD->field_end(); I!=E; ++I) {
- if (*I == LeftFD)
- return makeTruthVal(leftFirst, resultTy);
- if (*I == RightFD)
- return makeTruthVal(!leftFirst, resultTy);
- }
-
- assert(false && "Fields not found in parent record's definition");
- }
-
- // If we get here, we have no way of comparing the regions.
- return UnknownVal();
- }
- }
-}
-
-SVal SimpleSValBuilder::evalBinOpLN(const GRState *state,
- BinaryOperator::Opcode op,
- Loc lhs, NonLoc rhs, QualType resultTy) {
- // Special case: 'rhs' is an integer that has the same width as a pointer and
- // we are using the integer location in a comparison. Normally this cannot be
- // triggered, but transfer functions like those for OSCommpareAndSwapBarrier32
- // can generate comparisons that trigger this code.
- // FIXME: Are all locations guaranteed to have pointer width?
- if (BinaryOperator::isComparisonOp(op)) {
- if (nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs)) {
- const llvm::APSInt *x = &rhsInt->getValue();
- ASTContext &ctx = Context;
- if (ctx.getTypeSize(ctx.VoidPtrTy) == x->getBitWidth()) {
- // Convert the signedness of the integer (if necessary).
- if (x->isSigned())
- x = &getBasicValueFactory().getValue(*x, true);
-
- return evalBinOpLL(state, op, lhs, loc::ConcreteInt(*x), resultTy);
- }
- }
- }
-
- // We are dealing with pointer arithmetic.
-
- // Handle pointer arithmetic on constant values.
- if (nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs)) {
- if (loc::ConcreteInt *lhsInt = dyn_cast<loc::ConcreteInt>(&lhs)) {
- const llvm::APSInt &leftI = lhsInt->getValue();
- assert(leftI.isUnsigned());
- llvm::APSInt rightI(rhsInt->getValue(), /* isUnsigned */ true);
-
- // Convert the bitwidth of rightI. This should deal with overflow
- // since we are dealing with concrete values.
- rightI = rightI.extOrTrunc(leftI.getBitWidth());
-
- // Offset the increment by the pointer size.
- llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
- rightI *= Multiplicand;
-
- // Compute the adjusted pointer.
- switch (op) {
- case BO_Add:
- rightI = leftI + rightI;
- break;
- case BO_Sub:
- rightI = leftI - rightI;
- break;
- default:
- llvm_unreachable("Invalid pointer arithmetic operation");
- }
- return loc::ConcreteInt(getBasicValueFactory().getValue(rightI));
- }
- }
-
-
- // Delegate remaining pointer arithmetic to the StoreManager.
- return state->getStateManager().getStoreManager().evalBinOp(op, lhs,
- rhs, resultTy);
-}
-
-const llvm::APSInt *SimpleSValBuilder::getKnownValue(const GRState *state,
- SVal V) {
- if (V.isUnknownOrUndef())
- return NULL;
-
- if (loc::ConcreteInt* X = dyn_cast<loc::ConcreteInt>(&V))
- return &X->getValue();
-
- if (nonloc::ConcreteInt* X = dyn_cast<nonloc::ConcreteInt>(&V))
- return &X->getValue();
-
- if (SymbolRef Sym = V.getAsSymbol())
- return state->getSymVal(Sym);
-
- // FIXME: Add support for SymExprs.
- return NULL;
-}
Removed: cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp (original)
+++ cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp (removed)
@@ -1,204 +0,0 @@
-//=== StackAddrLeakChecker.cpp ------------------------------------*- C++ -*--//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines stack address leak checker, which checks if an invalid
-// stack address is stored into a global or heap location. See CERT DCL30-C.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRState.h"
-#include "clang/Basic/SourceManager.h"
-#include "llvm/ADT/SmallString.h"
-using namespace clang;
-
-namespace {
-class StackAddrLeakChecker : public CheckerVisitor<StackAddrLeakChecker> {
- BuiltinBug *BT_stackleak;
- BuiltinBug *BT_returnstack;
-
-public:
- StackAddrLeakChecker() : BT_stackleak(0), BT_returnstack(0) {}
- static void *getTag() {
- static int x;
- return &x;
- }
- void PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *RS);
- void evalEndPath(GREndPathNodeBuilder &B, void *tag, GRExprEngine &Eng);
-private:
- void EmitStackError(CheckerContext &C, const MemRegion *R, const Expr *RetE);
- SourceRange GenName(llvm::raw_ostream &os, const MemRegion *R,
- SourceManager &SM);
-};
-}
-
-void clang::RegisterStackAddrLeakChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new StackAddrLeakChecker());
-}
-
-SourceRange StackAddrLeakChecker::GenName(llvm::raw_ostream &os,
- const MemRegion *R,
- SourceManager &SM) {
- // Get the base region, stripping away fields and elements.
- R = R->getBaseRegion();
- SourceRange range;
- os << "Address of ";
-
- // Check if the region is a compound literal.
- if (const CompoundLiteralRegion* CR = dyn_cast<CompoundLiteralRegion>(R)) {
- const CompoundLiteralExpr* CL = CR->getLiteralExpr();
- os << "stack memory associated with a compound literal "
- "declared on line "
- << SM.getInstantiationLineNumber(CL->getLocStart())
- << " returned to caller";
- range = CL->getSourceRange();
- }
- else if (const AllocaRegion* AR = dyn_cast<AllocaRegion>(R)) {
- const Expr* ARE = AR->getExpr();
- SourceLocation L = ARE->getLocStart();
- range = ARE->getSourceRange();
- os << "stack memory allocated by call to alloca() on line "
- << SM.getInstantiationLineNumber(L);
- }
- else if (const BlockDataRegion *BR = dyn_cast<BlockDataRegion>(R)) {
- const BlockDecl *BD = BR->getCodeRegion()->getDecl();
- SourceLocation L = BD->getLocStart();
- range = BD->getSourceRange();
- os << "stack-allocated block declared on line "
- << SM.getInstantiationLineNumber(L);
- }
- else if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
- os << "stack memory associated with local variable '"
- << VR->getString() << '\'';
- range = VR->getDecl()->getSourceRange();
- }
- else {
- assert(false && "Invalid region in ReturnStackAddressChecker.");
- }
-
- return range;
-}
-
-void StackAddrLeakChecker::EmitStackError(CheckerContext &C, const MemRegion *R,
- const Expr *RetE) {
- ExplodedNode *N = C.generateSink();
-
- if (!N)
- return;
-
- if (!BT_returnstack)
- BT_returnstack=new BuiltinBug("Return of address to stack-allocated memory");
-
- // Generate a report for this bug.
- llvm::SmallString<512> buf;
- llvm::raw_svector_ostream os(buf);
- SourceRange range = GenName(os, R, C.getSourceManager());
- os << " returned to caller";
- RangedBugReport *report = new RangedBugReport(*BT_returnstack, os.str(), N);
- report->addRange(RetE->getSourceRange());
- if (range.isValid())
- report->addRange(range);
-
- C.EmitReport(report);
-}
-
-void StackAddrLeakChecker::PreVisitReturnStmt(CheckerContext &C,
- const ReturnStmt *RS) {
-
- const Expr *RetE = RS->getRetValue();
- if (!RetE)
- return;
-
- SVal V = C.getState()->getSVal(RetE);
- const MemRegion *R = V.getAsRegion();
-
- if (!R || !R->hasStackStorage())
- return;
-
- if (R->hasStackStorage()) {
- EmitStackError(C, R, RetE);
- return;
- }
-}
-
-void StackAddrLeakChecker::evalEndPath(GREndPathNodeBuilder &B, void *tag,
- GRExprEngine &Eng) {
- SaveAndRestore<bool> OldHasGen(B.HasGeneratedNode);
- const GRState *state = B.getState();
-
- // Iterate over all bindings to global variables and see if it contains
- // a memory region in the stack space.
- class CallBack : public StoreManager::BindingsHandler {
- private:
- const StackFrameContext *CurSFC;
- public:
- llvm::SmallVector<std::pair<const MemRegion*, const MemRegion*>, 10> V;
-
- CallBack(const LocationContext *LCtx)
- : CurSFC(LCtx->getCurrentStackFrame()) {}
-
- bool HandleBinding(StoreManager &SMgr, Store store,
- const MemRegion *region, SVal val) {
-
- if (!isa<GlobalsSpaceRegion>(region->getMemorySpace()))
- return true;
-
- const MemRegion *vR = val.getAsRegion();
- if (!vR)
- return true;
-
- if (const StackSpaceRegion *SSR =
- dyn_cast<StackSpaceRegion>(vR->getMemorySpace())) {
- // If the global variable holds a location in the current stack frame,
- // record the binding to emit a warning.
- if (SSR->getStackFrame() == CurSFC)
- V.push_back(std::make_pair(region, vR));
- }
-
- return true;
- }
- };
-
- CallBack cb(B.getPredecessor()->getLocationContext());
- state->getStateManager().getStoreManager().iterBindings(state->getStore(),cb);
-
- if (cb.V.empty())
- return;
-
- // Generate an error node.
- ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
- if (!N)
- return;
-
- if (!BT_stackleak)
- BT_stackleak =
- new BuiltinBug("Stack address stored into global variable",
- "Stack address was saved into a global variable. "
- "This is dangerous because the address will become "
- "invalid after returning from the function");
-
- for (unsigned i = 0, e = cb.V.size(); i != e; ++i) {
- // Generate a report for this bug.
- llvm::SmallString<512> buf;
- llvm::raw_svector_ostream os(buf);
- SourceRange range = GenName(os, cb.V[i].second,
- Eng.getContext().getSourceManager());
- os << " is still referred to by the global variable '";
- const VarRegion *VR = cast<VarRegion>(cb.V[i].first->getBaseRegion());
- os << VR->getDecl()->getNameAsString()
- << "' upon returning to the caller. This will be a dangling reference";
- RangedBugReport *report = new RangedBugReport(*BT_stackleak, os.str(), N);
- if (range.isValid())
- report->addRange(range);
-
- Eng.getBugReporter().EmitReport(report);
- }
-}
Removed: cfe/trunk/lib/Checker/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Store.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/Store.cpp (original)
+++ cfe/trunk/lib/Checker/Store.cpp (removed)
@@ -1,333 +0,0 @@
-//== Store.cpp - Interface for maps from Locations to Values ----*- C++ -*--==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defined the types Store and StoreManager.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/PathSensitive/Store.h"
-#include "clang/GR/PathSensitive/GRState.h"
-#include "clang/AST/CharUnits.h"
-
-using namespace clang;
-
-StoreManager::StoreManager(GRStateManager &stateMgr)
- : svalBuilder(stateMgr.getSValBuilder()), StateMgr(stateMgr),
- MRMgr(svalBuilder.getRegionManager()), Ctx(stateMgr.getContext()) {}
-
-Store StoreManager::EnterStackFrame(const GRState *state,
- const StackFrameContext *frame) {
- return state->getStore();
-}
-
-const MemRegion *StoreManager::MakeElementRegion(const MemRegion *Base,
- QualType EleTy, uint64_t index) {
- NonLoc idx = svalBuilder.makeArrayIndex(index);
- return MRMgr.getElementRegion(EleTy, idx, Base, svalBuilder.getContext());
-}
-
-// FIXME: Merge with the implementation of the same method in MemRegion.cpp
-static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
- if (const RecordType *RT = Ty->getAs<RecordType>()) {
- const RecordDecl *D = RT->getDecl();
- if (!D->getDefinition())
- return false;
- }
-
- return true;
-}
-
-const ElementRegion *StoreManager::GetElementZeroRegion(const MemRegion *R,
- QualType T) {
- NonLoc idx = svalBuilder.makeZeroArrayIndex();
- assert(!T.isNull());
- return MRMgr.getElementRegion(T, idx, R, Ctx);
-}
-
-const MemRegion *StoreManager::CastRegion(const MemRegion *R, QualType CastToTy) {
-
- ASTContext& Ctx = StateMgr.getContext();
-
- // Handle casts to Objective-C objects.
- if (CastToTy->isObjCObjectPointerType())
- return R->StripCasts();
-
- if (CastToTy->isBlockPointerType()) {
- // FIXME: We may need different solutions, depending on the symbol
- // involved. Blocks can be casted to/from 'id', as they can be treated
- // as Objective-C objects. This could possibly be handled by enhancing
- // our reasoning of downcasts of symbolic objects.
- if (isa<CodeTextRegion>(R) || isa<SymbolicRegion>(R))
- return R;
-
- // We don't know what to make of it. Return a NULL region, which
- // will be interpretted as UnknownVal.
- return NULL;
- }
-
- // Now assume we are casting from pointer to pointer. Other cases should
- // already be handled.
- QualType PointeeTy = CastToTy->getAs<PointerType>()->getPointeeType();
- QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
-
- // Handle casts to void*. We just pass the region through.
- if (CanonPointeeTy.getLocalUnqualifiedType() == Ctx.VoidTy)
- return R;
-
- // Handle casts from compatible types.
- if (R->isBoundable())
- if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
- QualType ObjTy = Ctx.getCanonicalType(TR->getValueType());
- if (CanonPointeeTy == ObjTy)
- return R;
- }
-
- // Process region cast according to the kind of the region being cast.
- switch (R->getKind()) {
- case MemRegion::CXXThisRegionKind:
- case MemRegion::GenericMemSpaceRegionKind:
- case MemRegion::StackLocalsSpaceRegionKind:
- case MemRegion::StackArgumentsSpaceRegionKind:
- case MemRegion::HeapSpaceRegionKind:
- case MemRegion::UnknownSpaceRegionKind:
- case MemRegion::NonStaticGlobalSpaceRegionKind:
- case MemRegion::StaticGlobalSpaceRegionKind: {
- assert(0 && "Invalid region cast");
- break;
- }
-
- case MemRegion::FunctionTextRegionKind:
- case MemRegion::BlockTextRegionKind:
- case MemRegion::BlockDataRegionKind:
- case MemRegion::StringRegionKind:
- // FIXME: Need to handle arbitrary downcasts.
- case MemRegion::SymbolicRegionKind:
- case MemRegion::AllocaRegionKind:
- case MemRegion::CompoundLiteralRegionKind:
- case MemRegion::FieldRegionKind:
- case MemRegion::ObjCIvarRegionKind:
- case MemRegion::VarRegionKind:
- case MemRegion::CXXTempObjectRegionKind:
- case MemRegion::CXXBaseObjectRegionKind:
- return MakeElementRegion(R, PointeeTy);
-
- case MemRegion::ElementRegionKind: {
- // If we are casting from an ElementRegion to another type, the
- // algorithm is as follows:
- //
- // (1) Compute the "raw offset" of the ElementRegion from the
- // base region. This is done by calling 'getAsRawOffset()'.
- //
- // (2a) If we get a 'RegionRawOffset' after calling
- // 'getAsRawOffset()', determine if the absolute offset
- // can be exactly divided into chunks of the size of the
- // casted-pointee type. If so, create a new ElementRegion with
- // the pointee-cast type as the new ElementType and the index
- // being the offset divded by the chunk size. If not, create
- // a new ElementRegion at offset 0 off the raw offset region.
- //
- // (2b) If we don't a get a 'RegionRawOffset' after calling
- // 'getAsRawOffset()', it means that we are at offset 0.
- //
- // FIXME: Handle symbolic raw offsets.
-
- const ElementRegion *elementR = cast<ElementRegion>(R);
- const RegionRawOffset &rawOff = elementR->getAsArrayOffset();
- const MemRegion *baseR = rawOff.getRegion();
-
- // If we cannot compute a raw offset, throw up our hands and return
- // a NULL MemRegion*.
- if (!baseR)
- return NULL;
-
- CharUnits off = CharUnits::fromQuantity(rawOff.getByteOffset());
-
- if (off.isZero()) {
- // Edge case: we are at 0 bytes off the beginning of baseR. We
- // check to see if type we are casting to is the same as the base
- // region. If so, just return the base region.
- if (const TypedRegion *TR = dyn_cast<TypedRegion>(baseR)) {
- QualType ObjTy = Ctx.getCanonicalType(TR->getValueType());
- QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
- if (CanonPointeeTy == ObjTy)
- return baseR;
- }
-
- // Otherwise, create a new ElementRegion at offset 0.
- return MakeElementRegion(baseR, PointeeTy);
- }
-
- // We have a non-zero offset from the base region. We want to determine
- // if the offset can be evenly divided by sizeof(PointeeTy). If so,
- // we create an ElementRegion whose index is that value. Otherwise, we
- // create two ElementRegions, one that reflects a raw offset and the other
- // that reflects the cast.
-
- // Compute the index for the new ElementRegion.
- int64_t newIndex = 0;
- const MemRegion *newSuperR = 0;
-
- // We can only compute sizeof(PointeeTy) if it is a complete type.
- if (IsCompleteType(Ctx, PointeeTy)) {
- // Compute the size in **bytes**.
- CharUnits pointeeTySize = Ctx.getTypeSizeInChars(PointeeTy);
- if (!pointeeTySize.isZero()) {
- // Is the offset a multiple of the size? If so, we can layer the
- // ElementRegion (with elementType == PointeeTy) directly on top of
- // the base region.
- if (off % pointeeTySize == 0) {
- newIndex = off / pointeeTySize;
- newSuperR = baseR;
- }
- }
- }
-
- if (!newSuperR) {
- // Create an intermediate ElementRegion to represent the raw byte.
- // This will be the super region of the final ElementRegion.
- newSuperR = MakeElementRegion(baseR, Ctx.CharTy, off.getQuantity());
- }
-
- return MakeElementRegion(newSuperR, PointeeTy, newIndex);
- }
- }
-
- assert(0 && "unreachable");
- return 0;
-}
-
-
-/// CastRetrievedVal - Used by subclasses of StoreManager to implement
-/// implicit casts that arise from loads from regions that are reinterpreted
-/// as another region.
-SVal StoreManager::CastRetrievedVal(SVal V, const TypedRegion *R,
- QualType castTy, bool performTestOnly) {
-
- if (castTy.isNull())
- return V;
-
- ASTContext &Ctx = svalBuilder.getContext();
-
- if (performTestOnly) {
- // Automatically translate references to pointers.
- QualType T = R->getValueType();
- if (const ReferenceType *RT = T->getAs<ReferenceType>())
- T = Ctx.getPointerType(RT->getPointeeType());
-
- assert(svalBuilder.getContext().hasSameUnqualifiedType(castTy, T));
- return V;
- }
-
- if (const Loc *L = dyn_cast<Loc>(&V))
- return svalBuilder.evalCastL(*L, castTy);
- else if (const NonLoc *NL = dyn_cast<NonLoc>(&V))
- return svalBuilder.evalCastNL(*NL, castTy);
-
- return V;
-}
-
-SVal StoreManager::getLValueFieldOrIvar(const Decl* D, SVal Base) {
- if (Base.isUnknownOrUndef())
- return Base;
-
- Loc BaseL = cast<Loc>(Base);
- const MemRegion* BaseR = 0;
-
- switch (BaseL.getSubKind()) {
- case loc::MemRegionKind:
- BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
- break;
-
- case loc::GotoLabelKind:
- // These are anormal cases. Flag an undefined value.
- return UndefinedVal();
-
- case loc::ConcreteIntKind:
- // While these seem funny, this can happen through casts.
- // FIXME: What we should return is the field offset. For example,
- // add the field offset to the integer value. That way funny things
- // like this work properly: &(((struct foo *) 0xa)->f)
- return Base;
-
- default:
- assert(0 && "Unhandled Base.");
- return Base;
- }
-
- // NOTE: We must have this check first because ObjCIvarDecl is a subclass
- // of FieldDecl.
- if (const ObjCIvarDecl *ID = dyn_cast<ObjCIvarDecl>(D))
- return loc::MemRegionVal(MRMgr.getObjCIvarRegion(ID, BaseR));
-
- return loc::MemRegionVal(MRMgr.getFieldRegion(cast<FieldDecl>(D), BaseR));
-}
-
-SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset,
- SVal Base) {
-
- // If the base is an unknown or undefined value, just return it back.
- // FIXME: For absolute pointer addresses, we just return that value back as
- // well, although in reality we should return the offset added to that
- // value.
- if (Base.isUnknownOrUndef() || isa<loc::ConcreteInt>(Base))
- return Base;
-
- const MemRegion* BaseRegion = cast<loc::MemRegionVal>(Base).getRegion();
-
- // Pointer of any type can be cast and used as array base.
- const ElementRegion *ElemR = dyn_cast<ElementRegion>(BaseRegion);
-
- // Convert the offset to the appropriate size and signedness.
- Offset = cast<NonLoc>(svalBuilder.convertToArrayIndex(Offset));
-
- if (!ElemR) {
- //
- // If the base region is not an ElementRegion, create one.
- // This can happen in the following example:
- //
- // char *p = __builtin_alloc(10);
- // p[1] = 8;
- //
- // Observe that 'p' binds to an AllocaRegion.
- //
- return loc::MemRegionVal(MRMgr.getElementRegion(elementType, Offset,
- BaseRegion, Ctx));
- }
-
- SVal BaseIdx = ElemR->getIndex();
-
- if (!isa<nonloc::ConcreteInt>(BaseIdx))
- return UnknownVal();
-
- const llvm::APSInt& BaseIdxI = cast<nonloc::ConcreteInt>(BaseIdx).getValue();
-
- // Only allow non-integer offsets if the base region has no offset itself.
- // FIXME: This is a somewhat arbitrary restriction. We should be using
- // SValBuilder here to add the two offsets without checking their types.
- if (!isa<nonloc::ConcreteInt>(Offset)) {
- if (isa<ElementRegion>(BaseRegion->StripCasts()))
- return UnknownVal();
-
- return loc::MemRegionVal(MRMgr.getElementRegion(elementType, Offset,
- ElemR->getSuperRegion(),
- Ctx));
- }
-
- const llvm::APSInt& OffI = cast<nonloc::ConcreteInt>(Offset).getValue();
- assert(BaseIdxI.isSigned());
-
- // Compute the new index.
- nonloc::ConcreteInt NewIdx(svalBuilder.getBasicValueFactory().getValue(BaseIdxI +
- OffI));
-
- // Construct the new ElementRegion.
- const MemRegion *ArrayR = ElemR->getSuperRegion();
- return loc::MemRegionVal(MRMgr.getElementRegion(elementType, NewIdx, ArrayR,
- Ctx));
-}
Removed: cfe/trunk/lib/Checker/StreamChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/StreamChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/StreamChecker.cpp (original)
+++ cfe/trunk/lib/Checker/StreamChecker.cpp (removed)
@@ -1,463 +0,0 @@
-//===-- StreamChecker.cpp -----------------------------------------*- C++ -*--//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines checkers that model and check stream handling functions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineExperimentalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRState.h"
-#include "clang/GR/PathSensitive/GRStateTrait.h"
-#include "clang/GR/PathSensitive/SymbolManager.h"
-#include "llvm/ADT/ImmutableMap.h"
-
-using namespace clang;
-
-namespace {
-
-struct StreamState {
- enum Kind { Opened, Closed, OpenFailed, Escaped } K;
- const Stmt *S;
-
- StreamState(Kind k, const Stmt *s) : K(k), S(s) {}
-
- bool isOpened() const { return K == Opened; }
- bool isClosed() const { return K == Closed; }
- //bool isOpenFailed() const { return K == OpenFailed; }
- //bool isEscaped() const { return K == Escaped; }
-
- bool operator==(const StreamState &X) const {
- return K == X.K && S == X.S;
- }
-
- static StreamState getOpened(const Stmt *s) { return StreamState(Opened, s); }
- static StreamState getClosed(const Stmt *s) { return StreamState(Closed, s); }
- static StreamState getOpenFailed(const Stmt *s) {
- return StreamState(OpenFailed, s);
- }
- static StreamState getEscaped(const Stmt *s) {
- return StreamState(Escaped, s);
- }
-
- void Profile(llvm::FoldingSetNodeID &ID) const {
- ID.AddInteger(K);
- ID.AddPointer(S);
- }
-};
-
-class StreamChecker : public CheckerVisitor<StreamChecker> {
- IdentifierInfo *II_fopen, *II_tmpfile, *II_fclose, *II_fread, *II_fwrite,
- *II_fseek, *II_ftell, *II_rewind, *II_fgetpos, *II_fsetpos,
- *II_clearerr, *II_feof, *II_ferror, *II_fileno;
- BuiltinBug *BT_nullfp, *BT_illegalwhence, *BT_doubleclose, *BT_ResourceLeak;
-
-public:
- StreamChecker()
- : II_fopen(0), II_tmpfile(0) ,II_fclose(0), II_fread(0), II_fwrite(0),
- II_fseek(0), II_ftell(0), II_rewind(0), II_fgetpos(0), II_fsetpos(0),
- II_clearerr(0), II_feof(0), II_ferror(0), II_fileno(0),
- BT_nullfp(0), BT_illegalwhence(0), BT_doubleclose(0),
- BT_ResourceLeak(0) {}
-
- static void *getTag() {
- static int x;
- return &x;
- }
-
- virtual bool evalCallExpr(CheckerContext &C, const CallExpr *CE);
- void evalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper);
- void evalEndPath(GREndPathNodeBuilder &B, void *tag, GRExprEngine &Eng);
- void PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S);
-
-private:
- void Fopen(CheckerContext &C, const CallExpr *CE);
- void Tmpfile(CheckerContext &C, const CallExpr *CE);
- void Fclose(CheckerContext &C, const CallExpr *CE);
- void Fread(CheckerContext &C, const CallExpr *CE);
- void Fwrite(CheckerContext &C, const CallExpr *CE);
- void Fseek(CheckerContext &C, const CallExpr *CE);
- void Ftell(CheckerContext &C, const CallExpr *CE);
- void Rewind(CheckerContext &C, const CallExpr *CE);
- void Fgetpos(CheckerContext &C, const CallExpr *CE);
- void Fsetpos(CheckerContext &C, const CallExpr *CE);
- void Clearerr(CheckerContext &C, const CallExpr *CE);
- void Feof(CheckerContext &C, const CallExpr *CE);
- void Ferror(CheckerContext &C, const CallExpr *CE);
- void Fileno(CheckerContext &C, const CallExpr *CE);
-
- void OpenFileAux(CheckerContext &C, const CallExpr *CE);
-
- const GRState *CheckNullStream(SVal SV, const GRState *state,
- CheckerContext &C);
- const GRState *CheckDoubleClose(const CallExpr *CE, const GRState *state,
- CheckerContext &C);
-};
-
-} // end anonymous namespace
-
-namespace clang {
- template <>
- struct GRStateTrait<StreamState>
- : public GRStatePartialTrait<llvm::ImmutableMap<SymbolRef, StreamState> > {
- static void *GDMIndex() { return StreamChecker::getTag(); }
- };
-}
-
-void clang::RegisterStreamChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new StreamChecker());
-}
-
-bool StreamChecker::evalCallExpr(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- const Expr *Callee = CE->getCallee();
- SVal L = state->getSVal(Callee);
- const FunctionDecl *FD = L.getAsFunctionDecl();
- if (!FD)
- return false;
-
- ASTContext &Ctx = C.getASTContext();
- if (!II_fopen)
- II_fopen = &Ctx.Idents.get("fopen");
- if (!II_tmpfile)
- II_tmpfile = &Ctx.Idents.get("tmpfile");
- if (!II_fclose)
- II_fclose = &Ctx.Idents.get("fclose");
- if (!II_fread)
- II_fread = &Ctx.Idents.get("fread");
- if (!II_fwrite)
- II_fwrite = &Ctx.Idents.get("fwrite");
- if (!II_fseek)
- II_fseek = &Ctx.Idents.get("fseek");
- if (!II_ftell)
- II_ftell = &Ctx.Idents.get("ftell");
- if (!II_rewind)
- II_rewind = &Ctx.Idents.get("rewind");
- if (!II_fgetpos)
- II_fgetpos = &Ctx.Idents.get("fgetpos");
- if (!II_fsetpos)
- II_fsetpos = &Ctx.Idents.get("fsetpos");
- if (!II_clearerr)
- II_clearerr = &Ctx.Idents.get("clearerr");
- if (!II_feof)
- II_feof = &Ctx.Idents.get("feof");
- if (!II_ferror)
- II_ferror = &Ctx.Idents.get("ferror");
- if (!II_fileno)
- II_fileno = &Ctx.Idents.get("fileno");
-
- if (FD->getIdentifier() == II_fopen) {
- Fopen(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_tmpfile) {
- Tmpfile(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fclose) {
- Fclose(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fread) {
- Fread(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fwrite) {
- Fwrite(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fseek) {
- Fseek(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_ftell) {
- Ftell(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_rewind) {
- Rewind(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fgetpos) {
- Fgetpos(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fsetpos) {
- Fsetpos(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_clearerr) {
- Clearerr(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_feof) {
- Feof(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_ferror) {
- Ferror(C, CE);
- return true;
- }
- if (FD->getIdentifier() == II_fileno) {
- Fileno(C, CE);
- return true;
- }
-
- return false;
-}
-
-void StreamChecker::Fopen(CheckerContext &C, const CallExpr *CE) {
- OpenFileAux(C, CE);
-}
-
-void StreamChecker::Tmpfile(CheckerContext &C, const CallExpr *CE) {
- OpenFileAux(C, CE);
-}
-
-void StreamChecker::OpenFileAux(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- unsigned Count = C.getNodeBuilder().getCurrentBlockCount();
- SValBuilder &svalBuilder = C.getSValBuilder();
- DefinedSVal RetVal =
- cast<DefinedSVal>(svalBuilder.getConjuredSymbolVal(0, CE, Count));
- state = state->BindExpr(CE, RetVal);
-
- ConstraintManager &CM = C.getConstraintManager();
- // Bifurcate the state into two: one with a valid FILE* pointer, the other
- // with a NULL.
- const GRState *stateNotNull, *stateNull;
- llvm::tie(stateNotNull, stateNull) = CM.assumeDual(state, RetVal);
-
- if (SymbolRef Sym = RetVal.getAsSymbol()) {
- // if RetVal is not NULL, set the symbol's state to Opened.
- stateNotNull =
- stateNotNull->set<StreamState>(Sym,StreamState::getOpened(CE));
- stateNull =
- stateNull->set<StreamState>(Sym, StreamState::getOpenFailed(CE));
-
- C.addTransition(stateNotNull);
- C.addTransition(stateNull);
- }
-}
-
-void StreamChecker::Fclose(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = CheckDoubleClose(CE, C.getState(), C);
- if (state)
- C.addTransition(state);
-}
-
-void StreamChecker::Fread(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(3)), state, C))
- return;
-}
-
-void StreamChecker::Fwrite(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(3)), state, C))
- return;
-}
-
-void StreamChecker::Fseek(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!(state = CheckNullStream(state->getSVal(CE->getArg(0)), state, C)))
- return;
- // Check the legality of the 'whence' argument of 'fseek'.
- SVal Whence = state->getSVal(CE->getArg(2));
- const nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&Whence);
-
- if (!CI)
- return;
-
- int64_t x = CI->getValue().getSExtValue();
- if (x >= 0 && x <= 2)
- return;
-
- if (ExplodedNode *N = C.generateNode(state)) {
- if (!BT_illegalwhence)
- BT_illegalwhence = new BuiltinBug("Illegal whence argument",
- "The whence argument to fseek() should be "
- "SEEK_SET, SEEK_END, or SEEK_CUR.");
- BugReport *R = new BugReport(*BT_illegalwhence,
- BT_illegalwhence->getDescription(), N);
- C.EmitReport(R);
- }
-}
-
-void StreamChecker::Ftell(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Rewind(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Fgetpos(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Fsetpos(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Clearerr(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Feof(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Ferror(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-void StreamChecker::Fileno(CheckerContext &C, const CallExpr *CE) {
- const GRState *state = C.getState();
- if (!CheckNullStream(state->getSVal(CE->getArg(0)), state, C))
- return;
-}
-
-const GRState *StreamChecker::CheckNullStream(SVal SV, const GRState *state,
- CheckerContext &C) {
- const DefinedSVal *DV = dyn_cast<DefinedSVal>(&SV);
- if (!DV)
- return 0;
-
- ConstraintManager &CM = C.getConstraintManager();
- const GRState *stateNotNull, *stateNull;
- llvm::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
-
- if (!stateNotNull && stateNull) {
- if (ExplodedNode *N = C.generateSink(stateNull)) {
- if (!BT_nullfp)
- BT_nullfp = new BuiltinBug("NULL stream pointer",
- "Stream pointer might be NULL.");
- BugReport *R =new BugReport(*BT_nullfp, BT_nullfp->getDescription(), N);
- C.EmitReport(R);
- }
- return 0;
- }
- return stateNotNull;
-}
-
-const GRState *StreamChecker::CheckDoubleClose(const CallExpr *CE,
- const GRState *state,
- CheckerContext &C) {
- SymbolRef Sym = state->getSVal(CE->getArg(0)).getAsSymbol();
- if (!Sym)
- return state;
-
- const StreamState *SS = state->get<StreamState>(Sym);
-
- // If the file stream is not tracked, return.
- if (!SS)
- return state;
-
- // Check: Double close a File Descriptor could cause undefined behaviour.
- // Conforming to man-pages
- if (SS->isClosed()) {
- ExplodedNode *N = C.generateSink();
- if (N) {
- if (!BT_doubleclose)
- BT_doubleclose = new BuiltinBug("Double fclose",
- "Try to close a file Descriptor already"
- " closed. Cause undefined behaviour.");
- BugReport *R = new BugReport(*BT_doubleclose,
- BT_doubleclose->getDescription(), N);
- C.EmitReport(R);
- }
- return NULL;
- }
-
- // Close the File Descriptor.
- return state->set<StreamState>(Sym, StreamState::getClosed(CE));
-}
-
-void StreamChecker::evalDeadSymbols(CheckerContext &C,SymbolReaper &SymReaper) {
- for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
- E = SymReaper.dead_end(); I != E; ++I) {
- SymbolRef Sym = *I;
- const GRState *state = C.getState();
- const StreamState *SS = state->get<StreamState>(Sym);
- if (!SS)
- return;
-
- if (SS->isOpened()) {
- ExplodedNode *N = C.generateSink();
- if (N) {
- if (!BT_ResourceLeak)
- BT_ResourceLeak = new BuiltinBug("Resource Leak",
- "Opened File never closed. Potential Resource leak.");
- BugReport *R = new BugReport(*BT_ResourceLeak,
- BT_ResourceLeak->getDescription(), N);
- C.EmitReport(R);
- }
- }
- }
-}
-
-void StreamChecker::evalEndPath(GREndPathNodeBuilder &B, void *tag,
- GRExprEngine &Eng) {
- SaveAndRestore<bool> OldHasGen(B.HasGeneratedNode);
- const GRState *state = B.getState();
- typedef llvm::ImmutableMap<SymbolRef, StreamState> SymMap;
- SymMap M = state->get<StreamState>();
-
- for (SymMap::iterator I = M.begin(), E = M.end(); I != E; ++I) {
- StreamState SS = I->second;
- if (SS.isOpened()) {
- ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
- if (N) {
- if (!BT_ResourceLeak)
- BT_ResourceLeak = new BuiltinBug("Resource Leak",
- "Opened File never closed. Potential Resource leak.");
- BugReport *R = new BugReport(*BT_ResourceLeak,
- BT_ResourceLeak->getDescription(), N);
- Eng.getBugReporter().EmitReport(R);
- }
- }
- }
-}
-
-void StreamChecker::PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S) {
- const Expr *RetE = S->getRetValue();
- if (!RetE)
- return;
-
- const GRState *state = C.getState();
- SymbolRef Sym = state->getSVal(RetE).getAsSymbol();
-
- if (!Sym)
- return;
-
- const StreamState *SS = state->get<StreamState>(Sym);
- if(!SS)
- return;
-
- if (SS->isOpened())
- state = state->set<StreamState>(Sym, StreamState::getEscaped(S));
-
- C.addTransition(state);
-}
Removed: cfe/trunk/lib/Checker/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SymbolManager.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Checker/SymbolManager.cpp (removed)
@@ -1,342 +0,0 @@
-//== SymbolManager.h - Management of Symbolic Values ------------*- C++ -*--==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines SymbolManager, a class that manages symbolic values
-// created for use by GRExprEngine and related classes.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/PathSensitive/SymbolManager.h"
-#include "clang/Analysis/Analyses/LiveVariables.h"
-#include "clang/GR/PathSensitive/MemRegion.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace clang;
-
-void SymExpr::dump() const {
- dumpToStream(llvm::errs());
-}
-
-static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) {
- switch (Op) {
- default:
- assert(false && "operator printing not implemented");
- break;
- case BO_Mul: os << '*' ; break;
- case BO_Div: os << '/' ; break;
- case BO_Rem: os << '%' ; break;
- case BO_Add: os << '+' ; break;
- case BO_Sub: os << '-' ; break;
- case BO_Shl: os << "<<" ; break;
- case BO_Shr: os << ">>" ; break;
- case BO_LT: os << "<" ; break;
- case BO_GT: os << '>' ; break;
- case BO_LE: os << "<=" ; break;
- case BO_GE: os << ">=" ; break;
- case BO_EQ: os << "==" ; break;
- case BO_NE: os << "!=" ; break;
- case BO_And: os << '&' ; break;
- case BO_Xor: os << '^' ; break;
- case BO_Or: os << '|' ; break;
- }
-}
-
-void SymIntExpr::dumpToStream(llvm::raw_ostream& os) const {
- os << '(';
- getLHS()->dumpToStream(os);
- os << ") ";
- print(os, getOpcode());
- os << ' ' << getRHS().getZExtValue();
- if (getRHS().isUnsigned()) os << 'U';
-}
-
-void SymSymExpr::dumpToStream(llvm::raw_ostream& os) const {
- os << '(';
- getLHS()->dumpToStream(os);
- os << ") ";
- os << '(';
- getRHS()->dumpToStream(os);
- os << ')';
-}
-
-void SymbolConjured::dumpToStream(llvm::raw_ostream& os) const {
- os << "conj_$" << getSymbolID() << '{' << T.getAsString() << '}';
-}
-
-void SymbolDerived::dumpToStream(llvm::raw_ostream& os) const {
- os << "derived_$" << getSymbolID() << '{'
- << getParentSymbol() << ',' << getRegion() << '}';
-}
-
-void SymbolExtent::dumpToStream(llvm::raw_ostream& os) const {
- os << "extent_$" << getSymbolID() << '{' << getRegion() << '}';
-}
-
-void SymbolMetadata::dumpToStream(llvm::raw_ostream& os) const {
- os << "meta_$" << getSymbolID() << '{'
- << getRegion() << ',' << T.getAsString() << '}';
-}
-
-void SymbolRegionValue::dumpToStream(llvm::raw_ostream& os) const {
- os << "reg_$" << getSymbolID() << "<" << R << ">";
-}
-
-const SymbolRegionValue*
-SymbolManager::getRegionValueSymbol(const TypedRegion* R) {
- llvm::FoldingSetNodeID profile;
- SymbolRegionValue::Profile(profile, R);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
- SD = (SymExpr*) BPAlloc.Allocate<SymbolRegionValue>();
- new (SD) SymbolRegionValue(SymbolCounter, R);
- DataSet.InsertNode(SD, InsertPos);
- ++SymbolCounter;
- }
-
- return cast<SymbolRegionValue>(SD);
-}
-
-const SymbolConjured*
-SymbolManager::getConjuredSymbol(const Stmt* E, QualType T, unsigned Count,
- const void* SymbolTag) {
-
- llvm::FoldingSetNodeID profile;
- SymbolConjured::Profile(profile, E, T, Count, SymbolTag);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
- SD = (SymExpr*) BPAlloc.Allocate<SymbolConjured>();
- new (SD) SymbolConjured(SymbolCounter, E, T, Count, SymbolTag);
- DataSet.InsertNode(SD, InsertPos);
- ++SymbolCounter;
- }
-
- return cast<SymbolConjured>(SD);
-}
-
-const SymbolDerived*
-SymbolManager::getDerivedSymbol(SymbolRef parentSymbol,
- const TypedRegion *R) {
-
- llvm::FoldingSetNodeID profile;
- SymbolDerived::Profile(profile, parentSymbol, R);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
- SD = (SymExpr*) BPAlloc.Allocate<SymbolDerived>();
- new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
- DataSet.InsertNode(SD, InsertPos);
- ++SymbolCounter;
- }
-
- return cast<SymbolDerived>(SD);
-}
-
-const SymbolExtent*
-SymbolManager::getExtentSymbol(const SubRegion *R) {
- llvm::FoldingSetNodeID profile;
- SymbolExtent::Profile(profile, R);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
- SD = (SymExpr*) BPAlloc.Allocate<SymbolExtent>();
- new (SD) SymbolExtent(SymbolCounter, R);
- DataSet.InsertNode(SD, InsertPos);
- ++SymbolCounter;
- }
-
- return cast<SymbolExtent>(SD);
-}
-
-const SymbolMetadata*
-SymbolManager::getMetadataSymbol(const MemRegion* R, const Stmt* S, QualType T,
- unsigned Count, const void* SymbolTag) {
-
- llvm::FoldingSetNodeID profile;
- SymbolMetadata::Profile(profile, R, S, T, Count, SymbolTag);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
- SD = (SymExpr*) BPAlloc.Allocate<SymbolMetadata>();
- new (SD) SymbolMetadata(SymbolCounter, R, S, T, Count, SymbolTag);
- DataSet.InsertNode(SD, InsertPos);
- ++SymbolCounter;
- }
-
- return cast<SymbolMetadata>(SD);
-}
-
-const SymIntExpr *SymbolManager::getSymIntExpr(const SymExpr *lhs,
- BinaryOperator::Opcode op,
- const llvm::APSInt& v,
- QualType t) {
- llvm::FoldingSetNodeID ID;
- SymIntExpr::Profile(ID, lhs, op, v, t);
- void *InsertPos;
- SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
-
- if (!data) {
- data = (SymIntExpr*) BPAlloc.Allocate<SymIntExpr>();
- new (data) SymIntExpr(lhs, op, v, t);
- DataSet.InsertNode(data, InsertPos);
- }
-
- return cast<SymIntExpr>(data);
-}
-
-const SymSymExpr *SymbolManager::getSymSymExpr(const SymExpr *lhs,
- BinaryOperator::Opcode op,
- const SymExpr *rhs,
- QualType t) {
- llvm::FoldingSetNodeID ID;
- SymSymExpr::Profile(ID, lhs, op, rhs, t);
- void *InsertPos;
- SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
-
- if (!data) {
- data = (SymSymExpr*) BPAlloc.Allocate<SymSymExpr>();
- new (data) SymSymExpr(lhs, op, rhs, t);
- DataSet.InsertNode(data, InsertPos);
- }
-
- return cast<SymSymExpr>(data);
-}
-
-QualType SymbolConjured::getType(ASTContext&) const {
- return T;
-}
-
-QualType SymbolDerived::getType(ASTContext& Ctx) const {
- return R->getValueType();
-}
-
-QualType SymbolExtent::getType(ASTContext& Ctx) const {
- return Ctx.getSizeType();
-}
-
-QualType SymbolMetadata::getType(ASTContext&) const {
- return T;
-}
-
-QualType SymbolRegionValue::getType(ASTContext& C) const {
- return R->getValueType();
-}
-
-SymbolManager::~SymbolManager() {}
-
-bool SymbolManager::canSymbolicate(QualType T) {
- if (Loc::IsLocType(T))
- return true;
-
- if (T->isIntegerType())
- return T->isScalarType();
-
- if (T->isRecordType())
- return true;
-
- return false;
-}
-
-void SymbolReaper::markLive(SymbolRef sym) {
- TheLiving.insert(sym);
- TheDead.erase(sym);
-}
-
-void SymbolReaper::markInUse(SymbolRef sym) {
- if (isa<SymbolMetadata>(sym))
- MetadataInUse.insert(sym);
-}
-
-bool SymbolReaper::maybeDead(SymbolRef sym) {
- if (isLive(sym))
- return false;
-
- TheDead.insert(sym);
- return true;
-}
-
-static bool IsLiveRegion(SymbolReaper &Reaper, const MemRegion *MR) {
- MR = MR->getBaseRegion();
-
- if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
- return Reaper.isLive(SR->getSymbol());
-
- if (const VarRegion *VR = dyn_cast<VarRegion>(MR))
- return Reaper.isLive(VR);
-
- // FIXME: This is a gross over-approximation. What we really need is a way to
- // tell if anything still refers to this region. Unlike SymbolicRegions,
- // AllocaRegions don't have associated symbols, though, so we don't actually
- // have a way to track their liveness.
- if (isa<AllocaRegion>(MR))
- return true;
-
- if (isa<CXXThisRegion>(MR))
- return true;
-
- if (isa<MemSpaceRegion>(MR))
- return true;
-
- return false;
-}
-
-bool SymbolReaper::isLive(SymbolRef sym) {
- if (TheLiving.count(sym))
- return true;
-
- if (const SymbolDerived *derived = dyn_cast<SymbolDerived>(sym)) {
- if (isLive(derived->getParentSymbol())) {
- markLive(sym);
- return true;
- }
- return false;
- }
-
- if (const SymbolExtent *extent = dyn_cast<SymbolExtent>(sym)) {
- if (IsLiveRegion(*this, extent->getRegion())) {
- markLive(sym);
- return true;
- }
- return false;
- }
-
- if (const SymbolMetadata *metadata = dyn_cast<SymbolMetadata>(sym)) {
- if (MetadataInUse.count(sym)) {
- if (IsLiveRegion(*this, metadata->getRegion())) {
- markLive(sym);
- MetadataInUse.erase(sym);
- return true;
- }
- }
- return false;
- }
-
- // Interogate the symbol. It may derive from an input value to
- // the analyzed function/method.
- return isa<SymbolRegionValue>(sym);
-}
-
-bool SymbolReaper::isLive(const Stmt* ExprVal) const {
- return LCtx->getAnalysisContext()->getRelaxedLiveVariables()->
- isLive(Loc, ExprVal);
-}
-
-bool SymbolReaper::isLive(const VarRegion *VR) const {
- const StackFrameContext *VarContext = VR->getStackFrame();
- const StackFrameContext *CurrentContext = LCtx->getCurrentStackFrame();
-
- if (VarContext == CurrentContext)
- return LCtx->getAnalysisContext()->getRelaxedLiveVariables()->
- isLive(Loc, VR->getDecl());
-
- return VarContext->isParentOf(CurrentContext);
-}
-
-SymbolVisitor::~SymbolVisitor() {}
Removed: cfe/trunk/lib/Checker/TextPathDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/TextPathDiagnostics.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/TextPathDiagnostics.cpp (original)
+++ cfe/trunk/lib/Checker/TextPathDiagnostics.cpp (removed)
@@ -1,69 +0,0 @@
-//===--- TextPathDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the TextPathDiagnostics object.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/GR/PathDiagnosticClients.h"
-#include "clang/GR/BugReporter/PathDiagnostic.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace clang;
-using namespace llvm;
-
-namespace {
-
-/// \brief Simple path diagnostic client used for outputting as diagnostic notes
-/// the sequence of events.
-class TextPathDiagnostics : public PathDiagnosticClient {
- const std::string OutputFile;
- Diagnostic &Diag;
-
-public:
- TextPathDiagnostics(const std::string& output, Diagnostic &diag)
- : OutputFile(output), Diag(diag) {}
-
- void HandlePathDiagnostic(const PathDiagnostic* D);
-
- void FlushDiagnostics(llvm::SmallVectorImpl<std::string> *FilesMade) { }
-
- virtual llvm::StringRef getName() const {
- return "TextPathDiagnostics";
- }
-
- PathGenerationScheme getGenerationScheme() const { return Minimal; }
- bool supportsLogicalOpControlFlow() const { return true; }
- bool supportsAllBlockEdges() const { return true; }
- virtual bool useVerboseDescription() const { return true; }
-};
-
-} // end anonymous namespace
-
-PathDiagnosticClient*
-clang::createTextPathDiagnosticClient(const std::string& out,
- const Preprocessor &PP) {
- return new TextPathDiagnostics(out, PP.getDiagnostics());
-}
-
-void TextPathDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
- if (!D)
- return;
-
- if (D->empty()) {
- delete D;
- return;
- }
-
- for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I) {
- unsigned diagID = Diag.getDiagnosticIDs()->getCustomDiagID(
- DiagnosticIDs::Note, I->getString());
- Diag.Report(I->getLocation().asLocation(), diagID);
- }
-}
Removed: cfe/trunk/lib/Checker/UndefBranchChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UndefBranchChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UndefBranchChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UndefBranchChecker.cpp (removed)
@@ -1,119 +0,0 @@
-//=== UndefBranchChecker.cpp -----------------------------------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines UndefBranchChecker, which checks for undefined branch
-// condition.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/Checker.h"
-
-using namespace clang;
-
-namespace {
-
-class UndefBranchChecker : public Checker {
- BuiltinBug *BT;
-
- struct FindUndefExpr {
- GRStateManager& VM;
- const GRState* St;
-
- FindUndefExpr(GRStateManager& V, const GRState* S) : VM(V), St(S) {}
-
- const Expr* FindExpr(const Expr* Ex) {
- if (!MatchesCriteria(Ex))
- return 0;
-
- for (Stmt::const_child_iterator I = Ex->child_begin(),
- E = Ex->child_end();I!=E;++I)
- if (const Expr* ExI = dyn_cast_or_null<Expr>(*I)) {
- const Expr* E2 = FindExpr(ExI);
- if (E2) return E2;
- }
-
- return Ex;
- }
-
- bool MatchesCriteria(const Expr* Ex) { return St->getSVal(Ex).isUndef(); }
- };
-
-public:
- UndefBranchChecker() : BT(0) {}
- static void *getTag();
- void VisitBranchCondition(GRBranchNodeBuilder &Builder, GRExprEngine &Eng,
- const Stmt *Condition, void *tag);
-};
-
-}
-
-void clang::RegisterUndefBranchChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UndefBranchChecker());
-}
-
-void *UndefBranchChecker::getTag() {
- static int x;
- return &x;
-}
-
-void UndefBranchChecker::VisitBranchCondition(GRBranchNodeBuilder &Builder,
- GRExprEngine &Eng,
- const Stmt *Condition, void *tag){
- const GRState *state = Builder.getState();
- SVal X = state->getSVal(Condition);
- if (X.isUndef()) {
- ExplodedNode *N = Builder.generateNode(state, true);
- if (N) {
- N->markAsSink();
- if (!BT)
- BT = new BuiltinBug("Branch condition evaluates to a garbage value");
-
- // What's going on here: we want to highlight the subexpression of the
- // condition that is the most likely source of the "uninitialized
- // branch condition." We do a recursive walk of the condition's
- // subexpressions and roughly look for the most nested subexpression
- // that binds to Undefined. We then highlight that expression's range.
- BlockEdge B = cast<BlockEdge>(N->getLocation());
- const Expr* Ex = cast<Expr>(B.getSrc()->getTerminatorCondition());
- assert (Ex && "Block must have a terminator.");
-
- // Get the predecessor node and check if is a PostStmt with the Stmt
- // being the terminator condition. We want to inspect the state
- // of that node instead because it will contain main information about
- // the subexpressions.
- assert (!N->pred_empty());
-
- // Note: any predecessor will do. They should have identical state,
- // since all the BlockEdge did was act as an error sink since the value
- // had to already be undefined.
- ExplodedNode *PrevN = *N->pred_begin();
- ProgramPoint P = PrevN->getLocation();
- const GRState* St = N->getState();
-
- if (PostStmt* PS = dyn_cast<PostStmt>(&P))
- if (PS->getStmt() == Ex)
- St = PrevN->getState();
-
- FindUndefExpr FindIt(Eng.getStateManager(), St);
- Ex = FindIt.FindExpr(Ex);
-
- // Emit the bug report.
- EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getDescription(),N);
- R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, Ex);
- R->addRange(Ex->getSourceRange());
-
- Eng.getBugReporter().EmitReport(R);
- }
-
- Builder.markInfeasible(true);
- Builder.markInfeasible(false);
- }
-}
Removed: cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp (removed)
@@ -1,101 +0,0 @@
-// UndefCapturedBlockVarChecker.cpp - Uninitialized captured vars -*- C++ -*-=//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This checker detects blocks that capture uninitialized values.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace clang;
-
-namespace {
-class UndefCapturedBlockVarChecker
- : public CheckerVisitor<UndefCapturedBlockVarChecker> {
- BugType *BT;
-
-public:
- UndefCapturedBlockVarChecker() : BT(0) {}
- static void *getTag() { static int tag = 0; return &tag; }
- void PostVisitBlockExpr(CheckerContext &C, const BlockExpr *BE);
-};
-} // end anonymous namespace
-
-void clang::RegisterUndefCapturedBlockVarChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UndefCapturedBlockVarChecker());
-}
-
-static const BlockDeclRefExpr *FindBlockDeclRefExpr(const Stmt *S,
- const VarDecl *VD){
- if (const BlockDeclRefExpr *BR = dyn_cast<BlockDeclRefExpr>(S))
- if (BR->getDecl() == VD)
- return BR;
-
- for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
- I!=E; ++I)
- if (const Stmt *child = *I) {
- const BlockDeclRefExpr *BR = FindBlockDeclRefExpr(child, VD);
- if (BR)
- return BR;
- }
-
- return NULL;
-}
-
-void
-UndefCapturedBlockVarChecker::PostVisitBlockExpr(CheckerContext &C,
- const BlockExpr *BE) {
- if (!BE->hasBlockDeclRefExprs())
- return;
-
- const GRState *state = C.getState();
- const BlockDataRegion *R =
- cast<BlockDataRegion>(state->getSVal(BE).getAsRegion());
-
- BlockDataRegion::referenced_vars_iterator I = R->referenced_vars_begin(),
- E = R->referenced_vars_end();
-
- for (; I != E; ++I) {
- // This VarRegion is the region associated with the block; we need
- // the one associated with the encompassing context.
- const VarRegion *VR = *I;
- const VarDecl *VD = VR->getDecl();
-
- if (VD->getAttr<BlocksAttr>() || !VD->hasLocalStorage())
- continue;
-
- // Get the VarRegion associated with VD in the local stack frame.
- const LocationContext *LC = C.getPredecessor()->getLocationContext();
- VR = C.getSValBuilder().getRegionManager().getVarRegion(VD, LC);
-
- if (state->getSVal(VR).isUndef())
- if (ExplodedNode *N = C.generateSink()) {
- if (!BT)
- BT = new BuiltinBug("Captured block variable is uninitialized");
-
- // Generate a bug report.
- llvm::SmallString<128> buf;
- llvm::raw_svector_ostream os(buf);
-
- os << "Variable '" << VD->getName() << "' is captured by block with "
- "a garbage value";
-
- EnhancedBugReport *R = new EnhancedBugReport(*BT, os.str(), N);
- if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD))
- R->addRange(Ex->getSourceRange());
- R->addVisitorCreator(bugreporter::registerFindLastStore, VR);
- // need location of block
- C.EmitReport(R);
- }
- }
-}
Removed: cfe/trunk/lib/Checker/UndefResultChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UndefResultChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UndefResultChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UndefResultChecker.cpp (removed)
@@ -1,86 +0,0 @@
-//=== UndefResultChecker.cpp ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines UndefResultChecker, a builtin check in GRExprEngine that
-// performs checks for undefined results of non-assignment binary operators.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-
-using namespace clang;
-
-namespace {
-class UndefResultChecker
- : public CheckerVisitor<UndefResultChecker> {
-
- BugType *BT;
-
-public:
- UndefResultChecker() : BT(0) {}
- static void *getTag() { static int tag = 0; return &tag; }
- void PostVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
-};
-} // end anonymous namespace
-
-void clang::RegisterUndefResultChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UndefResultChecker());
-}
-
-void UndefResultChecker::PostVisitBinaryOperator(CheckerContext &C,
- const BinaryOperator *B) {
- const GRState *state = C.getState();
- if (state->getSVal(B).isUndef()) {
- // Generate an error node.
- ExplodedNode *N = C.generateSink();
- if (!N)
- return;
-
- if (!BT)
- BT = new BuiltinBug("Result of operation is garbage or undefined");
-
- llvm::SmallString<256> sbuf;
- llvm::raw_svector_ostream OS(sbuf);
- const Expr *Ex = NULL;
- bool isLeft = true;
-
- if (state->getSVal(B->getLHS()).isUndef()) {
- Ex = B->getLHS()->IgnoreParenCasts();
- isLeft = true;
- }
- else if (state->getSVal(B->getRHS()).isUndef()) {
- Ex = B->getRHS()->IgnoreParenCasts();
- isLeft = false;
- }
-
- if (Ex) {
- OS << "The " << (isLeft ? "left" : "right")
- << " operand of '"
- << BinaryOperator::getOpcodeStr(B->getOpcode())
- << "' is a garbage value";
- }
- else {
- // Neither operand was undefined, but the result is undefined.
- OS << "The result of the '"
- << BinaryOperator::getOpcodeStr(B->getOpcode())
- << "' expression is undefined";
- }
- EnhancedBugReport *report = new EnhancedBugReport(*BT, OS.str(), N);
- if (Ex) {
- report->addRange(Ex->getSourceRange());
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, Ex);
- }
- else
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, B);
- C.EmitReport(report);
- }
-}
Removed: cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp (removed)
@@ -1,56 +0,0 @@
-//===--- UndefinedArraySubscriptChecker.h ----------------------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines UndefinedArraySubscriptChecker, a builtin check in GRExprEngine
-// that performs checks for undefined array subscripts.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-
-using namespace clang;
-
-namespace {
-class UndefinedArraySubscriptChecker
- : public CheckerVisitor<UndefinedArraySubscriptChecker> {
- BugType *BT;
-public:
- UndefinedArraySubscriptChecker() : BT(0) {}
- static void *getTag() {
- static int x = 0;
- return &x;
- }
- void PreVisitArraySubscriptExpr(CheckerContext &C,
- const ArraySubscriptExpr *A);
-};
-} // end anonymous namespace
-
-void clang::RegisterUndefinedArraySubscriptChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UndefinedArraySubscriptChecker());
-}
-
-void
-UndefinedArraySubscriptChecker::PreVisitArraySubscriptExpr(CheckerContext &C,
- const ArraySubscriptExpr *A) {
- if (C.getState()->getSVal(A->getIdx()).isUndef()) {
- if (ExplodedNode *N = C.generateSink()) {
- if (!BT)
- BT = new BuiltinBug("Array subscript is undefined");
-
- // Generate a report for this bug.
- EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getName(), N);
- R->addRange(A->getIdx()->getSourceRange());
- R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
- A->getIdx());
- C.EmitReport(R);
- }
- }
-}
Removed: cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp (removed)
@@ -1,93 +0,0 @@
-//===--- UndefinedAssignmentChecker.h ---------------------------*- C++ -*--==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines UndefinedAssginmentChecker, a builtin check in GRExprEngine that
-// checks for assigning undefined values.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-
-using namespace clang;
-
-namespace {
-class UndefinedAssignmentChecker
- : public CheckerVisitor<UndefinedAssignmentChecker> {
- BugType *BT;
-public:
- UndefinedAssignmentChecker() : BT(0) {}
- static void *getTag();
- virtual void PreVisitBind(CheckerContext &C, const Stmt *StoreE,
- SVal location, SVal val);
-};
-}
-
-void clang::RegisterUndefinedAssignmentChecker(GRExprEngine &Eng){
- Eng.registerCheck(new UndefinedAssignmentChecker());
-}
-
-void *UndefinedAssignmentChecker::getTag() {
- static int x = 0;
- return &x;
-}
-
-void UndefinedAssignmentChecker::PreVisitBind(CheckerContext &C,
- const Stmt *StoreE,
- SVal location,
- SVal val) {
- if (!val.isUndef())
- return;
-
- ExplodedNode *N = C.generateSink();
-
- if (!N)
- return;
-
- const char *str = "Assigned value is garbage or undefined";
-
- if (!BT)
- BT = new BuiltinBug(str);
-
- // Generate a report for this bug.
- const Expr *ex = 0;
-
- while (StoreE) {
- if (const BinaryOperator *B = dyn_cast<BinaryOperator>(StoreE)) {
- if (B->isCompoundAssignmentOp()) {
- const GRState *state = C.getState();
- if (state->getSVal(B->getLHS()).isUndef()) {
- str = "The left expression of the compound assignment is an "
- "uninitialized value. The computed value will also be garbage";
- ex = B->getLHS();
- break;
- }
- }
-
- ex = B->getRHS();
- break;
- }
-
- if (const DeclStmt *DS = dyn_cast<DeclStmt>(StoreE)) {
- const VarDecl* VD = dyn_cast<VarDecl>(DS->getSingleDecl());
- ex = VD->getInit();
- }
-
- break;
- }
-
- EnhancedBugReport *R = new EnhancedBugReport(*BT, str, N);
- if (ex) {
- R->addRange(ex->getSourceRange());
- R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, ex);
- }
- C.EmitReport(R);
-}
-
Removed: cfe/trunk/lib/Checker/UnixAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UnixAPIChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UnixAPIChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UnixAPIChecker.cpp (removed)
@@ -1,276 +0,0 @@
-//= UnixAPIChecker.h - Checks preconditions for various Unix APIs --*- C++ -*-//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines UnixAPIChecker, which is an assortment of checks on calls
-// to various, widely used UNIX/Posix functions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/StringSwitch.h"
-#include <fcntl.h>
-
-using namespace clang;
-using llvm::Optional;
-
-namespace {
-class UnixAPIChecker : public CheckerVisitor<UnixAPIChecker> {
- enum SubChecks {
- OpenFn = 0,
- PthreadOnceFn = 1,
- MallocZero = 2,
- NumChecks
- };
-
- BugType *BTypes[NumChecks];
-
-public:
- Optional<uint64_t> Val_O_CREAT;
-
-public:
- UnixAPIChecker() { memset(BTypes, 0, sizeof(*BTypes) * NumChecks); }
- static void *getTag() { static unsigned tag = 0; return &tag; }
-
- void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE);
-};
-} //end anonymous namespace
-
-void clang::RegisterUnixAPIChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UnixAPIChecker());
-}
-
-//===----------------------------------------------------------------------===//
-// Utility functions.
-//===----------------------------------------------------------------------===//
-
-static inline void LazyInitialize(BugType *&BT, const char *name) {
- if (BT)
- return;
- BT = new BugType(name, "Unix API");
-}
-
-//===----------------------------------------------------------------------===//
-// "open" (man 2 open)
-//===----------------------------------------------------------------------===//
-
-static void CheckOpen(CheckerContext &C, UnixAPIChecker &UC,
- const CallExpr *CE, BugType *&BT) {
- // The definition of O_CREAT is platform specific. We need a better way
- // of querying this information from the checking environment.
- if (!UC.Val_O_CREAT.hasValue()) {
- if (C.getASTContext().Target.getTriple().getVendor() == llvm::Triple::Apple)
- UC.Val_O_CREAT = 0x0200;
- else {
- // FIXME: We need a more general way of getting the O_CREAT value.
- // We could possibly grovel through the preprocessor state, but
- // that would require passing the Preprocessor object to the GRExprEngine.
- return;
- }
- }
-
- LazyInitialize(BT, "Improper use of 'open'");
-
- // Look at the 'oflags' argument for the O_CREAT flag.
- const GRState *state = C.getState();
-
- if (CE->getNumArgs() < 2) {
- // The frontend should issue a warning for this case, so this is a sanity
- // check.
- return;
- }
-
- // Now check if oflags has O_CREAT set.
- const Expr *oflagsEx = CE->getArg(1);
- const SVal V = state->getSVal(oflagsEx);
- if (!isa<NonLoc>(V)) {
- // The case where 'V' can be a location can only be due to a bad header,
- // so in this case bail out.
- return;
- }
- NonLoc oflags = cast<NonLoc>(V);
- NonLoc ocreateFlag =
- cast<NonLoc>(C.getSValBuilder().makeIntVal(UC.Val_O_CREAT.getValue(),
- oflagsEx->getType()));
- SVal maskedFlagsUC = C.getSValBuilder().evalBinOpNN(state, BO_And,
- oflags, ocreateFlag,
- oflagsEx->getType());
- if (maskedFlagsUC.isUnknownOrUndef())
- return;
- DefinedSVal maskedFlags = cast<DefinedSVal>(maskedFlagsUC);
-
- // Check if maskedFlags is non-zero.
- const GRState *trueState, *falseState;
- llvm::tie(trueState, falseState) = state->assume(maskedFlags);
-
- // Only emit an error if the value of 'maskedFlags' is properly
- // constrained;
- if (!(trueState && !falseState))
- return;
-
- if (CE->getNumArgs() < 3) {
- ExplodedNode *N = C.generateSink(trueState);
- if (!N)
- return;
-
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT,
- "Call to 'open' requires a third argument when "
- "the 'O_CREAT' flag is set", N);
- report->addRange(oflagsEx->getSourceRange());
- C.EmitReport(report);
- }
-}
-
-//===----------------------------------------------------------------------===//
-// pthread_once
-//===----------------------------------------------------------------------===//
-
-static void CheckPthreadOnce(CheckerContext &C, UnixAPIChecker &,
- const CallExpr *CE, BugType *&BT) {
-
- // This is similar to 'CheckDispatchOnce' in the MacOSXAPIChecker.
- // They can possibly be refactored.
-
- LazyInitialize(BT, "Improper use of 'pthread_once'");
-
- if (CE->getNumArgs() < 1)
- return;
-
- // Check if the first argument is stack allocated. If so, issue a warning
- // because that's likely to be bad news.
- const GRState *state = C.getState();
- const MemRegion *R = state->getSVal(CE->getArg(0)).getAsRegion();
- if (!R || !isa<StackSpaceRegion>(R->getMemorySpace()))
- return;
-
- ExplodedNode *N = C.generateSink(state);
- if (!N)
- return;
-
- llvm::SmallString<256> S;
- llvm::raw_svector_ostream os(S);
- os << "Call to 'pthread_once' uses";
- if (const VarRegion *VR = dyn_cast<VarRegion>(R))
- os << " the local variable '" << VR->getDecl()->getName() << '\'';
- else
- os << " stack allocated memory";
- os << " for the \"control\" value. Using such transient memory for "
- "the control value is potentially dangerous.";
- if (isa<VarRegion>(R) && isa<StackLocalsSpaceRegion>(R->getMemorySpace()))
- os << " Perhaps you intended to declare the variable as 'static'?";
-
- EnhancedBugReport *report = new EnhancedBugReport(*BT, os.str(), N);
- report->addRange(CE->getArg(0)->getSourceRange());
- C.EmitReport(report);
-}
-
-//===----------------------------------------------------------------------===//
-// "malloc" with allocation size 0
-//===----------------------------------------------------------------------===//
-
-// FIXME: Eventually this should be rolled into the MallocChecker, but this
-// check is more basic and is valuable for widespread use.
-static void CheckMallocZero(CheckerContext &C, UnixAPIChecker &UC,
- const CallExpr *CE, BugType *&BT) {
-
- // Sanity check that malloc takes one argument.
- if (CE->getNumArgs() != 1)
- return;
-
- // Check if the allocation size is 0.
- const GRState *state = C.getState();
- SVal argVal = state->getSVal(CE->getArg(0));
-
- if (argVal.isUnknownOrUndef())
- return;
-
- const GRState *trueState, *falseState;
- llvm::tie(trueState, falseState) = state->assume(cast<DefinedSVal>(argVal));
-
- // Is the value perfectly constrained to zero?
- if (falseState && !trueState) {
- ExplodedNode *N = C.generateSink(falseState);
- if (!N)
- return;
-
- // FIXME: Add reference to CERT advisory, and/or C99 standard in bug
- // output.
-
- LazyInitialize(BT, "Undefined allocation of 0 bytes");
-
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT, "Call to 'malloc' has an allocation size"
- " of 0 bytes", N);
- report->addRange(CE->getArg(0)->getSourceRange());
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue,
- CE->getArg(0));
- C.EmitReport(report);
- return;
- }
- // Assume the the value is non-zero going forward.
- assert(trueState);
- if (trueState != state) {
- C.addTransition(trueState);
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Central dispatch function.
-//===----------------------------------------------------------------------===//
-
-typedef void (*SubChecker)(CheckerContext &C, UnixAPIChecker &UC,
- const CallExpr *CE, BugType *&BT);
-namespace {
- class SubCheck {
- SubChecker SC;
- UnixAPIChecker *UC;
- BugType **BT;
- public:
- SubCheck(SubChecker sc, UnixAPIChecker *uc, BugType *& bt) : SC(sc), UC(uc),
- BT(&bt) {}
- SubCheck() : SC(NULL), UC(NULL), BT(NULL) {}
-
- void run(CheckerContext &C, const CallExpr *CE) const {
- if (SC)
- SC(C, *UC, CE, *BT);
- }
- };
-} // end anonymous namespace
-
-void UnixAPIChecker::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE) {
- // Get the callee. All the functions we care about are C functions
- // with simple identifiers.
- const GRState *state = C.getState();
- const Expr *Callee = CE->getCallee();
- const FunctionTextRegion *Fn =
- dyn_cast_or_null<FunctionTextRegion>(state->getSVal(Callee).getAsRegion());
-
- if (!Fn)
- return;
-
- const IdentifierInfo *FI = Fn->getDecl()->getIdentifier();
- if (!FI)
- return;
-
- const SubCheck &SC =
- llvm::StringSwitch<SubCheck>(FI->getName())
- .Case("open",
- SubCheck(CheckOpen, this, BTypes[OpenFn]))
- .Case("pthread_once",
- SubCheck(CheckPthreadOnce, this, BTypes[PthreadOnceFn]))
- .Case("malloc",
- SubCheck(CheckMallocZero, this, BTypes[MallocZero]))
- .Default(SubCheck());
-
- SC.run(C, CE);
-}
Removed: cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp (original)
+++ cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp (removed)
@@ -1,222 +0,0 @@
-//==- UnreachableCodeChecker.cpp - Generalized dead code checker -*- C++ -*-==//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// This file implements a generalized unreachable code checker using a
-// path-sensitive analysis. We mark any path visited, and then walk the CFG as a
-// post-analysis to determine what was never visited.
-//
-// A similar flow-sensitive only check exists in Analysis/ReachableCode.cpp
-//===----------------------------------------------------------------------===//
-
-#include "clang/AST/ParentMap.h"
-#include "clang/Basic/Builtins.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/ExplodedGraph.h"
-#include "clang/GR/PathSensitive/SVals.h"
-#include "clang/GR/PathSensitive/CheckerHelpers.h"
-#include "clang/GR/BugReporter/BugReporter.h"
-#include "GRExprEngineExperimentalChecks.h"
-#include "llvm/ADT/SmallPtrSet.h"
-
-// The number of CFGBlock pointers we want to reserve memory for. This is used
-// once for each function we analyze.
-#define DEFAULT_CFGBLOCKS 256
-
-using namespace clang;
-
-namespace {
-class UnreachableCodeChecker : public Checker {
-public:
- static void *getTag();
- void VisitEndAnalysis(ExplodedGraph &G,
- BugReporter &B,
- GRExprEngine &Eng);
-private:
- static inline const Stmt *getUnreachableStmt(const CFGBlock *CB);
- void FindUnreachableEntryPoints(const CFGBlock *CB);
- static bool isInvalidPath(const CFGBlock *CB, const ParentMap &PM);
- static inline bool isEmptyCFGBlock(const CFGBlock *CB);
-
- llvm::SmallSet<unsigned, DEFAULT_CFGBLOCKS> reachable;
- llvm::SmallSet<unsigned, DEFAULT_CFGBLOCKS> visited;
-};
-}
-
-void *UnreachableCodeChecker::getTag() {
- static int x = 0;
- return &x;
-}
-
-void clang::RegisterUnreachableCodeChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new UnreachableCodeChecker());
-}
-
-void UnreachableCodeChecker::VisitEndAnalysis(ExplodedGraph &G,
- BugReporter &B,
- GRExprEngine &Eng) {
- // Bail out if we didn't cover all paths
- if (Eng.hasWorkRemaining())
- return;
-
- CFG *C = 0;
- ParentMap *PM = 0;
- // Iterate over ExplodedGraph
- for (ExplodedGraph::node_iterator I = G.nodes_begin(), E = G.nodes_end();
- I != E; ++I) {
- const ProgramPoint &P = I->getLocation();
- const LocationContext *LC = P.getLocationContext();
-
- // Save the CFG if we don't have it already
- if (!C)
- C = LC->getAnalysisContext()->getUnoptimizedCFG();
- if (!PM)
- PM = &LC->getParentMap();
-
- if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) {
- const CFGBlock *CB = BE->getBlock();
- reachable.insert(CB->getBlockID());
- }
- }
-
- // Bail out if we didn't get the CFG or the ParentMap.
- if (!C || !PM)
- return;
-
- ASTContext &Ctx = B.getContext();
-
- // Find CFGBlocks that were not covered by any node
- for (CFG::const_iterator I = C->begin(), E = C->end(); I != E; ++I) {
- const CFGBlock *CB = *I;
- // Check if the block is unreachable
- if (reachable.count(CB->getBlockID()))
- continue;
-
- // Check if the block is empty (an artificial block)
- if (isEmptyCFGBlock(CB))
- continue;
-
- // Find the entry points for this block
- if (!visited.count(CB->getBlockID()))
- FindUnreachableEntryPoints(CB);
-
- // This block may have been pruned; check if we still want to report it
- if (reachable.count(CB->getBlockID()))
- continue;
-
- // Check for false positives
- if (CB->size() > 0 && isInvalidPath(CB, *PM))
- continue;
-
- // Special case for __builtin_unreachable.
- // FIXME: This should be extended to include other unreachable markers,
- // such as llvm_unreachable.
- if (!CB->empty()) {
- CFGElement First = CB->front();
- if (CFGStmt S = First.getAs<CFGStmt>()) {
- if (const CallExpr *CE = dyn_cast<CallExpr>(S.getStmt())) {
- if (CE->isBuiltinCall(Ctx) == Builtin::BI__builtin_unreachable)
- continue;
- }
- }
- }
-
- // We found a block that wasn't covered - find the statement to report
- SourceRange SR;
- SourceLocation SL;
- if (const Stmt *S = getUnreachableStmt(CB)) {
- SR = S->getSourceRange();
- SL = S->getLocStart();
- if (SR.isInvalid() || SL.isInvalid())
- continue;
- }
- else
- continue;
-
- // Check if the SourceLocation is in a system header
- const SourceManager &SM = B.getSourceManager();
- if (SM.isInSystemHeader(SL) || SM.isInExternCSystemHeader(SL))
- continue;
-
- B.EmitBasicReport("Unreachable code", "Dead code", "This statement is never"
- " executed", SL, SR);
- }
-}
-
-// Recursively finds the entry point(s) for this dead CFGBlock.
-void UnreachableCodeChecker::FindUnreachableEntryPoints(const CFGBlock *CB) {
- visited.insert(CB->getBlockID());
-
- for (CFGBlock::const_pred_iterator I = CB->pred_begin(), E = CB->pred_end();
- I != E; ++I) {
- if (!reachable.count((*I)->getBlockID())) {
- // If we find an unreachable predecessor, mark this block as reachable so
- // we don't report this block
- reachable.insert(CB->getBlockID());
- if (!visited.count((*I)->getBlockID()))
- // If we haven't previously visited the unreachable predecessor, recurse
- FindUnreachableEntryPoints(*I);
- }
- }
-}
-
-// Find the Stmt* in a CFGBlock for reporting a warning
-const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
- for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
- if (CFGStmt S = I->getAs<CFGStmt>())
- return S;
- }
- if (const Stmt *S = CB->getTerminator())
- return S;
- else
- return 0;
-}
-
-// Determines if the path to this CFGBlock contained an element that infers this
-// block is a false positive. We assume that FindUnreachableEntryPoints has
-// already marked only the entry points to any dead code, so we need only to
-// find the condition that led to this block (the predecessor of this block.)
-// There will never be more than one predecessor.
-bool UnreachableCodeChecker::isInvalidPath(const CFGBlock *CB,
- const ParentMap &PM) {
- // We only expect a predecessor size of 0 or 1. If it is >1, then an external
- // condition has broken our assumption (for example, a sink being placed by
- // another check). In these cases, we choose not to report.
- if (CB->pred_size() > 1)
- return true;
-
- // If there are no predecessors, then this block is trivially unreachable
- if (CB->pred_size() == 0)
- return false;
-
- const CFGBlock *pred = *CB->pred_begin();
-
- // Get the predecessor block's terminator conditon
- const Stmt *cond = pred->getTerminatorCondition();
-
- //assert(cond && "CFGBlock's predecessor has a terminator condition");
- // The previous assertion is invalid in some cases (eg do/while). Leaving
- // reporting of these situations on at the moment to help triage these cases.
- if (!cond)
- return false;
-
- // Run each of the checks on the conditions
- if (containsMacro(cond) || containsEnum(cond)
- || containsStaticLocal(cond) || containsBuiltinOffsetOf(cond)
- || containsStmt<SizeOfAlignOfExpr>(cond))
- return true;
-
- return false;
-}
-
-// Returns true if the given CFGBlock is empty
-bool UnreachableCodeChecker::isEmptyCFGBlock(const CFGBlock *CB) {
- return CB->getLabel() == 0 // No labels
- && CB->size() == 0 // No statements
- && CB->getTerminator() == 0; // No terminator
-}
Removed: cfe/trunk/lib/Checker/VLASizeChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/VLASizeChecker.cpp?rev=122420&view=auto
==============================================================================
--- cfe/trunk/lib/Checker/VLASizeChecker.cpp (original)
+++ cfe/trunk/lib/Checker/VLASizeChecker.cpp (removed)
@@ -1,137 +0,0 @@
-//=== VLASizeChecker.cpp - Undefined dereference checker --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This defines VLASizeChecker, a builtin check in GRExprEngine that
-// performs checks for declaration of VLA of undefined or zero size.
-// In addition, VLASizeChecker is responsible for defining the extent
-// of the MemRegion that represents a VLA.
-//
-//===----------------------------------------------------------------------===//
-
-#include "GRExprEngineInternalChecks.h"
-#include "clang/AST/CharUnits.h"
-#include "clang/GR/BugReporter/BugType.h"
-#include "clang/GR/PathSensitive/CheckerVisitor.h"
-#include "clang/GR/PathSensitive/GRExprEngine.h"
-
-using namespace clang;
-
-namespace {
-class VLASizeChecker : public CheckerVisitor<VLASizeChecker> {
- BugType *BT_zero;
- BugType *BT_undef;
-
-public:
- VLASizeChecker() : BT_zero(0), BT_undef(0) {}
- static void *getTag() { static int tag = 0; return &tag; }
- void PreVisitDeclStmt(CheckerContext &C, const DeclStmt *DS);
-};
-} // end anonymous namespace
-
-void clang::RegisterVLASizeChecker(GRExprEngine &Eng) {
- Eng.registerCheck(new VLASizeChecker());
-}
-
-void VLASizeChecker::PreVisitDeclStmt(CheckerContext &C, const DeclStmt *DS) {
- if (!DS->isSingleDecl())
- return;
-
- const VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl());
- if (!VD)
- return;
-
- ASTContext &Ctx = C.getASTContext();
- const VariableArrayType *VLA = Ctx.getAsVariableArrayType(VD->getType());
- if (!VLA)
- return;
-
- // FIXME: Handle multi-dimensional VLAs.
- const Expr* SE = VLA->getSizeExpr();
- const GRState *state = C.getState();
- SVal sizeV = state->getSVal(SE);
-
- if (sizeV.isUndef()) {
- // Generate an error node.
- ExplodedNode *N = C.generateSink();
- if (!N)
- return;
-
- if (!BT_undef)
- BT_undef = new BuiltinBug("Declared variable-length array (VLA) uses a "
- "garbage value as its size");
-
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT_undef, BT_undef->getName(), N);
- report->addRange(SE->getSourceRange());
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, SE);
- C.EmitReport(report);
- return;
- }
-
- // See if the size value is known. It can't be undefined because we would have
- // warned about that already.
- if (sizeV.isUnknown())
- return;
-
- // Check if the size is zero.
- DefinedSVal sizeD = cast<DefinedSVal>(sizeV);
-
- const GRState *stateNotZero, *stateZero;
- llvm::tie(stateNotZero, stateZero) = state->assume(sizeD);
-
- if (stateZero && !stateNotZero) {
- ExplodedNode* N = C.generateSink(stateZero);
- if (!BT_zero)
- BT_zero = new BuiltinBug("Declared variable-length array (VLA) has zero "
- "size");
-
- EnhancedBugReport *report =
- new EnhancedBugReport(*BT_zero, BT_zero->getName(), N);
- report->addRange(SE->getSourceRange());
- report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, SE);
- C.EmitReport(report);
- return;
- }
-
- // From this point on, assume that the size is not zero.
- state = stateNotZero;
-
- // VLASizeChecker is responsible for defining the extent of the array being
- // declared. We do this by multiplying the array length by the element size,
- // then matching that with the array region's extent symbol.
-
- // Convert the array length to size_t.
- SValBuilder &svalBuilder = C.getSValBuilder();
- QualType SizeTy = Ctx.getSizeType();
- NonLoc ArrayLength = cast<NonLoc>(svalBuilder.evalCast(sizeD, SizeTy,
- SE->getType()));
-
- // Get the element size.
- CharUnits EleSize = Ctx.getTypeSizeInChars(VLA->getElementType());
- SVal EleSizeVal = svalBuilder.makeIntVal(EleSize.getQuantity(), SizeTy);
-
- // Multiply the array length by the element size.
- SVal ArraySizeVal = svalBuilder.evalBinOpNN(state, BO_Mul, ArrayLength,
- cast<NonLoc>(EleSizeVal), SizeTy);
-
- // Finally, assume that the array's extent matches the given size.
- const LocationContext *LC = C.getPredecessor()->getLocationContext();
- DefinedOrUnknownSVal Extent =
- state->getRegion(VD, LC)->getExtent(svalBuilder);
- DefinedOrUnknownSVal ArraySize = cast<DefinedOrUnknownSVal>(ArraySizeVal);
- DefinedOrUnknownSVal sizeIsKnown =
- svalBuilder.evalEQ(state, Extent, ArraySize);
- state = state->assume(sizeIsKnown, true);
-
- // Assume should not fail at this point.
- assert(state);
-
- // Remember our assumptions!
- C.addTransition(state);
-}
Modified: cfe/trunk/lib/FrontendTool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/CMakeLists.txt?rev=122421&r1=122420&r2=122421&view=diff
==============================================================================
--- cfe/trunk/lib/FrontendTool/CMakeLists.txt (original)
+++ cfe/trunk/lib/FrontendTool/CMakeLists.txt Wed Dec 22 12:52:29 2010
@@ -1,7 +1,7 @@
set(LLVM_NO_RTTI 1)
set(LLVM_USED_LIBS clangDriver clangFrontend clangRewrite clangCodeGen
- clangChecker)
+ clangGRCore)
add_clang_library(clangFrontendTool
ExecuteCompilerInvocation.cpp
Copied: cfe/trunk/lib/GR/AdjustedReturnValueChecker.cpp (from r122420, cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AdjustedReturnValueChecker.cpp?p2=cfe/trunk/lib/GR/AdjustedReturnValueChecker.cpp&p1=cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/AggExprVisitor.cpp (from r122420, cfe/trunk/lib/Checker/AggExprVisitor.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AggExprVisitor.cpp?p2=cfe/trunk/lib/GR/AggExprVisitor.cpp&p1=cfe/trunk/lib/Checker/AggExprVisitor.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/AnalysisConsumer.cpp (from r122420, cfe/trunk/lib/Checker/AnalysisConsumer.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AnalysisConsumer.cpp?p2=cfe/trunk/lib/GR/AnalysisConsumer.cpp&p1=cfe/trunk/lib/Checker/AnalysisConsumer.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/AnalysisManager.cpp (from r122420, cfe/trunk/lib/Checker/AnalysisManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AnalysisManager.cpp?p2=cfe/trunk/lib/GR/AnalysisManager.cpp&p1=cfe/trunk/lib/Checker/AnalysisManager.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/AnalyzerStatsChecker.cpp (from r122420, cfe/trunk/lib/Checker/AnalyzerStatsChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AnalyzerStatsChecker.cpp?p2=cfe/trunk/lib/GR/AnalyzerStatsChecker.cpp&p1=cfe/trunk/lib/Checker/AnalyzerStatsChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ArrayBoundChecker.cpp (from r122420, cfe/trunk/lib/Checker/ArrayBoundChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ArrayBoundChecker.cpp?p2=cfe/trunk/lib/GR/ArrayBoundChecker.cpp&p1=cfe/trunk/lib/Checker/ArrayBoundChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/AttrNonNullChecker.cpp (from r122420, cfe/trunk/lib/Checker/AttrNonNullChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/AttrNonNullChecker.cpp?p2=cfe/trunk/lib/GR/AttrNonNullChecker.cpp&p1=cfe/trunk/lib/Checker/AttrNonNullChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BasicConstraintManager.cpp (from r122420, cfe/trunk/lib/Checker/BasicConstraintManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BasicConstraintManager.cpp?p2=cfe/trunk/lib/GR/BasicConstraintManager.cpp&p1=cfe/trunk/lib/Checker/BasicConstraintManager.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BasicObjCFoundationChecks.cpp (from r122420, cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BasicObjCFoundationChecks.cpp?p2=cfe/trunk/lib/GR/BasicObjCFoundationChecks.cpp&p1=cfe/trunk/lib/Checker/BasicObjCFoundationChecks.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BasicObjCFoundationChecks.h (from r122420, cfe/trunk/lib/Checker/BasicObjCFoundationChecks.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BasicObjCFoundationChecks.h?p2=cfe/trunk/lib/GR/BasicObjCFoundationChecks.h&p1=cfe/trunk/lib/Checker/BasicObjCFoundationChecks.h&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BasicStore.cpp (from r122420, cfe/trunk/lib/Checker/BasicStore.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BasicStore.cpp?p2=cfe/trunk/lib/GR/BasicStore.cpp&p1=cfe/trunk/lib/Checker/BasicStore.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BasicValueFactory.cpp (from r122420, cfe/trunk/lib/Checker/BasicValueFactory.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BasicValueFactory.cpp?p2=cfe/trunk/lib/GR/BasicValueFactory.cpp&p1=cfe/trunk/lib/Checker/BasicValueFactory.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BugReporter.cpp (from r122420, cfe/trunk/lib/Checker/BugReporter.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BugReporter.cpp?p2=cfe/trunk/lib/GR/BugReporter.cpp&p1=cfe/trunk/lib/Checker/BugReporter.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BugReporterVisitors.cpp (from r122420, cfe/trunk/lib/Checker/BugReporterVisitors.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BugReporterVisitors.cpp?p2=cfe/trunk/lib/GR/BugReporterVisitors.cpp&p1=cfe/trunk/lib/Checker/BugReporterVisitors.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/BuiltinFunctionChecker.cpp (from r122420, cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/BuiltinFunctionChecker.cpp?p2=cfe/trunk/lib/GR/BuiltinFunctionChecker.cpp&p1=cfe/trunk/lib/Checker/BuiltinFunctionChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CFRefCount.cpp (from r122420, cfe/trunk/lib/Checker/CFRefCount.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CFRefCount.cpp?p2=cfe/trunk/lib/GR/CFRefCount.cpp&p1=cfe/trunk/lib/Checker/CFRefCount.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CMakeLists.txt (from r122420, cfe/trunk/lib/Checker/CMakeLists.txt)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CMakeLists.txt?p2=cfe/trunk/lib/GR/CMakeLists.txt&p1=cfe/trunk/lib/Checker/CMakeLists.txt&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CMakeLists.txt (original)
+++ cfe/trunk/lib/GR/CMakeLists.txt Wed Dec 22 12:52:29 2010
@@ -2,7 +2,7 @@
set(LLVM_USED_LIBS clangBasic clangLex clangAST clangFrontend clangRewrite)
-add_clang_library(clangChecker
+add_clang_library(clangGRCore
AdjustedReturnValueChecker.cpp
AggExprVisitor.cpp
AnalysisConsumer.cpp
@@ -84,5 +84,5 @@
VLASizeChecker.cpp
)
-add_dependencies(clangChecker ClangAttrClasses ClangAttrList ClangDeclNodes
+add_dependencies(clangGRCore ClangAttrClasses ClangAttrList ClangDeclNodes
ClangStmtNodes)
Copied: cfe/trunk/lib/GR/CStringChecker.cpp (from r122420, cfe/trunk/lib/Checker/CStringChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CStringChecker.cpp?p2=cfe/trunk/lib/GR/CStringChecker.cpp&p1=cfe/trunk/lib/Checker/CStringChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CallAndMessageChecker.cpp (from r122420, cfe/trunk/lib/Checker/CallAndMessageChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CallAndMessageChecker.cpp?p2=cfe/trunk/lib/GR/CallAndMessageChecker.cpp&p1=cfe/trunk/lib/Checker/CallAndMessageChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CastSizeChecker.cpp (from r122420, cfe/trunk/lib/Checker/CastSizeChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CastSizeChecker.cpp?p2=cfe/trunk/lib/GR/CastSizeChecker.cpp&p1=cfe/trunk/lib/Checker/CastSizeChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CastToStructChecker.cpp (from r122420, cfe/trunk/lib/Checker/CastToStructChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CastToStructChecker.cpp?p2=cfe/trunk/lib/GR/CastToStructChecker.cpp&p1=cfe/trunk/lib/Checker/CastToStructChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckDeadStores.cpp (from r122420, cfe/trunk/lib/Checker/CheckDeadStores.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckDeadStores.cpp?p2=cfe/trunk/lib/GR/CheckDeadStores.cpp&p1=cfe/trunk/lib/Checker/CheckDeadStores.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckObjCDealloc.cpp (from r122420, cfe/trunk/lib/Checker/CheckObjCDealloc.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckObjCDealloc.cpp?p2=cfe/trunk/lib/GR/CheckObjCDealloc.cpp&p1=cfe/trunk/lib/Checker/CheckObjCDealloc.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckObjCInstMethSignature.cpp (from r122420, cfe/trunk/lib/Checker/CheckObjCInstMethSignature.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckObjCInstMethSignature.cpp?p2=cfe/trunk/lib/GR/CheckObjCInstMethSignature.cpp&p1=cfe/trunk/lib/Checker/CheckObjCInstMethSignature.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckSecuritySyntaxOnly.cpp (from r122420, cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckSecuritySyntaxOnly.cpp?p2=cfe/trunk/lib/GR/CheckSecuritySyntaxOnly.cpp&p1=cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckSizeofPointer.cpp (from r122420, cfe/trunk/lib/Checker/CheckSizeofPointer.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckSizeofPointer.cpp?p2=cfe/trunk/lib/GR/CheckSizeofPointer.cpp&p1=cfe/trunk/lib/Checker/CheckSizeofPointer.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/Checker.cpp (from r122420, cfe/trunk/lib/Checker/Checker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/Checker.cpp?p2=cfe/trunk/lib/GR/Checker.cpp&p1=cfe/trunk/lib/Checker/Checker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/CheckerHelpers.cpp (from r122420, cfe/trunk/lib/Checker/CheckerHelpers.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/CheckerHelpers.cpp?p2=cfe/trunk/lib/GR/CheckerHelpers.cpp&p1=cfe/trunk/lib/Checker/CheckerHelpers.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ChrootChecker.cpp (from r122420, cfe/trunk/lib/Checker/ChrootChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ChrootChecker.cpp?p2=cfe/trunk/lib/GR/ChrootChecker.cpp&p1=cfe/trunk/lib/Checker/ChrootChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/DereferenceChecker.cpp (from r122420, cfe/trunk/lib/Checker/DereferenceChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/DereferenceChecker.cpp?p2=cfe/trunk/lib/GR/DereferenceChecker.cpp&p1=cfe/trunk/lib/Checker/DereferenceChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/DivZeroChecker.cpp (from r122420, cfe/trunk/lib/Checker/DivZeroChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/DivZeroChecker.cpp?p2=cfe/trunk/lib/GR/DivZeroChecker.cpp&p1=cfe/trunk/lib/Checker/DivZeroChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/Environment.cpp (from r122420, cfe/trunk/lib/Checker/Environment.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/Environment.cpp?p2=cfe/trunk/lib/GR/Environment.cpp&p1=cfe/trunk/lib/Checker/Environment.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ExplodedGraph.cpp (from r122420, cfe/trunk/lib/Checker/ExplodedGraph.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ExplodedGraph.cpp?p2=cfe/trunk/lib/GR/ExplodedGraph.cpp&p1=cfe/trunk/lib/Checker/ExplodedGraph.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/FixedAddressChecker.cpp (from r122420, cfe/trunk/lib/Checker/FixedAddressChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/FixedAddressChecker.cpp?p2=cfe/trunk/lib/GR/FixedAddressChecker.cpp&p1=cfe/trunk/lib/Checker/FixedAddressChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/FlatStore.cpp (from r122420, cfe/trunk/lib/Checker/FlatStore.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/FlatStore.cpp?p2=cfe/trunk/lib/GR/FlatStore.cpp&p1=cfe/trunk/lib/Checker/FlatStore.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/FrontendActions.cpp (from r122420, cfe/trunk/lib/Checker/FrontendActions.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/FrontendActions.cpp?p2=cfe/trunk/lib/GR/FrontendActions.cpp&p1=cfe/trunk/lib/Checker/FrontendActions.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRBlockCounter.cpp (from r122420, cfe/trunk/lib/Checker/GRBlockCounter.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRBlockCounter.cpp?p2=cfe/trunk/lib/GR/GRBlockCounter.cpp&p1=cfe/trunk/lib/Checker/GRBlockCounter.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRCXXExprEngine.cpp (from r122420, cfe/trunk/lib/Checker/GRCXXExprEngine.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRCXXExprEngine.cpp?p2=cfe/trunk/lib/GR/GRCXXExprEngine.cpp&p1=cfe/trunk/lib/Checker/GRCXXExprEngine.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRCoreEngine.cpp (from r122420, cfe/trunk/lib/Checker/GRCoreEngine.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRCoreEngine.cpp?p2=cfe/trunk/lib/GR/GRCoreEngine.cpp&p1=cfe/trunk/lib/Checker/GRCoreEngine.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRExprEngine.cpp (from r122420, cfe/trunk/lib/Checker/GRExprEngine.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRExprEngine.cpp?p2=cfe/trunk/lib/GR/GRExprEngine.cpp&p1=cfe/trunk/lib/Checker/GRExprEngine.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.cpp (from r122420, cfe/trunk/lib/Checker/GRExprEngineExperimentalChecks.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.cpp?p2=cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.cpp&p1=cfe/trunk/lib/Checker/GRExprEngineExperimentalChecks.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.h (from r122420, cfe/trunk/lib/Checker/GRExprEngineExperimentalChecks.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.h?p2=cfe/trunk/lib/GR/GRExprEngineExperimentalChecks.h&p1=cfe/trunk/lib/Checker/GRExprEngineExperimentalChecks.h&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRExprEngineInternalChecks.h (from r122420, cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRExprEngineInternalChecks.h?p2=cfe/trunk/lib/GR/GRExprEngineInternalChecks.h&p1=cfe/trunk/lib/Checker/GRExprEngineInternalChecks.h&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/GRState.cpp (from r122420, cfe/trunk/lib/Checker/GRState.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/GRState.cpp?p2=cfe/trunk/lib/GR/GRState.cpp&p1=cfe/trunk/lib/Checker/GRState.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/HTMLDiagnostics.cpp (from r122420, cfe/trunk/lib/Checker/HTMLDiagnostics.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/HTMLDiagnostics.cpp?p2=cfe/trunk/lib/GR/HTMLDiagnostics.cpp&p1=cfe/trunk/lib/Checker/HTMLDiagnostics.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/IdempotentOperationChecker.cpp (from r122420, cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/IdempotentOperationChecker.cpp?p2=cfe/trunk/lib/GR/IdempotentOperationChecker.cpp&p1=cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/LLVMConventionsChecker.cpp (from r122420, cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/LLVMConventionsChecker.cpp?p2=cfe/trunk/lib/GR/LLVMConventionsChecker.cpp&p1=cfe/trunk/lib/Checker/LLVMConventionsChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/MacOSXAPIChecker.cpp (from r122420, cfe/trunk/lib/Checker/MacOSXAPIChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/MacOSXAPIChecker.cpp?p2=cfe/trunk/lib/GR/MacOSXAPIChecker.cpp&p1=cfe/trunk/lib/Checker/MacOSXAPIChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/Makefile (from r122420, cfe/trunk/lib/Checker/Makefile)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/Makefile?p2=cfe/trunk/lib/GR/Makefile&p1=cfe/trunk/lib/Checker/Makefile&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/Makefile (original)
+++ cfe/trunk/lib/GR/Makefile Wed Dec 22 12:52:29 2010
@@ -12,7 +12,7 @@
##===----------------------------------------------------------------------===##
CLANG_LEVEL := ../..
-LIBRARYNAME := clangChecker
+LIBRARYNAME := clangGRCore
include $(CLANG_LEVEL)/Makefile
Copied: cfe/trunk/lib/GR/MallocChecker.cpp (from r122420, cfe/trunk/lib/Checker/MallocChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/MallocChecker.cpp?p2=cfe/trunk/lib/GR/MallocChecker.cpp&p1=cfe/trunk/lib/Checker/MallocChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ManagerRegistry.cpp (from r122420, cfe/trunk/lib/Checker/ManagerRegistry.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ManagerRegistry.cpp?p2=cfe/trunk/lib/GR/ManagerRegistry.cpp&p1=cfe/trunk/lib/Checker/ManagerRegistry.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/MemRegion.cpp (from r122420, cfe/trunk/lib/Checker/MemRegion.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/MemRegion.cpp?p2=cfe/trunk/lib/GR/MemRegion.cpp&p1=cfe/trunk/lib/Checker/MemRegion.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/NSAutoreleasePoolChecker.cpp (from r122420, cfe/trunk/lib/Checker/NSAutoreleasePoolChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/NSAutoreleasePoolChecker.cpp?p2=cfe/trunk/lib/GR/NSAutoreleasePoolChecker.cpp&p1=cfe/trunk/lib/Checker/NSAutoreleasePoolChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/NSErrorChecker.cpp (from r122420, cfe/trunk/lib/Checker/NSErrorChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/NSErrorChecker.cpp?p2=cfe/trunk/lib/GR/NSErrorChecker.cpp&p1=cfe/trunk/lib/Checker/NSErrorChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/NoReturnFunctionChecker.cpp (from r122420, cfe/trunk/lib/Checker/NoReturnFunctionChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/NoReturnFunctionChecker.cpp?p2=cfe/trunk/lib/GR/NoReturnFunctionChecker.cpp&p1=cfe/trunk/lib/Checker/NoReturnFunctionChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/OSAtomicChecker.cpp (from r122420, cfe/trunk/lib/Checker/OSAtomicChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/OSAtomicChecker.cpp?p2=cfe/trunk/lib/GR/OSAtomicChecker.cpp&p1=cfe/trunk/lib/Checker/OSAtomicChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ObjCAtSyncChecker.cpp (from r122420, cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ObjCAtSyncChecker.cpp?p2=cfe/trunk/lib/GR/ObjCAtSyncChecker.cpp&p1=cfe/trunk/lib/Checker/ObjCAtSyncChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ObjCUnusedIVarsChecker.cpp (from r122420, cfe/trunk/lib/Checker/ObjCUnusedIVarsChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ObjCUnusedIVarsChecker.cpp?p2=cfe/trunk/lib/GR/ObjCUnusedIVarsChecker.cpp&p1=cfe/trunk/lib/Checker/ObjCUnusedIVarsChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/PathDiagnostic.cpp (from r122420, cfe/trunk/lib/Checker/PathDiagnostic.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/PathDiagnostic.cpp?p2=cfe/trunk/lib/GR/PathDiagnostic.cpp&p1=cfe/trunk/lib/Checker/PathDiagnostic.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/PlistDiagnostics.cpp (from r122420, cfe/trunk/lib/Checker/PlistDiagnostics.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/PlistDiagnostics.cpp?p2=cfe/trunk/lib/GR/PlistDiagnostics.cpp&p1=cfe/trunk/lib/Checker/PlistDiagnostics.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/PointerArithChecker.cpp (from r122420, cfe/trunk/lib/Checker/PointerArithChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/PointerArithChecker.cpp?p2=cfe/trunk/lib/GR/PointerArithChecker.cpp&p1=cfe/trunk/lib/Checker/PointerArithChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/PointerSubChecker.cpp (from r122420, cfe/trunk/lib/Checker/PointerSubChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/PointerSubChecker.cpp?p2=cfe/trunk/lib/GR/PointerSubChecker.cpp&p1=cfe/trunk/lib/Checker/PointerSubChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/PthreadLockChecker.cpp (from r122420, cfe/trunk/lib/Checker/PthreadLockChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/PthreadLockChecker.cpp?p2=cfe/trunk/lib/GR/PthreadLockChecker.cpp&p1=cfe/trunk/lib/Checker/PthreadLockChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/README.txt (from r122420, cfe/trunk/lib/Checker/README.txt)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/README.txt?p2=cfe/trunk/lib/GR/README.txt&p1=cfe/trunk/lib/Checker/README.txt&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/RangeConstraintManager.cpp (from r122420, cfe/trunk/lib/Checker/RangeConstraintManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/RangeConstraintManager.cpp?p2=cfe/trunk/lib/GR/RangeConstraintManager.cpp&p1=cfe/trunk/lib/Checker/RangeConstraintManager.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/RegionStore.cpp (from r122420, cfe/trunk/lib/Checker/RegionStore.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/RegionStore.cpp?p2=cfe/trunk/lib/GR/RegionStore.cpp&p1=cfe/trunk/lib/Checker/RegionStore.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ReturnPointerRangeChecker.cpp (from r122420, cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ReturnPointerRangeChecker.cpp?p2=cfe/trunk/lib/GR/ReturnPointerRangeChecker.cpp&p1=cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/ReturnUndefChecker.cpp (from r122420, cfe/trunk/lib/Checker/ReturnUndefChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/ReturnUndefChecker.cpp?p2=cfe/trunk/lib/GR/ReturnUndefChecker.cpp&p1=cfe/trunk/lib/Checker/ReturnUndefChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SValBuilder.cpp (from r122420, cfe/trunk/lib/Checker/SValBuilder.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SValBuilder.cpp?p2=cfe/trunk/lib/GR/SValBuilder.cpp&p1=cfe/trunk/lib/Checker/SValBuilder.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SVals.cpp (from r122420, cfe/trunk/lib/Checker/SVals.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SVals.cpp?p2=cfe/trunk/lib/GR/SVals.cpp&p1=cfe/trunk/lib/Checker/SVals.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SimpleConstraintManager.cpp (from r122420, cfe/trunk/lib/Checker/SimpleConstraintManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SimpleConstraintManager.cpp?p2=cfe/trunk/lib/GR/SimpleConstraintManager.cpp&p1=cfe/trunk/lib/Checker/SimpleConstraintManager.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SimpleConstraintManager.h (from r122420, cfe/trunk/lib/Checker/SimpleConstraintManager.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SimpleConstraintManager.h?p2=cfe/trunk/lib/GR/SimpleConstraintManager.h&p1=cfe/trunk/lib/Checker/SimpleConstraintManager.h&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SimpleSValBuilder.cpp (from r122420, cfe/trunk/lib/Checker/SimpleSValBuilder.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SimpleSValBuilder.cpp?p2=cfe/trunk/lib/GR/SimpleSValBuilder.cpp&p1=cfe/trunk/lib/Checker/SimpleSValBuilder.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/StackAddrLeakChecker.cpp (from r122420, cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/StackAddrLeakChecker.cpp?p2=cfe/trunk/lib/GR/StackAddrLeakChecker.cpp&p1=cfe/trunk/lib/Checker/StackAddrLeakChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/Store.cpp (from r122420, cfe/trunk/lib/Checker/Store.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/Store.cpp?p2=cfe/trunk/lib/GR/Store.cpp&p1=cfe/trunk/lib/Checker/Store.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/StreamChecker.cpp (from r122420, cfe/trunk/lib/Checker/StreamChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/StreamChecker.cpp?p2=cfe/trunk/lib/GR/StreamChecker.cpp&p1=cfe/trunk/lib/Checker/StreamChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/SymbolManager.cpp (from r122420, cfe/trunk/lib/Checker/SymbolManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/SymbolManager.cpp?p2=cfe/trunk/lib/GR/SymbolManager.cpp&p1=cfe/trunk/lib/Checker/SymbolManager.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/TextPathDiagnostics.cpp (from r122420, cfe/trunk/lib/Checker/TextPathDiagnostics.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/TextPathDiagnostics.cpp?p2=cfe/trunk/lib/GR/TextPathDiagnostics.cpp&p1=cfe/trunk/lib/Checker/TextPathDiagnostics.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UndefBranchChecker.cpp (from r122420, cfe/trunk/lib/Checker/UndefBranchChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UndefBranchChecker.cpp?p2=cfe/trunk/lib/GR/UndefBranchChecker.cpp&p1=cfe/trunk/lib/Checker/UndefBranchChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UndefCapturedBlockVarChecker.cpp (from r122420, cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UndefCapturedBlockVarChecker.cpp?p2=cfe/trunk/lib/GR/UndefCapturedBlockVarChecker.cpp&p1=cfe/trunk/lib/Checker/UndefCapturedBlockVarChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UndefResultChecker.cpp (from r122420, cfe/trunk/lib/Checker/UndefResultChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UndefResultChecker.cpp?p2=cfe/trunk/lib/GR/UndefResultChecker.cpp&p1=cfe/trunk/lib/Checker/UndefResultChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UndefinedArraySubscriptChecker.cpp (from r122420, cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UndefinedArraySubscriptChecker.cpp?p2=cfe/trunk/lib/GR/UndefinedArraySubscriptChecker.cpp&p1=cfe/trunk/lib/Checker/UndefinedArraySubscriptChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UndefinedAssignmentChecker.cpp (from r122420, cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UndefinedAssignmentChecker.cpp?p2=cfe/trunk/lib/GR/UndefinedAssignmentChecker.cpp&p1=cfe/trunk/lib/Checker/UndefinedAssignmentChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UnixAPIChecker.cpp (from r122420, cfe/trunk/lib/Checker/UnixAPIChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UnixAPIChecker.cpp?p2=cfe/trunk/lib/GR/UnixAPIChecker.cpp&p1=cfe/trunk/lib/Checker/UnixAPIChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/UnreachableCodeChecker.cpp (from r122420, cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/UnreachableCodeChecker.cpp?p2=cfe/trunk/lib/GR/UnreachableCodeChecker.cpp&p1=cfe/trunk/lib/Checker/UnreachableCodeChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Copied: cfe/trunk/lib/GR/VLASizeChecker.cpp (from r122420, cfe/trunk/lib/Checker/VLASizeChecker.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/GR/VLASizeChecker.cpp?p2=cfe/trunk/lib/GR/VLASizeChecker.cpp&p1=cfe/trunk/lib/Checker/VLASizeChecker.cpp&r1=122420&r2=122421&rev=122421&view=diff
==============================================================================
(empty)
Modified: cfe/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Makefile?rev=122421&r1=122420&r2=122421&view=diff
==============================================================================
--- cfe/trunk/lib/Makefile (original)
+++ cfe/trunk/lib/Makefile Wed Dec 22 12:52:29 2010
@@ -9,7 +9,7 @@
CLANG_LEVEL := ..
PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis \
- Checker Rewrite Serialization Frontend FrontendTool Index Driver
+ GR Rewrite Serialization Frontend FrontendTool Index Driver
include $(CLANG_LEVEL)/Makefile
Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=122421&r1=122420&r2=122421&view=diff
==============================================================================
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Wed Dec 22 12:52:29 2010
@@ -8,7 +8,7 @@
clangCodeGen
clangParse
clangSema
- clangChecker
+ clangGRCore
clangAnalysis
clangIndex
clangRewrite
Modified: cfe/trunk/tools/driver/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/Makefile?rev=122421&r1=122420&r2=122421&view=diff
==============================================================================
--- cfe/trunk/tools/driver/Makefile (original)
+++ cfe/trunk/tools/driver/Makefile Wed Dec 22 12:52:29 2010
@@ -39,7 +39,7 @@
ipo selectiondag
USEDLIBS = clangFrontendTool.a clangFrontend.a clangDriver.a \
clangSerialization.a clangCodeGen.a clangParse.a clangSema.a \
- clangChecker.a clangAnalysis.a clangIndex.a clangRewrite.a \
+ clangGRCore.a clangAnalysis.a clangIndex.a clangRewrite.a \
clangAST.a clangLex.a clangBasic.a
include $(CLANG_LEVEL)/Makefile
More information about the cfe-commits
mailing list