[llvm-commits] [PATCH] New compatibility macro: LLVM_LVALUE_FUNCTION
Jordan Rose
jordan_rose at apple.com
Thu Nov 29 16:46:18 PST 2012
Doug reviewed this; committed as r168963.
On Nov 28, 2012, at 15:59 , Jordan Rose <jordan_rose at apple.com> wrote:
> Hi, all. I'm a committer up on the Clang side, but lately I've been working on an internal side project that gets to use C++11. I was trying to put a non-copyable type in an llvm::Optional, but I discovered that that's a problem when you want to conditionally move it somewhere else.
>
> I'd like to add rvalue overrides to Optional::getValue, but of course you can't do that unless the regular const version is annotated with an ampersand. Does anyone object to adding a new Compiler.h macro that expands to '&' when rvalue references are supported? It would look like this:
>
> const T& getValue() const LLVM_LVALUE_FUNCTION { … }
>
> This isn't perfect, but it could also help alleviate the "returning an inner pointer of a temporary" mistake that we keep making, and which GCC keeps causing us to crash on:
>
> const T *getInteriorPointer() const LLVM_LVALUE_FUNCTION;
> #if LLVM_USE_RVALUE_REFERENCES
> void getInteriorPointer() && LLVM_DELETED_FUNCTION;
> #endif
>
> Thanks,
> Jordan
>
> <LLVM_LVALUE_FUNCTION.diff>
More information about the llvm-commits
mailing list