[llvm] r228200 - IR: Define MDNode uniquing sets automatically, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Feb 4 20:41:37 PST 2015


> On 2015 Feb 4, at 16:54, Sean Silva <chisophugis at gmail.com> wrote:
> 
> 
> 
> On Wed, Feb 4, 2015 at 4:53 PM, Sean Silva <chisophugis at gmail.com> wrote:
> I've definitely seen that pattern around. Not sure if we follow it consistently though. One downside is that (like the present case), it trigger's people's macro hygiene response when they don't see it (maybe could be ameliorated with a comment like "Foo.def #undef's all of its macros").
> 
> (in case it wasn't clear, I mean the the "Foo.def #undef's all of its macros" comment to be in the #include'er, not the .def file itself).
> 

IMO, adding a comment almost defeats the purpose.  It would be better
to incrementally update the cases that don't #undef their macros so
the pattern was more recognizable.

> -- Sean Silva
>  
> 
> -- Sean Silva
> 
> On Wed, Feb 4, 2015 at 2:07 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> On Wed, Feb 4, 2015 at 2:06 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> > On 2015-Feb-04, at 14:02, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> >
> > On Wed, Feb 4, 2015 at 1:46 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> > Author: dexonsmith
> > Date: Wed Feb  4 15:46:12 2015
> > New Revision: 228200
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=228200&view=rev
> > Log:
> > IR: Define MDNode uniquing sets automatically, NFC
> >
> > Modified:
> >     llvm/trunk/lib/IR/LLVMContextImpl.h
> >
> > Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=228200&r1=228199&r2=228200&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
> > +++ llvm/trunk/lib/IR/LLVMContextImpl.h Wed Feb  4 15:46:12 2015
> > @@ -357,9 +357,8 @@ public:
> >    DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
> >    DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
> >
> > -  DenseSet<MDTuple *, MDTupleInfo> MDTuples;
> > -  DenseSet<MDLocation *, MDLocationInfo> MDLocations;
> > -  DenseSet<GenericDebugNode *, GenericDebugNodeInfo> GenericDebugNodes;
> > +#define HANDLE_MDNODE_LEAF(CLASS) DenseSet<CLASS *, CLASS##Info> CLASS##s;
> >
> > I /think/ (but could well be wrong) that the usual style for def file inclusions is to undef the relevant macro immediately after the inclusion, so it doesn't leak into other things, etc.
> >
> > +#include "llvm/IR/Metadata.def"
> 
> Metadata.def ends with:
> 
> #undef HANDLE_METADATA
> #undef HANDLE_METADATA_LEAF
> #undef HANDLE_METADATA_BRANCH
> #undef HANDLE_MDNODE_LEAF
> #undef HANDLE_MDNODE_BRANCH
> 
> Ah, dandy. (maybe that's the common idiom - if not, might be nice to update existing .def files to be so smart - I'll keep it in mind next time I come across a #include .def)
>  
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> 
> 





More information about the llvm-commits mailing list