Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/AutoRestore.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/* functions for restoring saved values at the end of a C++ scope */
8
9
#ifndef mozilla_AutoRestore_h_
10
#define mozilla_AutoRestore_h_
11
12
#include "mozilla/Attributes.h" // MOZ_STACK_CLASS
13
#include "mozilla/GuardObjects.h"
14
15
namespace mozilla {
16
17
/**
18
 * Save the current value of a variable and restore it when the object
19
 * goes out of scope.  For example:
20
 *   {
21
 *     AutoRestore<bool> savePainting(mIsPainting);
22
 *     mIsPainting = true;
23
 *
24
 *     // ... your code here ...
25
 *
26
 *     // mIsPainting is reset to its old value at the end of this block
27
 *   }
28
 */
29
template<class T>
30
class MOZ_RAII AutoRestore
31
{
32
private:
33
  T& mLocation;
34
  T mValue;
35
  MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
36
public:
37
  explicit AutoRestore(T& aValue MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
38
    : mLocation(aValue)
39
    , mValue(aValue)
40
18
  {
41
18
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
42
18
  }
Unexecuted instantiation: mozilla::AutoRestore<unsigned int>::AutoRestore(unsigned int&)
mozilla::AutoRestore<bool>::AutoRestore(bool&)
Line
Count
Source
40
18
  {
41
18
    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
42
18
  }
Unexecuted instantiation: mozilla::AutoRestore<LoggingType>::AutoRestore(LoggingType&)
Unexecuted instantiation: mozilla::AutoRestore<DBState*>::AutoRestore(DBState*&)
Unexecuted instantiation: mozilla::AutoRestore<mozilla::dom::Nullable<mozilla::BaseTimeDuration<mozilla::TimeDurationValueCalculator> > >::AutoRestore(mozilla::dom::Nullable<mozilla::BaseTimeDuration<mozilla::TimeDurationValueCalculator> >&)
Unexecuted instantiation: mozilla::AutoRestore<mozilla::dom::Element*>::AutoRestore(mozilla::dom::Element*&)
Unexecuted instantiation: mozilla::AutoRestore<nsISupports*>::AutoRestore(nsISupports*&)
Unexecuted instantiation: mozilla::AutoRestore<nsCOMPtr<nsIWidget> >::AutoRestore(nsCOMPtr<nsIWidget>&)
Unexecuted instantiation: mozilla::AutoRestore<unsigned char>::AutoRestore(unsigned char&)
Unexecuted instantiation: mozilla::AutoRestore<mozilla::TimeStamp>::AutoRestore(mozilla::TimeStamp&)
Unexecuted instantiation: mozilla::AutoRestore<mozilla::RestyleManager::AnimationsWithDestroyedFrame*>::AutoRestore(mozilla::RestyleManager::AnimationsWithDestroyedFrame*&)
Unexecuted instantiation: mozilla::AutoRestore<nsFrameState>::AutoRestore(nsFrameState&)
Unexecuted instantiation: mozilla::AutoRestore<unsigned short>::AutoRestore(unsigned short&)
Unexecuted instantiation: mozilla::AutoRestore<int>::AutoRestore(int&)
Unexecuted instantiation: mozilla::AutoRestore<nsIFrame*>::AutoRestore(nsIFrame*&)
43
  ~AutoRestore()
44
18
  {
45
18
    mLocation = mValue;
46
18
  }
Unexecuted instantiation: mozilla::AutoRestore<unsigned int>::~AutoRestore()
mozilla::AutoRestore<bool>::~AutoRestore()
Line
Count
Source
44
18
  {
45
18
    mLocation = mValue;
46
18
  }
Unexecuted instantiation: mozilla::AutoRestore<LoggingType>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<DBState*>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<mozilla::dom::Nullable<mozilla::BaseTimeDuration<mozilla::TimeDurationValueCalculator> > >::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<mozilla::dom::Element*>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<nsISupports*>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<nsCOMPtr<nsIWidget> >::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<unsigned char>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<mozilla::TimeStamp>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<mozilla::RestyleManager::AnimationsWithDestroyedFrame*>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<nsFrameState>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<unsigned short>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<int>::~AutoRestore()
Unexecuted instantiation: mozilla::AutoRestore<nsIFrame*>::~AutoRestore()
47
  T SavedValue() const
48
0
  {
49
0
    return mValue;
50
0
  }
Unexecuted instantiation: mozilla::AutoRestore<bool>::SavedValue() const
Unexecuted instantiation: mozilla::AutoRestore<int>::SavedValue() const
51
};
52
53
} // namespace mozilla
54
55
#endif /* !defined(mozilla_AutoRestore_h_) */