[llvm] r234274 - DebugInfo: Move DIFlag-related API from DIDescriptor to DebugNode
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 6 18:21:40 PDT 2015
Author: dexonsmith
Date: Mon Apr 6 20:21:40 2015
New Revision: 234274
URL: http://llvm.org/viewvc/llvm-project?rev=234274&view=rev
Log:
DebugInfo: Move DIFlag-related API from DIDescriptor to DebugNode
Modified:
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/unittests/IR/DebugInfoTest.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 6 20:21:40 2015
@@ -77,16 +77,6 @@ public:
FlagAccessibility = DebugNode::FlagAccessibility
};
- static unsigned getFlag(StringRef Flag);
- static const char *getFlagString(unsigned Flag);
-
- /// \brief Split up a flags bitfield.
- ///
- /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
- /// any remaining (unrecognized) bits.
- static unsigned splitFlags(unsigned Flags,
- SmallVectorImpl<unsigned> &SplitFlags);
-
protected:
const MDNode *DbgNode;
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 6 20:21:40 2015
@@ -175,6 +175,16 @@ public:
FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic
};
+ static unsigned getFlag(StringRef Flag);
+ static const char *getFlagString(unsigned Flag);
+
+ /// \brief Split up a flags bitfield.
+ ///
+ /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
+ /// any remaining (unrecognized) bits.
+ static unsigned splitFlags(unsigned Flags,
+ SmallVectorImpl<unsigned> &SplitFlags);
+
DebugNodeRef getRef() const { return DebugNodeRef::get(this); }
static bool classof(const Metadata *MD) {
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Apr 6 20:21:40 2015
@@ -3165,7 +3165,7 @@ bool LLParser::ParseMDField(LocTy Loc, S
if (Lex.getKind() != lltok::DIFlag)
return TokError("expected debug info flag");
- Val = DIDescriptor::getFlag(Lex.getStrVal());
+ Val = DebugNode::getFlag(Lex.getStrVal());
if (!Val)
return TokError(Twine("invalid debug info flag flag '") +
Lex.getStrVal() + "'");
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Mon Apr 6 20:21:40 2015
@@ -1443,11 +1443,11 @@ void MDFieldPrinter::printDIFlags(String
Out << FS << Name << ": ";
SmallVector<unsigned, 8> SplitFlags;
- unsigned Extra = DIDescriptor::splitFlags(Flags, SplitFlags);
+ unsigned Extra = DebugNode::splitFlags(Flags, SplitFlags);
FieldSeparator FlagsFS(" | ");
for (unsigned F : SplitFlags) {
- const char *StringF = DIDescriptor::getFlagString(F);
+ const char *StringF = DebugNode::getFlagString(F);
assert(StringF && "Expected valid flag");
Out << FlagsFS << StringF;
}
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 6 20:21:40 2015
@@ -17,7 +17,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringSwitch.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
@@ -38,48 +37,6 @@ using namespace llvm::dwarf;
// DIDescriptor
//===----------------------------------------------------------------------===//
-unsigned DIDescriptor::getFlag(StringRef Flag) {
- return StringSwitch<unsigned>(Flag)
-#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
-#include "llvm/IR/DebugInfoFlags.def"
- .Default(0);
-}
-
-const char *DIDescriptor::getFlagString(unsigned Flag) {
- switch (Flag) {
- default:
- return "";
-#define HANDLE_DI_FLAG(ID, NAME) \
- case Flag##NAME: \
- return "DIFlag" #NAME;
-#include "llvm/IR/DebugInfoFlags.def"
- }
-}
-
-unsigned DIDescriptor::splitFlags(unsigned Flags,
- SmallVectorImpl<unsigned> &SplitFlags) {
- // Accessibility flags need to be specially handled, since they're packed
- // together.
- if (unsigned A = Flags & FlagAccessibility) {
- if (A == FlagPrivate)
- SplitFlags.push_back(FlagPrivate);
- else if (A == FlagProtected)
- SplitFlags.push_back(FlagProtected);
- else
- SplitFlags.push_back(FlagPublic);
- Flags &= ~A;
- }
-
-#define HANDLE_DI_FLAG(ID, NAME) \
- if (unsigned Bit = Flags & ID) { \
- SplitFlags.push_back(Bit); \
- Flags &= ~Bit; \
- }
-#include "llvm/IR/DebugInfoFlags.def"
-
- return Flags;
-}
-
static Metadata *getField(const MDNode *DbgNode, unsigned Elt) {
if (!DbgNode || Elt >= DbgNode->getNumOperands())
return nullptr;
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Mon Apr 6 20:21:40 2015
@@ -14,6 +14,7 @@
#include "llvm/IR/DebugInfoMetadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/IR/Function.h"
using namespace llvm;
@@ -65,6 +66,49 @@ MDLocation *MDLocation::getImpl(LLVMCont
Storage, Context.pImpl->MDLocations);
}
+unsigned DebugNode::getFlag(StringRef Flag) {
+ return StringSwitch<unsigned>(Flag)
+#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
+#include "llvm/IR/DebugInfoFlags.def"
+ .Default(0);
+}
+
+const char *DebugNode::getFlagString(unsigned Flag) {
+ switch (Flag) {
+ default:
+ return "";
+#define HANDLE_DI_FLAG(ID, NAME) \
+ case Flag##NAME: \
+ return "DIFlag" #NAME;
+#include "llvm/IR/DebugInfoFlags.def"
+ }
+}
+
+unsigned DebugNode::splitFlags(unsigned Flags,
+ SmallVectorImpl<unsigned> &SplitFlags) {
+ // Accessibility flags need to be specially handled, since they're packed
+ // together.
+ if (unsigned A = Flags & FlagAccessibility) {
+ if (A == FlagPrivate)
+ SplitFlags.push_back(FlagPrivate);
+ else if (A == FlagProtected)
+ SplitFlags.push_back(FlagProtected);
+ else
+ SplitFlags.push_back(FlagPublic);
+ Flags &= ~A;
+ }
+
+#define HANDLE_DI_FLAG(ID, NAME) \
+ if (unsigned Bit = Flags & ID) { \
+ SplitFlags.push_back(Bit); \
+ Flags &= ~Bit; \
+ }
+#include "llvm/IR/DebugInfoFlags.def"
+
+ return Flags;
+}
+
+
static StringRef getString(const MDString *S) {
if (S)
return S->getString();
Modified: llvm/trunk/unittests/IR/DebugInfoTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/DebugInfoTest.cpp?rev=234274&r1=234273&r2=234274&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/DebugInfoTest.cpp (original)
+++ llvm/trunk/unittests/IR/DebugInfoTest.cpp Mon Apr 6 20:21:40 2015
@@ -7,76 +7,75 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace {
-TEST(DIDescriptorTest, getFlag) {
+TEST(DebugNodeTest, getFlag) {
// Some valid flags.
- EXPECT_EQ(DIDescriptor::FlagPublic, DIDescriptor::getFlag("DIFlagPublic"));
- EXPECT_EQ(DIDescriptor::FlagProtected,
- DIDescriptor::getFlag("DIFlagProtected"));
- EXPECT_EQ(DIDescriptor::FlagPrivate, DIDescriptor::getFlag("DIFlagPrivate"));
- EXPECT_EQ(DIDescriptor::FlagVector, DIDescriptor::getFlag("DIFlagVector"));
- EXPECT_EQ(DIDescriptor::FlagRValueReference,
- DIDescriptor::getFlag("DIFlagRValueReference"));
+ EXPECT_EQ(DebugNode::FlagPublic, DebugNode::getFlag("DIFlagPublic"));
+ EXPECT_EQ(DebugNode::FlagProtected, DebugNode::getFlag("DIFlagProtected"));
+ EXPECT_EQ(DebugNode::FlagPrivate, DebugNode::getFlag("DIFlagPrivate"));
+ EXPECT_EQ(DebugNode::FlagVector, DebugNode::getFlag("DIFlagVector"));
+ EXPECT_EQ(DebugNode::FlagRValueReference,
+ DebugNode::getFlag("DIFlagRValueReference"));
// FlagAccessibility shouldn't work.
- EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagAccessibility"));
+ EXPECT_EQ(0u, DebugNode::getFlag("DIFlagAccessibility"));
// Some other invalid strings.
- EXPECT_EQ(0u, DIDescriptor::getFlag("FlagVector"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("Vector"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("other things"));
- EXPECT_EQ(0u, DIDescriptor::getFlag("DIFlagOther"));
+ EXPECT_EQ(0u, DebugNode::getFlag("FlagVector"));
+ EXPECT_EQ(0u, DebugNode::getFlag("Vector"));
+ EXPECT_EQ(0u, DebugNode::getFlag("other things"));
+ EXPECT_EQ(0u, DebugNode::getFlag("DIFlagOther"));
}
-TEST(DIDescriptorTest, getFlagString) {
+TEST(DebugNodeTest, getFlagString) {
// Some valid flags.
EXPECT_EQ(StringRef("DIFlagPublic"),
- DIDescriptor::getFlagString(DIDescriptor::FlagPublic));
+ DebugNode::getFlagString(DebugNode::FlagPublic));
EXPECT_EQ(StringRef("DIFlagProtected"),
- DIDescriptor::getFlagString(DIDescriptor::FlagProtected));
+ DebugNode::getFlagString(DebugNode::FlagProtected));
EXPECT_EQ(StringRef("DIFlagPrivate"),
- DIDescriptor::getFlagString(DIDescriptor::FlagPrivate));
+ DebugNode::getFlagString(DebugNode::FlagPrivate));
EXPECT_EQ(StringRef("DIFlagVector"),
- DIDescriptor::getFlagString(DIDescriptor::FlagVector));
+ DebugNode::getFlagString(DebugNode::FlagVector));
EXPECT_EQ(StringRef("DIFlagRValueReference"),
- DIDescriptor::getFlagString(DIDescriptor::FlagRValueReference));
+ DebugNode::getFlagString(DebugNode::FlagRValueReference));
// FlagAccessibility actually equals FlagPublic.
EXPECT_EQ(StringRef("DIFlagPublic"),
- DIDescriptor::getFlagString(DIDescriptor::FlagAccessibility));
+ DebugNode::getFlagString(DebugNode::FlagAccessibility));
// Some other invalid flags.
- EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(DIDescriptor::FlagPublic |
- DIDescriptor::FlagVector));
- EXPECT_EQ(StringRef(),
- DIDescriptor::getFlagString(DIDescriptor::FlagFwdDecl |
- DIDescriptor::FlagArtificial));
- EXPECT_EQ(StringRef(), DIDescriptor::getFlagString(0xffff));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagPublic |
+ DebugNode::FlagVector));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(DebugNode::FlagFwdDecl |
+ DebugNode::FlagArtificial));
+ EXPECT_EQ(StringRef(), DebugNode::getFlagString(0xffff));
}
-TEST(DIDescriptorTest, splitFlags) {
- // Some valid flags.
+TEST(DebugNodeTest, splitFlags) {
+// Some valid flags.
#define CHECK_SPLIT(FLAGS, VECTOR, REMAINDER) \
{ \
SmallVector<unsigned, 8> V; \
- EXPECT_EQ(REMAINDER, DIDescriptor::splitFlags(FLAGS, V)); \
- EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
+ EXPECT_EQ(REMAINDER, DebugNode::splitFlags(FLAGS, V)); \
+ EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \
}
- CHECK_SPLIT(DIDescriptor::FlagPublic, {DIDescriptor::FlagPublic}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagProtected, {DIDescriptor::FlagProtected}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagPrivate, {DIDescriptor::FlagPrivate}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagVector, {DIDescriptor::FlagVector}, 0u);
- CHECK_SPLIT(DIDescriptor::FlagRValueReference, {DIDescriptor::FlagRValueReference}, 0u);
- unsigned Flags[] = {DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector};
- CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, Flags, 0u);
+ CHECK_SPLIT(DebugNode::FlagPublic, {DebugNode::FlagPublic}, 0u);
+ CHECK_SPLIT(DebugNode::FlagProtected, {DebugNode::FlagProtected}, 0u);
+ CHECK_SPLIT(DebugNode::FlagPrivate, {DebugNode::FlagPrivate}, 0u);
+ CHECK_SPLIT(DebugNode::FlagVector, {DebugNode::FlagVector}, 0u);
+ CHECK_SPLIT(DebugNode::FlagRValueReference, {DebugNode::FlagRValueReference},
+ 0u);
+ unsigned Flags[] = {DebugNode::FlagFwdDecl, DebugNode::FlagVector};
+ CHECK_SPLIT(DebugNode::FlagFwdDecl | DebugNode::FlagVector, Flags, 0u);
CHECK_SPLIT(0x100000u, {}, 0x100000u);
- CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, {DIDescriptor::FlagVector},
+ CHECK_SPLIT(0x100000u | DebugNode::FlagVector, {DebugNode::FlagVector},
0x100000u);
#undef CHECK_SPLIT
}
More information about the llvm-commits
mailing list