#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/VersionTuple.h"
+#include "clang/Basic/UsuallyTinyPtrVector.h"
#include "clang/AST/Decl.h"
#include "clang/AST/LambdaMangleContext.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/TemplateName.h"
#include "clang/AST/Type.h"
#include "clang/AST/CanonicalType.h"
-#include "clang/AST/UsuallyTinyPtrVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "clang/AST/OperationKinds.h"
#include "clang/AST/ASTVector.h"
#include "clang/AST/TemplateBase.h"
-#include "clang/AST/UsuallyTinyPtrVector.h"
+#include "clang/Basic/UsuallyTinyPtrVector.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TypeTraits.h"
#include "llvm/ADT/APSInt.h"
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_USUALLY_TINY_PTR_VECTOR_H
-#define LLVM_CLANG_AST_USUALLY_TINY_PTR_VECTOR_H
+#ifndef LLVM_CLANG_BASIC_USUALLY_TINY_PTR_VECTOR_H
+#define LLVM_CLANG_BASIC_USUALLY_TINY_PTR_VECTOR_H
#include <vector>
size_t size() const;
void push_back(T *Method);
+ iterator erase(const iterator ElementPos);
void Destroy();
};
Vec->push_back(Element);
}
+template<typename T>
+typename UsuallyTinyPtrVector<T>::iterator
+UsuallyTinyPtrVector<T>::erase(
+ const typename UsuallyTinyPtrVector<T>::iterator ElementPos) {
+ // only one item
+ if ((Storage & 0x01) == 0) {
+ // if the element is found remove it
+ if (ElementPos == reinterpret_cast<T **>(&Storage))
+ Storage = 0;
+ } else {
+ // multiple items in a vector; just do the erase, there is no
+ // benefit to collapsing back to a pointer
+ vector_type *Vec = reinterpret_cast<vector_type *>(Storage & ~0x01);
+ unsigned index = ElementPos -
+ const_cast<typename UsuallyTinyPtrVector<T>::iterator>(&Vec->front());
+ if (index < Vec->size())
+ return const_cast<typename UsuallyTinyPtrVector<T>::iterator>(
+ &*(Vec->erase(Vec->begin() + index)));
+ }
+ return end();
+}
+
template<typename T>
void UsuallyTinyPtrVector<T>::Destroy() {
if (Storage & 0x01)