From: Argyrios Kyrtzidis Date: Mon, 27 Feb 2012 21:09:45 +0000 (+0000) Subject: Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d45d361f2ce5c37824052357e2218e8a5509eba5;p=clang Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h" 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 --- diff --git a/include/clang/Analysis/Support/SaveAndRestore.h b/include/clang/Analysis/Support/SaveAndRestore.h deleted file mode 100644 index f720639490..0000000000 --- a/include/clang/Analysis/Support/SaveAndRestore.h +++ /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 -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 diff --git a/include/clang/Basic/LLVM.h b/include/clang/Basic/LLVM.h index 934a5a0159..813b49ed23 100644 --- a/include/clang/Basic/LLVM.h +++ b/include/clang/Basic/LLVM.h @@ -29,6 +29,9 @@ namespace llvm { template class SmallVector; template class SmallVectorImpl; + template + struct SaveAndRestore; + // Reference counting. template class IntrusiveRefCntPtr; template 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; diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp index de710abb5d..adb0002cd9 100644 --- a/lib/ARCMigrate/TransGCAttrs.cpp +++ b/lib/ARCMigrate/TransGCAttrs.cpp @@ -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" diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp index 5740e64d26..158cba8dd4 100644 --- a/lib/Analysis/AnalysisDeclContext.cpp +++ b/lib/Analysis/AnalysisDeclContext.cpp @@ -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" diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index 406aca8433..6bdbb26549 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -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" diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 86b96ce623..2b18563360 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -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; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index efe70e095a..b009a17173 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -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" diff --git a/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp index 02ef6dc9cc..991ca92b79 100644 --- a/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp @@ -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" diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index d2f81adda1..a98d3b8c59 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -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; diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 924a84332f..4dd8c84ef0 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -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"