mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 15:39:06 +00:00
926ddae882
This is used to mark functions with the C++11 [[ noreturn ]] or C11 _Noreturn attributes. Patch by Victor Leschuk! https://reviews.llvm.org/D23167 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278940 91177308-0d34-0410-b5e6-96231b3b80d8
83 lines
3.3 KiB
C++
83 lines
3.3 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/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(0xffff));
|
|
}
|
|
|
|
TEST(DINodeTest, splitFlags) {
|
|
// Some valid flags.
|
|
#define CHECK_SPLIT(FLAGS, VECTOR, REMAINDER) \
|
|
{ \
|
|
SmallVector<unsigned, 8> V; \
|
|
EXPECT_EQ(REMAINDER, DINode::splitFlags(FLAGS, V)); \
|
|
EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
|
|
}
|
|
CHECK_SPLIT(DINode::FlagPublic, {DINode::FlagPublic}, 0u);
|
|
CHECK_SPLIT(DINode::FlagProtected, {DINode::FlagProtected}, 0u);
|
|
CHECK_SPLIT(DINode::FlagPrivate, {DINode::FlagPrivate}, 0u);
|
|
CHECK_SPLIT(DINode::FlagVector, {DINode::FlagVector}, 0u);
|
|
CHECK_SPLIT(DINode::FlagRValueReference, {DINode::FlagRValueReference}, 0u);
|
|
unsigned Flags[] = {DINode::FlagFwdDecl, DINode::FlagVector};
|
|
CHECK_SPLIT(DINode::FlagFwdDecl | DINode::FlagVector, Flags, 0u);
|
|
CHECK_SPLIT(0x200000u, {}, 0x200000u);
|
|
CHECK_SPLIT(0x200000u | DINode::FlagVector, {DINode::FlagVector}, 0x200000u);
|
|
CHECK_SPLIT(0x200000u | DINode::FlagNoReturn, {DINode::FlagNoReturn}, 0x200000u);
|
|
#undef CHECK_SPLIT
|
|
}
|
|
|
|
} // end namespace
|