[llvm-dev] MSVC warning noise on "LLVM_ATTRIBUTE_ALWAYS_INLINE inline void foo()"

Johan Engelen via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 21 03:40:34 PST 2015

On Mon, Dec 21, 2015 at 12:08 AM, Aaron Ballman <aaron at aaronballman.com>

> On Sun, Dec 20, 2015 at 5:57 PM, Johan Engelen <jbc.engelen at gmail.com>
> wrote:
> >
> > Perhaps LLVM_ATTRIBUTE_ALWAYS_INLINE could be defined to "inline" if the
> > compiler has no support for always_inline (currently it is set to
> nothing in
> > that case) ?
> > I think this would allow removal of the "inline" after
> Wouldn't this cause functions with MSVC that are marked
> LLVM_ATTRIBUTE_ALWAYS_INLINE but not 'inline' to not be inlined?

__forceinline means that MSVC will always inline that function, that is why
the extra "inline" results in a warning.

I propose:
in llvm/Support/Compiler.h

  #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0)
#define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
__forceinline  #else- #define LLVM_ATTRIBUTE_ALWAYS_INLINE+ #define

and elsewhere

  LLVM_ATTRIBUTE_ALWAYS_INLINE- inline bool operator==(StringRef LHS,
StringRef RHS) {
+ bool operator==(StringRef LHS, StringRef RHS) {
    return LHS.equals(RHS);

As far as I can tell from online documentation, that will do the correct
thing on MSVC and GCC. For non-MSVC, non-GCC, this will add "inline" in
front of some functions that do not have it right now, notably member
functions that are defined in the class definition (see e.g. StringRef.h
empty()). I will have to test if /that/ doesn't create a warning ;)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151221/5c9115df/attachment.html>

More information about the llvm-dev mailing list