mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 23:18:51 +00:00
83902832de
This reverts commit r218918, effectively reapplying r218914 after fixing an Ocaml bindings test and an Asan crash. The root cause of the latter was a tightened-up check in `DILexicalBlock::Verify()`, so I'll file a PR to investigate who requires the loose check (and why). Original commit message follows. -- This patch addresses the first stage of PR17891 by folding constant arguments together into a single MDString. Integers are stringified and a `\0` character is used as a separator. Part of PR17891. Note: I've attached my testcases upgrade scripts to the PR. If I've just broken your out-of-tree testcases, they might help. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219010 91177308-0d34-0410-b5e6-96231b3b80d8
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
//===- llvm/unittest/IR/DebugInfo.cpp - DebugInfo tests -------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/DebugInfo.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace llvm {
|
|
|
|
static void PrintTo(const StringRef &S, ::std::ostream *os) {
|
|
*os << "(" << (void *)S.data() << "," << S.size() << ") = '";
|
|
for (auto C : S)
|
|
if (C)
|
|
*os << C;
|
|
else
|
|
*os << "\\00";
|
|
*os << "'";
|
|
}
|
|
static void PrintTo(const DIHeaderFieldIterator &I, ::std::ostream *os) {
|
|
PrintTo(I.getCurrent(), os);
|
|
*os << " in ";
|
|
PrintTo(I.getHeader(), os);
|
|
}
|
|
|
|
} // end namespace llvm
|
|
|
|
namespace {
|
|
|
|
#define MAKE_FIELD_ITERATOR(S) \
|
|
DIHeaderFieldIterator(StringRef(S, sizeof(S) - 1))
|
|
TEST(DebugInfoTest, DIHeaderFieldIterator) {
|
|
ASSERT_EQ(DIHeaderFieldIterator(), DIHeaderFieldIterator());
|
|
|
|
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR(""));
|
|
ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR(""));
|
|
ASSERT_EQ("", *DIHeaderFieldIterator(""));
|
|
|
|
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff"));
|
|
ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff"));
|
|
ASSERT_EQ("stuff", *DIHeaderFieldIterator("stuff"));
|
|
|
|
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("st\0uff"));
|
|
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("st\0uff"));
|
|
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("st\0uff"));
|
|
ASSERT_EQ("st", *MAKE_FIELD_ITERATOR("st\0uff"));
|
|
ASSERT_EQ("uff", *++MAKE_FIELD_ITERATOR("st\0uff"));
|
|
|
|
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff\0"));
|
|
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff\0"));
|
|
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("stuff\0"));
|
|
ASSERT_EQ("stuff", *MAKE_FIELD_ITERATOR("stuff\0"));
|
|
ASSERT_EQ("", *++MAKE_FIELD_ITERATOR("stuff\0"));
|
|
|
|
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("\0stuff"));
|
|
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("\0stuff"));
|
|
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("\0stuff"));
|
|
ASSERT_EQ("", *MAKE_FIELD_ITERATOR("\0stuff"));
|
|
ASSERT_EQ("stuff", *++MAKE_FIELD_ITERATOR("\0stuff"));
|
|
}
|
|
|
|
} // end namespace
|