opnsense-src/include/clang/Analysis/Analyses/UninitializedValues.h

78 lines
2.5 KiB
C
Raw Normal View History

2009-06-02 13:58:47 -04:00
//===- UninitializedValues.h - unintialized values analysis ----*- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file provides the interface for the Unintialized Values analysis,
// a flow-sensitive analysis that detects when variable values are unintialized.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_UNITVALS_H
#define LLVM_CLANG_UNITVALS_H
#include "clang/Analysis/Support/BlkExprDeclBitVector.h"
#include "clang/Analysis/FlowSensitive/DataflowValues.h"
namespace clang {
class BlockVarDecl;
class Expr;
class DeclRefExpr;
class VarDecl;
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
/// UninitializedValues_ValueTypes - Utility class to wrap type declarations
/// for dataflow values and dataflow analysis state for the
/// Unitialized Values analysis.
class UninitializedValues_ValueTypes {
public:
struct ObserverTy;
2009-10-14 14:03:49 -04:00
struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy {
2009-06-02 13:58:47 -04:00
AnalysisDataTy() : Observer(NULL), FullUninitTaint(true) {}
2010-01-01 05:34:51 -05:00
virtual ~AnalysisDataTy() {}
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
ObserverTy* Observer;
bool FullUninitTaint;
};
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
typedef StmtDeclBitVector_Types::ValTy ValTy;
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
//===--------------------------------------------------------------------===//
// ObserverTy - Observer for querying DeclRefExprs that use an uninitalized
// value.
//===--------------------------------------------------------------------===//
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
struct ObserverTy {
virtual ~ObserverTy();
2009-10-14 14:03:49 -04:00
virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD,
2009-06-02 13:58:47 -04:00
DeclRefExpr* DR, VarDecl* VD) = 0;
2009-10-14 14:03:49 -04:00
};
2009-06-02 13:58:47 -04:00
};
/// UninitializedValues - Objects of this class encapsulate dataflow analysis
/// information regarding what variable declarations in a function are
/// potentially unintialized.
2009-10-14 14:03:49 -04:00
class UninitializedValues :
public DataflowValues<UninitializedValues_ValueTypes> {
2009-06-02 13:58:47 -04:00
public:
typedef UninitializedValues_ValueTypes::ObserverTy ObserverTy;
UninitializedValues(CFG &cfg) { getAnalysisData().setCFG(cfg); }
2009-10-14 14:03:49 -04:00
2009-06-02 13:58:47 -04:00
/// IntializeValues - Create initial dataflow values and meta data for
/// a given CFG. This is intended to be called by the dataflow solver.
void InitializeValues(const CFG& cfg);
};
2010-02-16 04:31:36 -05:00
void CheckUninitializedValues(CFG& cfg, ASTContext& Ctx, Diagnostic& Diags,
bool FullUninitTaint=false);
2009-06-02 13:58:47 -04:00
} // end namespace clang
#endif