diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-11-17 08:09:59 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-11-17 08:16:47 +0100 |
commit | 11b741ac5e32c65475c61961679adac11660eab2 (patch) | |
tree | bfbadfc306fc56065c08decba934f7144660ad1d /compilerplugins | |
parent | 56379beb1ea55c1262382039aba2dbb335e92b67 (diff) |
Make loplugin:casttovoid more resilient against macros
...in the type at the start of a ParmVarDecl, so that it does not erroneously
assume in isSharedCAndCppCode that the whole decl is in "the body of a macro
definition". (Even better might be to check the whole ParmVarDecl is inside one
macro body.)
Turns out that vcl/unx/gtk/gtkdata.cxx indirectly includes stdbool.h via some
vcl/inc/unx/saldisp.hxx -> workdir/UnpackedTarball/epoxy/include/epoxy/glx.h ->
workdir/UnpackedTarball/epoxy/include/epoxy/gl.h, and Clang's stdbool.h contains
> /* Don't define bool, true, and false in C++, except as a GNU extension. */
> #ifndef __cplusplus
> #define bool _Bool
> #define true 1
> #define false 0
> #elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
> /* Define _Bool, bool, false, true as a GNU extension. */
> #define _Bool bool
> #define bool bool
> #define false false
> #define true true
> #endif
since <http://llvm.org/viewvc/llvm-project?view=revision&revision=115028>
"Define _Bool, bool, true, and false macros in <stdbool.h> when we're in a
GNU-compatible C++ dialect. Fixes <rdar://problem/8477819>" while GCC's
stdbool.h has meanwhile been improved with
<https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=216679> "C++11
explicitly forbids macros for bool, true and false" to
> #ifndef __cplusplus
>
> #define bool _Bool
> #define true 1
> #define false 0
>
> #else /* __cplusplus */
>
> /* Supporting _Bool in C++ is a GCC extension. */
> #define _Bool bool
>
> #if __cplusplus < 201103L
> /* Defining these macros in C++98 is a GCC extension. */
> #define bool bool
> #define false false
> #define true true
> #endif
>
> #endif /* __cplusplus */
Change-Id: I42caab83ac6e4d5e5297376136a6bbe6f3d70818
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/casttovoid.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx index 1ed7e4e19c78..e98388c8de7b 100644 --- a/compilerplugins/clang/casttovoid.cxx +++ b/compilerplugins/clang/casttovoid.cxx @@ -414,7 +414,7 @@ private: } bool isSharedCAndCppCode(VarDecl const * decl) const { - auto loc = decl->getLocStart(); + auto loc = decl->getLocation(); while (compiler.getSourceManager().isMacroArgExpansion(loc)) { loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); } |