Kaydet (Commit) 11b741ac authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 56379beb
......@@ -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);
}
......
......@@ -644,9 +644,8 @@ void GtkSalData::ErrorTrapPush()
gdk_error_trap_push ();
}
bool GtkSalData::ErrorTrapPop( bool bIgnoreError )
bool GtkSalData::ErrorTrapPop( bool )
{
(void) bIgnoreError;
return gdk_error_trap_pop () != 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment