diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-04-09 20:26:58 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-04-09 20:26:58 +0000 |
| commit | 26984fb4ebf20d74d32435517db882e8bfb2cca3 (patch) | |
| tree | edbc984a8caadcb0910d6fa50a6df284ba929685 | |
| parent | 800b66be9d47e9671f5b83eb99324a6d6c391c48 (diff) | |
| download | bcm5719-llvm-26984fb4ebf20d74d32435517db882e8bfb2cca3.tar.gz bcm5719-llvm-26984fb4ebf20d74d32435517db882e8bfb2cca3.zip | |
Remove copy of 'Optional' in Clang tree, and convert clients to use the one now in the LLVM tree.
llvm-svn: 100891
| -rw-r--r-- | clang/include/clang/Analysis/Support/Optional.h | 68 | ||||
| -rw-r--r-- | clang/lib/Checker/RegionStore.cpp | 18 | ||||
| -rw-r--r-- | clang/lib/Checker/UnixAPIChecker.cpp | 3 |
3 files changed, 11 insertions, 78 deletions
diff --git a/clang/include/clang/Analysis/Support/Optional.h b/clang/include/clang/Analysis/Support/Optional.h deleted file mode 100644 index 77c4825b4e5..00000000000 --- a/clang/include/clang/Analysis/Support/Optional.h +++ /dev/null @@ -1,68 +0,0 @@ -//===-- Optional.h - Simple variant for passing optional values ---*- 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 Optional, a template class modeled in the spirit of -// OCaml's 'opt' variant. The idea is to strongly type whether or not -// a value can be optional. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ANALYSIS_OPTIONAL -#define LLVM_CLANG_ANALYSIS_OPTIONAL - -#include <cassert> - -namespace clang { - -template<typename T> -class Optional { - T x; - unsigned hasVal : 1; -public: - explicit Optional() : x(), hasVal(false) {} - Optional(const T &y) : x(y), hasVal(true) {} - - static inline Optional create(const T* y) { - return y ? Optional(*y) : Optional(); - } - - Optional &operator=(const T &y) { - x = y; - hasVal = true; - return *this; - } - - const T* getPointer() const { assert(hasVal); return &x; } - const T& getValue() const { assert(hasVal); return x; } - - operator bool() const { return hasVal; } - bool hasValue() const { return hasVal; } - const T* operator->() const { return getPointer(); } - const T& operator*() const { assert(hasVal); return x; } -}; -} //end clang namespace - -namespace llvm { - -template<typename T> struct simplify_type; - -template <typename T> -struct simplify_type<const ::clang::Optional<T> > { - typedef const T* SimpleType; - static SimpleType getSimplifiedValue(const ::clang::Optional<T> &Val) { - return Val.getPointer(); - } -}; - -template <typename T> -struct simplify_type< ::clang::Optional<T> > - : public simplify_type<const ::clang::Optional<T> > {}; -} // end llvm namespace - -#endif diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index c97da33aaac..5e71bb0b3c7 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -14,22 +14,22 @@ // parameters are created lazily. // //===----------------------------------------------------------------------===// -#include "clang/Checker/PathSensitive/MemRegion.h" -#include "clang/Analysis/AnalysisContext.h" -#include "clang/Checker/PathSensitive/GRState.h" -#include "clang/Checker/PathSensitive/GRStateTrait.h" -#include "clang/Analysis/Analyses/LiveVariables.h" -#include "clang/Analysis/Support/Optional.h" -#include "clang/Basic/TargetInfo.h" #include "clang/AST/CharUnits.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/ExprCXX.h" - -#include "llvm/ADT/ImmutableMap.h" +#include "clang/Analysis/Analyses/LiveVariables.h" +#include "clang/Analysis/AnalysisContext.h" +#include "clang/Basic/TargetInfo.h" +#include "clang/Checker/PathSensitive/GRState.h" +#include "clang/Checker/PathSensitive/GRStateTrait.h" +#include "clang/Checker/PathSensitive/MemRegion.h" #include "llvm/ADT/ImmutableList.h" +#include "llvm/ADT/ImmutableMap.h" +#include "llvm/ADT/Optional.h" #include "llvm/Support/raw_ostream.h" using namespace clang; +using llvm::Optional; //===----------------------------------------------------------------------===// // Representation of binding keys. diff --git a/clang/lib/Checker/UnixAPIChecker.cpp b/clang/lib/Checker/UnixAPIChecker.cpp index 31864e74550..e9b8f0966ae 100644 --- a/clang/lib/Checker/UnixAPIChecker.cpp +++ b/clang/lib/Checker/UnixAPIChecker.cpp @@ -13,14 +13,15 @@ //===----------------------------------------------------------------------===// #include "GRExprEngineInternalChecks.h" -#include "clang/Analysis/Support/Optional.h" #include "clang/Basic/TargetInfo.h" #include "clang/Checker/BugReporter/BugType.h" #include "clang/Checker/PathSensitive/CheckerVisitor.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" #include <fcntl.h> using namespace clang; +using llvm::Optional; namespace { class UnixAPIChecker : public CheckerVisitor<UnixAPIChecker> { |

