view debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp @ 171:66f3bfe93da9

git version 2c4ca6832fa6b306ee6a7010bfb80a3f2596f824
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:07:02 +0900
parents 1d019706d866
children 0572611fdcc8
line wrap: on
line source

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/ilist.h"
#include "llvm/Support/Error.h"

int Array[] = {1, 2, 3};
auto IntPtr = reinterpret_cast<int *>(0xabc);

llvm::ArrayRef<int> ArrayRef(Array);
llvm::MutableArrayRef<int> MutableArrayRef(Array);
llvm::DenseMap<int, int> DenseMap = {{4, 5}, {6, 7}};
llvm::Expected<int> ExpectedValue(8);
llvm::Expected<int> ExpectedError(llvm::createStringError({}, ""));
llvm::Optional<int> OptionalValue(9);
llvm::Optional<int> OptionalNone(llvm::None);
llvm::SmallVector<int, 5> SmallVector = {10, 11, 12};
llvm::SmallString<5> SmallString("foo");
llvm::StringRef StringRef = "bar";
llvm::Twine Twine = llvm::Twine(SmallString) + StringRef;
llvm::PointerIntPair<int *, 1> PointerIntPair(IntPtr, 1);
llvm::PointerUnion<float *, int *> PointerUnion(IntPtr);

using IlistTag = llvm::ilist_tag<struct A>;
using SimpleIlistTag = llvm::ilist_tag<struct B>;
struct IlistNode : llvm::ilist_node<IlistNode, IlistTag>,
                   llvm::ilist_node<IlistNode, SimpleIlistTag> {
  int Value;
};
auto Ilist = [] {
  llvm::ilist<IlistNode, IlistTag> Result;
  for (int I : {13, 14, 15}) {
    Result.push_back(new IlistNode);
    Result.back().Value = I;
  }
  return Result;
}();
auto SimpleIlist = []() {
  llvm::simple_ilist<IlistNode, SimpleIlistTag> Result;
  for (auto &Node : Ilist)
    Result.push_front(Node);
  return Result;
}();

// Check expected instances to avoid compile errors.
auto CheckExpectedValue = static_cast<bool>(ExpectedValue);
auto CheckExpectedError = static_cast<bool>(ExpectedError);

int main() { return 0; }