]> granicus.if.org Git - clang/commitdiff
Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h"
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 27 Feb 2012 21:09:45 +0000 (21:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 27 Feb 2012 21:09:45 +0000 (21:09 +0000)
to make it more widely available.

Depends on llvm commit r151564

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151566 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Support/SaveAndRestore.h [deleted file]
include/clang/Basic/LLVM.h
lib/ARCMigrate/TransGCAttrs.cpp
lib/Analysis/AnalysisDeclContext.cpp
lib/Analysis/CFG.cpp
lib/Analysis/UninitializedValues.cpp
lib/Serialization/ASTReader.cpp
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
tools/libclang/CIndex.cpp

diff --git a/include/clang/Analysis/Support/SaveAndRestore.h b/include/clang/Analysis/Support/SaveAndRestore.h
deleted file mode 100644 (file)
index f720639..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//===-- SaveAndRestore.h - Utility  -------------------------------*- 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 utility classes that uses RAII to save and restore
-//  values.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ANALYSIS_SAVERESTORE
-#define LLVM_CLANG_ANALYSIS_SAVERESTORE
-
-namespace clang {
-
-// SaveAndRestore - A utility class that uses RAII to save and restore
-//  the value of a variable.
-template<typename T>
-struct SaveAndRestore {
-  SaveAndRestore(T& x) : X(x), old_value(x) {}
-  SaveAndRestore(T& x, const T &new_value) : X(x), old_value(x) {
-    X = new_value;
-  }
-  ~SaveAndRestore() { X = old_value; }
-  T get() { return old_value; }
-private:
-  T& X;
-  T old_value;
-};
-
-// SaveOr - Similar to SaveAndRestore.  Operates only on bools; the old
-//  value of a variable is saved, and during the dstor the old value is
-//  or'ed with the new value.
-struct SaveOr {
-  SaveOr(bool& x) : X(x), old_value(x) { x = false; }
-  ~SaveOr() { X |= old_value; }
-private:
-  bool& X;
-  const bool old_value;
-};
-
-}
-#endif
index 934a5a01593d97485f9de0f1bc1927f15907aaa0..813b49ed235326568339f9091d3874232b81e56c 100644 (file)
@@ -29,6 +29,9 @@ namespace llvm {
   template<typename T, unsigned N> class SmallVector;
   template<typename T> class SmallVectorImpl;
 
+  template<typename T>
+  struct SaveAndRestore;
+
   // Reference counting.
   template <typename T> class IntrusiveRefCntPtr;
   template <typename T> struct IntrusiveRefCntPtrInfo;
@@ -56,6 +59,7 @@ namespace clang {
   using llvm::SmallString;
   using llvm::SmallVector;
   using llvm::SmallVectorImpl;
+  using llvm::SaveAndRestore;
 
   // Reference counting.
   using llvm::IntrusiveRefCntPtr;
index de710abb5d5e28acbcfb54df675c833b1dfc2330..adb0002cd97cdc9621f25b704d386be8726e90fb 100644 (file)
@@ -11,7 +11,7 @@
 #include "Internals.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/TinyPtrVector.h"
index 5740e64d26dfe512d53beff24f9ac9a2611dfc58..158cba8dd4a785d8952fa1fb4bdef7d898eabe5f 100644 (file)
@@ -24,7 +24,7 @@
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CFGStmtMap.h"
 #include "clang/Analysis/Support/BumpVector.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/ErrorHandling.h"
 
index 406aca84330f800635ef9a652568dcf5ceea5772..6bdbb26549c254ed275c1fdb0eb6d3dde4ba1ce5 100644 (file)
@@ -12,7 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtVisitor.h"
index 86b96ce6230f70b5c33f99a65615586fc3250e96..2b185633606654394f3f39782e57ddfc84115ceb 100644 (file)
@@ -21,7 +21,7 @@
 #include "clang/Analysis/AnalysisContext.h"
 #include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
 #include "clang/Analysis/Analyses/UninitializedValues.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 
 using namespace clang;
 
index efe70e095a1b3e75954cdcffd4dffc10524c9d2d..b009a171731afe62541280aa274affd8a5424300 100644 (file)
@@ -27,7 +27,7 @@
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLocVisitor.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
index 02ef6dc9cc18cc5b8256b92f6638a86c12197790..991ca92b79e0e832cc9bcdfc8016c839b11ffa43 100644 (file)
@@ -15,7 +15,7 @@
 #include "ClangSACheckers.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtVisitor.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
index d2f81adda1ec93819b8a60dcf2a930b216c12733..a98d3b8c59302f4cc0ccf31c3e9cee35f145283c 100644 (file)
@@ -14,7 +14,7 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "clang/AST/DeclCXX.h"
 
 using namespace clang;
index 924a84332f73a8a33010d89e373fd4d9955499ea..4dd8c84ef08ee0367eb920756e20c5da476962f3 100644 (file)
@@ -35,7 +35,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "clang/Analysis/Support/SaveAndRestore.h"
+#include "llvm/ADT/SaveAndRestore.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/MemoryBuffer.h"