Displaying 6 results from an estimated 6 matches for "llvm_nodiscard".
2016 Sep 04
6
Adding [[nodiscard]] to Compiler.h
My 2 cents: get rid of LLVM_UNUSED_RESULT, and move to LLVM_NODISCARD.
For compilers that support it, it should be a strict superset of features
and functionality. The standard feature was written directly based on the
clang warn_unused_result stuff.
I would just migrate us onto the spelling and usage pattern that got
standardized. All we have to lose are warnings...
2016 Sep 02
2
Adding [[nodiscard]] to Compiler.h
...for the obvious cases of this
rather than having to wait for a runtime check.
This, of course, is exactly what the C++17 [[nodiscard]] attribute is
for - with new enough compilers in C++17 mode we can just declare the
class like so:
class [[nodiscard]] Error { ... };
So, I'd like to add an LLVM_NODISCARD macro to Compiler.h, and this is
where it gets interesting. Pre-C++17, clang already allows
__attribute__((warn_unused_result)) and [[clang::warn_unused_result]] to
be used on a class this way, with equivalent affects, so it'd be nice to
use that if we aren't building in C++17 mode.
We alr...
2016 Sep 02
2
Adding [[nodiscard]] to Compiler.h
Sanjoy Das <sanjoy at playingwithpointers.com> writes:
> Hi Justin,
>
> This SGTM generally, but please make the difference between
> LLVM_NODISCARD and LLVM_UNUSED_RESULT clear in the code. :)
Right, this is where it gets a little weird. LLVM_NODISCARD would be for
types, whereas LLVM_UNUSED_RESULT would be for functions. Depending on
your host compiler, using the wrong one might DTRT, but it won't across
all compilers.
Do you think docu...
2019 Apr 10
2
[RFC] Should we add isa_or_null<>?
Don Hinton via llvm-dev <llvm-dev at lists.llvm.org> writes:
> Used like this: isa<T,1>(v) or isa<T, true>(v)
I don't think I would know what that means when I see it in code.
-David
> On Sat, Apr 6, 2019 at 9:45 AM Mehdi AMINI via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> On Fri, Apr 5, 2019 at 5:15 AM Aaron Ballman via
2019 Apr 06
4
[RFC] Should we add isa_or_null<>?
What about a type not_null_impl<T> and we could write:
then you could just write bool x = isa<T>(not_null(val));
We provide a function not_null<T> that returns a not_null_impl<T>:
template<typename T>
not_null_impl<T> not_null(T *t) { return not_null_impl<T>{t}; }
and a specialization of isa that takes a not_null_impl<T>
template<typename T,
2019 Apr 22
3
[RFC] Should we add isa_or_null<>?
...ight a different way of doing it, and
> lazily used a bool. Here's something a little more realistic:
>
> struct NulCheck : std::true_type {};
>
> template <class X, class Check, class Y,
> typename std::enable_if<Check::value, X>::type * = nullptr>
> LLVM_NODISCARD inline bool isa(const Y *Val) {
> return Val && isa<X>(Val);
> }
>
> isa<foo,NulCheck>(v)
>
> Not sure if that's better than isa_and_nonnull or isa_nonnull, but it's
> shorter than the first, and only slightly longer than the second.
>
>
>...