[PATCH] D18157: Refactor D17884 solution to use xmacro idiom
don hinton via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 14 13:48:35 PDT 2016
hintonda created this revision.
hintonda added reviewers: aaboud, dblaikie, aprantl.
hintonda added a subscriber: llvm-commits.
As recomended by Amjad, this is a follow on to D17884.
It uses the xmacro idiom and addresses Dave's concerns about relying
on, and exposing, implemetation details.
http://reviews.llvm.org/D18157
Files:
include/llvm/IR/DebugInfoMetadata.h
lib/IR/DIBuilder.cpp
lib/IR/DebugInfoMetadata.cpp
Index: lib/IR/DebugInfoMetadata.cpp
===================================================================
--- lib/IR/DebugInfoMetadata.cpp
+++ lib/IR/DebugInfoMetadata.cpp
@@ -184,6 +184,8 @@
setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
}
+#define DEFINE_GETIMPL_SIZE(CLASS) \
+ return Context.pImpl->CLASS##s.size();
#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
@@ -529,6 +531,10 @@
DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
}
+size_t DIImportedEntity::getSize(LLVMContext &Context) {
+ DEFINE_GETIMPL_SIZE(DIImportedEntity);
+}
+
DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity,
unsigned Line, MDString *Name,
Index: lib/IR/DIBuilder.cpp
===================================================================
--- lib/IR/DIBuilder.cpp
+++ lib/IR/DIBuilder.cpp
@@ -19,7 +19,6 @@
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
-#include "LLVMContextImpl.h"
using namespace llvm;
using namespace llvm::dwarf;
@@ -169,9 +168,9 @@
createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
Metadata *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
- unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
+ auto EntitiesCount = DIImportedEntity::getSize(C);
auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
- if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
+ if (EntitiesCount < DIImportedEntity::getSize(C))
// A new Imported Entity was just added to the context.
// Add it to the Imported Modules list.
AllImportedModules.emplace_back(M);
Index: include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- include/llvm/IR/DebugInfoMetadata.h
+++ include/llvm/IR/DebugInfoMetadata.h
@@ -2173,6 +2173,8 @@
}
public:
+ static size_t getSize(LLVMContext &Context);
+
DEFINE_MDNODE_GET(DIImportedEntity,
(unsigned Tag, DIScope *Scope, DINodeRef Entity,
unsigned Line, StringRef Name = ""),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18157.50642.patch
Type: text/x-patch
Size: 2427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160314/f46e7e25/attachment.bin>
More information about the llvm-commits
mailing list