[llvm-commits] [llvm] r84820 - in /llvm/trunk: include/llvm/Metadata.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Metadata.cpp

Chris Lattner clattner at apple.com
Wed Oct 21 22:22:09 PDT 2009


On Oct 21, 2009, at 6:01 PM, Devang Patel wrote:

> Author: dpatel
> Date: Wed Oct 21 20:01:24 2009
> New Revision: 84820
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84820&view=rev
> Log:
> Fix getHandlerNames() interface. Now it populate clinet supplied  
> small vector with handler names.

Thanks Devang,

> +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 21 20:01:24 2009
> @@ -287,7 +287,7 @@
>
>   /// getHandlerNames - Get handler names. This is used by bitcode
>   /// writer.
> -  const StringMap<unsigned> *getHandlerNames();
> +  void getHandlerNames(SmallVectorImpl<std::pair<unsigned,  
> StringRef> >&N) const;

Please improve this comment: the bitcode writer shouldn't be mentioned.

> +/// writer and aswm writer.
> +void MetadataContext::
> +getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef>  
> >&Names) const {
> +  for (StringMap<unsigned>::const_iterator I = MDHandlerNames.begin 
> (),
> +         E = MDHandlerNames.end(); I != E; ++I)
> +    Names.push_back(std::make_pair(I->second, I->first()));

This implementation is returning the names in a nondeterminstic  
order.  Please return them according to their index.  Since the  
indices are dense, you can do something like:

   Names.resize(MDHandlerNames.size());
   for (StringMap<unsigned>::const_iterator I = MDHandlerNames.begin(),
          E = MDHandlerNames.end(); I != E; ++I)
     Names[I->second] = I->first;

Being careful for fencepost errors.

Thanks!

-Chris



More information about the llvm-commits mailing list