[llvm-commits] [llvm] r133412 - in /llvm/trunk: include/llvm/Constants.h lib/Analysis/ConstantFolding.cpp lib/AsmParser/LLParser.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/CodeGen/ShadowStackGC.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/Transform

Jay Foad jay.foad at gmail.com
Tue Jun 21 11:35:28 PDT 2011


> Mostly I'm just skeptical of having an O(n) implicit conversion, but it also seems
> odd to privilege std::vector here.

I'm probably biased by what I'm trying to do now, but I'm thinking of
ArrayRef as a more flexible replacement for "const vector &". (More
flexible since it doesn't have to refer to a *vector*, it could refer
to a C array or other things.) Since "const vector &" implicitly
converts to vector, I don't see the problem with ArrayRef doing the
same.

> Why is this necessary?  Template metaprogramming in the constants-map
> implementation?

Yes. We have something like:

template<class ValType, class ValRefType>
class ConstantUniqueMap {
  void doSomething(ValRefType v) {
    ValType myVal = v;
  }
}

The template class is instantiated with things like

ConstantUniqueMap<char, char>
ConstantUniqueMap<SomeClassType, const SomeClassType &>
ConstantUniqueMap<vector<Constant*>, ArrayRef<Constant*>>

In the last case, I want the flexibility of being able to pass
(anything convertible to) an ArrayRef into doSomething().

Thanks,
Jay.




More information about the llvm-commits mailing list