Coverage Report

Created: 2018-10-19 17:52

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
Line
Count
Source
1
//===- TaintManager.h - Managing taint --------------------------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
//  This file provides APIs for adding, removing, querying symbol taint.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H
15
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H
16
17
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
19
#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
20
#include "clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h"
21
#include "llvm/ADT/ImmutableMap.h"
22
23
namespace clang {
24
namespace ento {
25
26
/// The GDM component containing the tainted root symbols. We lazily infer the
27
/// taint of the dependent symbols. Currently, this is a map from a symbol to
28
/// tag kind. TODO: Should support multiple tag kinds.
29
// FIXME: This does not use the nice trait macros because it must be accessible
30
// from multiple translation units.
31
struct TaintMap {};
32
33
using TaintMapImpl = llvm::ImmutableMap<SymbolRef, TaintTagType>;
34
35
template<> struct ProgramStateTrait<TaintMap>
36
    :  public ProgramStatePartialTrait<TaintMapImpl> {
37
27.3k
  static void *GDMIndex() {
38
27.3k
    static int index = 0;
39
27.3k
    return &index;
40
27.3k
  }
41
};
42
43
/// The GDM component mapping derived symbols' parent symbols to their
44
/// underlying regions. This is used to efficiently check whether a symbol is
45
/// tainted when it represents a sub-region of a tainted symbol.
46
struct DerivedSymTaint {};
47
48
using DerivedSymTaintImpl = llvm::ImmutableMap<SymbolRef, TaintedSubRegions>;
49
50
template<> struct ProgramStateTrait<DerivedSymTaint>
51
    :  public ProgramStatePartialTrait<DerivedSymTaintImpl> {
52
2.37k
  static void *GDMIndex() {
53
2.37k
    static int index;
54
2.37k
    return &index;
55
2.37k
  }
56
};
57
58
class TaintManager {
59
  TaintManager() = default;
60
};
61
62
} // namespace ento
63
} // namespace clang
64
65
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H