[PATCH] D60547: Add checks for MSVC in LLVM_FALLTHROUGH and LLVM_NODISCARD

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 15:32:48 PDT 2019


rnk added inline comments.


================
Comment at: llvm/include/llvm/Support/Compiler.h:123
 /// LLVM_NODISCARD - Warn if a type or return value is discarded.
 #if __cplusplus > 201402L && __has_cpp_attribute(nodiscard)
 #define LLVM_NODISCARD [[nodiscard]]
----------------
ThadHouse wrote:
> zturner wrote:
> > zturner wrote:
> > > What about just changing this `&&` to an `||`?
> > Another question: Why is the check for `__cplusplus` even needed?
> Is there CI for testing against old versions of clang and GCC, to make sure that it doesn't cause a regression. Otherwise yeah I think that would work too. Although I wonder if the original creators had a reason to check a newer c++ version.
I think we can check `__has_cpp_attribute` without the `__cplusplus` check, or just check `defined(__cplusplus)` if we need to avoid C++ style attributes in C code. I'll test it and try committing that tomorrow.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60547/new/

https://reviews.llvm.org/D60547





More information about the llvm-commits mailing list