Coverage Report

Created: 2020-06-26 05:44

/home/arjun/llvm-project/llvm/include/llvm/Support/SaveAndRestore.h
Line
Count
Source (jump to first uncovered line)
1
//===-- SaveAndRestore.h - Utility  -------------------------------*- C++ -*-=//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// This file provides utility classes that use RAII to save and restore
11
/// values.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_SUPPORT_SAVEANDRESTORE_H
16
#define LLVM_SUPPORT_SAVEANDRESTORE_H
17
18
namespace llvm {
19
20
/// A utility class that uses RAII to save and restore the value of a variable.
21
template <typename T> struct SaveAndRestore {
22
0
  SaveAndRestore(T &X) : X(X), OldValue(X) {}
Unexecuted instantiation: _ZN4llvm14SaveAndRestoreIiEC2ERi
Unexecuted instantiation: _ZN4llvm14SaveAndRestoreIjEC2ERj
23
0
  SaveAndRestore(T &X, const T &NewValue) : X(X), OldValue(X) {
24
0
    X = NewValue;
25
0
  }
26
0
  ~SaveAndRestore() { X = OldValue; }
Unexecuted instantiation: _ZN4llvm14SaveAndRestoreIiED2Ev
Unexecuted instantiation: _ZN4llvm14SaveAndRestoreIjED2Ev
Unexecuted instantiation: _ZN4llvm14SaveAndRestoreIPNS_21PrettyStackTraceEntryEED2Ev
27
0
  T get() { return OldValue; }
28
29
private:
30
  T &X;
31
  T OldValue;
32
};
33
34
} // namespace llvm
35
36
#endif