mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
83 lines
3.4 KiB
C++
83 lines
3.4 KiB
C++
//===- llvm/unittest/IR/DebugInfo.cpp - DebugInfo tests -------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/DebugInfoMetadata.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(DINodeTest, getFlag) {
|
|
// Some valid flags.
|
|
EXPECT_EQ(DINode::FlagPublic, DINode::getFlag("DIFlagPublic"));
|
|
EXPECT_EQ(DINode::FlagProtected, DINode::getFlag("DIFlagProtected"));
|
|
EXPECT_EQ(DINode::FlagPrivate, DINode::getFlag("DIFlagPrivate"));
|
|
EXPECT_EQ(DINode::FlagVector, DINode::getFlag("DIFlagVector"));
|
|
EXPECT_EQ(DINode::FlagRValueReference,
|
|
DINode::getFlag("DIFlagRValueReference"));
|
|
|
|
// FlagAccessibility shouldn't work.
|
|
EXPECT_EQ(0u, DINode::getFlag("DIFlagAccessibility"));
|
|
|
|
// Some other invalid strings.
|
|
EXPECT_EQ(0u, DINode::getFlag("FlagVector"));
|
|
EXPECT_EQ(0u, DINode::getFlag("Vector"));
|
|
EXPECT_EQ(0u, DINode::getFlag("other things"));
|
|
EXPECT_EQ(0u, DINode::getFlag("DIFlagOther"));
|
|
}
|
|
|
|
TEST(DINodeTest, getFlagString) {
|
|
// Some valid flags.
|
|
EXPECT_EQ(StringRef("DIFlagPublic"),
|
|
DINode::getFlagString(DINode::FlagPublic));
|
|
EXPECT_EQ(StringRef("DIFlagProtected"),
|
|
DINode::getFlagString(DINode::FlagProtected));
|
|
EXPECT_EQ(StringRef("DIFlagPrivate"),
|
|
DINode::getFlagString(DINode::FlagPrivate));
|
|
EXPECT_EQ(StringRef("DIFlagVector"),
|
|
DINode::getFlagString(DINode::FlagVector));
|
|
EXPECT_EQ(StringRef("DIFlagRValueReference"),
|
|
DINode::getFlagString(DINode::FlagRValueReference));
|
|
|
|
// FlagAccessibility actually equals FlagPublic.
|
|
EXPECT_EQ(StringRef("DIFlagPublic"),
|
|
DINode::getFlagString(DINode::FlagAccessibility));
|
|
|
|
// Some other invalid flags.
|
|
EXPECT_EQ(StringRef(),
|
|
DINode::getFlagString(DINode::FlagPublic | DINode::FlagVector));
|
|
EXPECT_EQ(StringRef(), DINode::getFlagString(DINode::FlagFwdDecl |
|
|
DINode::FlagArtificial));
|
|
EXPECT_EQ(StringRef(),
|
|
DINode::getFlagString(static_cast<DINode::DIFlags>(0xffff)));
|
|
}
|
|
|
|
TEST(DINodeTest, splitFlags) {
|
|
// Some valid flags.
|
|
#define CHECK_SPLIT(FLAGS, VECTOR, REMAINDER) \
|
|
{ \
|
|
SmallVector<DINode::DIFlags, 8> V; \
|
|
EXPECT_EQ(REMAINDER, DINode::splitFlags(FLAGS, V)); \
|
|
EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
|
|
}
|
|
CHECK_SPLIT(DINode::FlagPublic, {DINode::FlagPublic}, DINode::FlagZero);
|
|
CHECK_SPLIT(DINode::FlagProtected, {DINode::FlagProtected}, DINode::FlagZero);
|
|
CHECK_SPLIT(DINode::FlagPrivate, {DINode::FlagPrivate}, DINode::FlagZero);
|
|
CHECK_SPLIT(DINode::FlagVector, {DINode::FlagVector}, DINode::FlagZero);
|
|
CHECK_SPLIT(DINode::FlagRValueReference, {DINode::FlagRValueReference},
|
|
DINode::FlagZero);
|
|
DINode::DIFlags Flags[] = {DINode::FlagFwdDecl, DINode::FlagVector};
|
|
CHECK_SPLIT(DINode::FlagFwdDecl | DINode::FlagVector, Flags,
|
|
DINode::FlagZero);
|
|
CHECK_SPLIT(DINode::FlagZero, {}, DINode::FlagZero);
|
|
#undef CHECK_SPLIT
|
|
}
|
|
|
|
} // end namespace
|