[Qt-creator] Clang-Tidy and Clazy analyzer using '-D__cplusplus=199711L'
Tyson Wiser
twiser.public at gmail.com
Thu Aug 9 18:33:15 CEST 2018
Thank you for the quick response. I do not have a Qt account so I cannot
file the bug. I think I have included everything that you would need to
reproduce the problem below. Note that the default for my version of GCC is
C++98.
Qt Creator: 4.7.0 built on Jul 17 2018 04:23:40 from revision dedbb40f57.
OS: CentOS Linux release 7.5.1804 (Core)
GCC: 4.8.5 20150623 (Red Hat 4.8.5-28)
Steps to reproduce:
1. Open the project
2. Click 'Analyze' -> 'Clang-Tidy and Clazy...'
3. Select 'Clang-Tidy and Clazy preselected checks [built-in]' for the
'Diagnostic Configuration'
4. Click 'Analyze' button
Expected result:
The analysis succeeds, possibly with some warnings/suggestions for code
improvement.
Actual result:
Failed to analyze "<path-to>/test_proj.cpp": Clang-Tidy and Clazy finished
with exit code: 1.
Source and project file contents follow.
---------- test_proj.cpp ----------
#include <functional> #include <iostream> typedef std::function<void()>
Callback; class Test { public: void setCallback(Callback callback) {
mCallback = callback; } void doCallback() { mCallback(); } private:
Callback mCallback; }; int main(int argc, char **argv) { Test t;
t.setCallback([]() { std::cout << "Callback" << std::endl; });
t.doCallback(); }
---------- End test_proj.cpp ----------
---------- makefile ----------
all : test_proj test_proj : test_proj.cpp g++ -std=c++11 -o $@ $^ clean :
rm test_proj
---------- End makefile ----------
---------- TestProj.config ----------
// Need the following uncommented for editor warning/error highlighting to
work with C++11
//#define __cplusplus 201103L
---------- End TestProj.config ----------
---------- TestProj.creator ----------
[General]
---------- End TestProj.creator ----------
---------- TestProj.files ----------
makefile
test_proj.cpp
---------- End TestProj.files ----------
---------- TestProj.includes ----------
.
---------- End TestProj.includes ----------
On Thu, Aug 9, 2018 at 8:42 AM Ivan Donchevskii <ivan.donchevskii at qt.io>
wrote:
> Hi!
>
>
> We use defines we get from the compiler which is set in your current Kit.
> It might be possible that we have some bug in the process of getting them.
>
> Please create a bugreport (bugreports.qt.io) with a small code example so
> we can reproduce the issue and fix it.
>
>
> Kind regards,
>
> Ivan
> ------------------------------
> *From:* Qt-creator <qt-creator-bounces+ivan.donchevskii=
> qt.io at qt-project.org> on behalf of Tyson Wiser <twiser.public at gmail.com>
> *Sent:* Thursday, August 9, 2018 2:35:47 PM
> *To:* qt-creator at qt-project.org
> *Subject:* [Qt-creator] Clang-Tidy and Clazy analyzer using
> '-D__cplusplus=199711L'
>
> First of all, thank you for creating and maintaining this great IDE. It
> has been a great tool.
>
> More details follow, but in a nutshell, I'm having trouble using the
> 'Clang-Tidy and Clazy...' analyzers in Qt Creator 4.7 on CentOS 7. It
> appears that it is incorrectly defining __cplusplus, which causes multiple
> errors. Is there a way to find out why that is and how to change it? It is
> also trying to use the C++17 standard. Is there a way to change that to
> C++11?
>
> I run Qt Creator on a CentOS 7 Linux box. My projects are makefile-based
> (no CMake, QMake, or QBS), but I have the appropriate paths in my
> <project>.includes file so that the code completion, etc. all work as
> expected. I recently upgraded from 4.6.1 to 4.7. In 4.6.1 I did not use the
> clang-tidy checks as I found them to be too slow. I'm trying them again in
> 4.7 and they seem to be faster. However, they do not seem to check every
> file. In looking at the command line used to launch the tools (from the
> Issues window), I notice the following.
>
> 1. The '-std=c++17' option is included.
> 2. Later on, there is a '-D__cplusplus=199711L' included as well.
>
> I believe that the combination of the two points above (especially #2) are
> causing the tools to fail early.
>
> So here are my questions. First, how do I find out why __cplusplus is
> being defined to an old standard and how do I change it? Second, is it
> possible to change it so that the tools use '-std=c++11" instead of
> '-std=c++17'?
>
> In case it is helpful, the command line the IDE used is included below
> (I've replaced some irrelevant sections with <description>). Thanks in
> advance for any help you may be able to provide.
>
> -Tyson
>
> :-1: warning: Command line:
> /home/twiser/programs/qtcreator-4.7.0/libexec/qtcreator/clang/bin/clang-6.0
> -fsyntax-only -serialize-diagnostics
> /tmp/QtCreator-UPSeGv/clangtools-dTWDOt/report-NavConnectionSerial.cpp-BFnMCN
> -Wno-unknown-pragmas -Wno-unknown-warning-option
> -Wno-documentation-unknown-command -Xclang -add-plugin -Xclang clang-tidy
> -Xclang -plugin-arg-clang-tidy -Xclang
> '-checks=-*,bugprone-*,cppcoreguidelines-c-copy-assignment-signature,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-no-malloc,cppcoreguidelines-pro-bounds-constant-array-index,cppcoreguidelines-pro-bounds-pointer-arithmetic,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-pro-type-union-access,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions,misc-*,modernize-*,performance-*,readability-avoid-const-params-in-decls,readability-container-size-empty,readability-delete-null-pointer,readability-deleted-default,readability-else-after-return,readability-function-size,readability-identifier-naming,readability-inconsistent-declaration-parameter-name,readability-misleading-indentation,readability-misplaced-array-index,readability-non-const-parameter,readability-redundant-*,readability-simplify-boolean-expr,readability-static-*,readability-uniqueptr-delete-release'
> -Xclang -add-plugin -Xclang clang-lazy -Xclang -plugin-arg-clang-lazy
> -Xclang enable-all-fixits -Xclang -plugin-arg-clang-lazy -Xclang
> no-autowrite-fixits -Xclang -plugin-arg-clang-lazy -Xclang level0 -m64
> -target x86_64-redhat-linux -x c++ -std=c++17 -fcxx-exceptions -fexceptions
> '-D__DBL_MIN_EXP__=(-1021)' -D__UINT_LEAST16_MAX__=65535
> -D__ATOMIC_ACQUIRE=2 -D__FLT_MIN__=1.17549435082228750797e-38F
> '-D__UINT_LEAST8_TYPE__=unsigned char' '-D__INTMAX_C(c)=c ##L'
> -D__CHAR_BIT__=8 -D__UINT8_MAX__=255 -D__WINT_MAX__=4294967295U
> -D__ORDER_LITTLE_ENDIAN__=1234 -D__SIZE_MAX__=18446744073709551615UL
> -D__WCHAR_MAX__=2147483647 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
> -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
> '-D__DBL_DENORM_MIN__=double(4.94065645841246544177e-324L)'
> -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 -D__GCC_ATOMIC_CHAR_LOCK_FREE=2
> -D__FLT_EVAL_METHOD__=0 -D__unix__ -D__GCC_ATOMIC_CHAR32_T_LOCK_FREE=2
> -D__x86_64 -D__UINT_FAST64_MAX__=18446744073709551615UL
> -D__SIG_ATOMIC_TYPE__=int '-D__DBL_MIN_10_EXP__=(-307)'
> -D__FINITE_MATH_ONLY__=0 -D__GNUC_PATCHLEVEL__=5 -D__UINT_FAST8_MAX__=255
> -D__DEC64_MAX_EXP__=385 '-D__INT8_C(c)=c'
> -D__UINT_LEAST64_MAX__=18446744073709551615UL -D__SHRT_MAX__=32767
> -D__LDBL_MAX__=1.18973149535723176502e+4932L -D__UINT_LEAST8_MAX__=255
> -D__GCC_ATOMIC_BOOL_LOCK_FREE=2 '-D__UINTMAX_TYPE__=long unsigned int'
> -D__linux -D__DEC32_EPSILON__=1E-6DF -D__unix -D__UINT32_MAX__=4294967295U
> -D__LDBL_MAX_EXP__=16384 -D__WINT_MIN__=0U -D__linux__ -D__SCHAR_MAX__=127
> '-D__WCHAR_MIN__=(-__WCHAR_MAX__ - 1)' '-D__INT64_C(c)=c ##L'
> -D__DBL_DIG__=15 -D__GCC_ATOMIC_POINTER_LOCK_FREE=2 -D__SIZEOF_INT__=4
> -D__SIZEOF_POINTER__=8 -D__GCC_ATOMIC_CHAR16_T_LOCK_FREE=2
> -D__USER_LABEL_PREFIX__= -D__STDC_HOSTED__ -D__LDBL_HAS_INFINITY__
> -D__FLT_EPSILON__=1.19209289550781250000e-7F -D__GXX_WEAK__
> -D__LDBL_MIN__=3.36210314311209350626e-4932L -D__DEC32_MAX__=9.999999E96DF
> -D__INT32_MAX__=2147483647 -D__SIZEOF_LONG__=8 -D__STDC_IEC_559__
> -D__STDC_ISO_10646__=201103L '-D__UINT16_C(c)=c' -D__DECIMAL_DIG__=21
> -D__gnu_linux__ -D__LDBL_HAS_QUIET_NAN__ -D__GNUC__=4 -D__GXX_RTTI
> -D__MMX__ -D__FLT_HAS_DENORM__ -D__SIZEOF_LONG_DOUBLE__=16
> -D__BIGGEST_ALIGNMENT__=16
> '-D__DBL_MAX__=double(1.79769313486231570815e+308L)'
> -D__INT_FAST32_MAX__=9223372036854775807L -D__DBL_HAS_INFINITY__
> -D__INT64_MAX__=9223372036854775807L '-D__DEC32_MIN_EXP__=(-94)'
> '-D__INT_FAST16_TYPE__=long int' -D__LDBL_HAS_DENORM__
> -D__cplusplus=199711L
> -D__DEC128_MAX__=9.999999999999999999999999999999999E6144DL
> -D__INT_LEAST32_MAX__=2147483647 -D__DEC32_MIN__=1E-95DF -D__DEPRECATED
> -D__DBL_MAX_EXP__=1024 -D__DEC128_EPSILON__=1E-33DL -D__SSE2_MATH__
> -D__ATOMIC_HLE_RELEASE=131072 -D__PTRDIFF_MAX__=9223372036854775807L
> -D__amd64 -D__STDC_NO_THREADS__ -D__ATOMIC_HLE_ACQUIRE=65536 -D__GNUG__=4
> -D__LONG_LONG_MAX__=9223372036854775807LL -D__SIZEOF_SIZE_T__=8
> -D__SIZEOF_WINT_T__=4 -D__GCC_HAVE_DWARF2_CFI_ASM -D__GXX_ABI_VERSION=1002
> '-D__FLT_MIN_EXP__=(-125)' '-D__INT_FAST64_TYPE__=long int'
> '-D__DBL_MIN__=double(2.22507385850720138309e-308L)' -D__LP64__
> -D__DECIMAL_BID_FORMAT__ -D__DEC128_MIN__=1E-6143DL -D__REGISTER_PREFIX__=
> -D__UINT16_MAX__=65535 -D__DBL_HAS_DENORM__ '-D__UINT8_TYPE__=unsigned
> char' -D__NO_INLINE__ -D__FLT_MANT_DIG__=24 '-D__VERSION__="4.8.5 20150623
> (Red Hat 4.8.5-28)"' '-D__UINT64_C(c)=c ##UL' -D_STDC_PREDEF_H
> -D__GCC_ATOMIC_INT_LOCK_FREE=2
> -D__FLOAT_WORD_ORDER__=__ORDER_LITTLE_ENDIAN__ -D__STDC_IEC_559_COMPLEX__
> '-D__INT32_C(c)=c' -D__DEC64_EPSILON__=1E-15DD -D__ORDER_PDP_ENDIAN__=3412
> '-D__DEC128_MIN_EXP__=(-6142)' '-D__INT_FAST32_TYPE__=long int'
> '-D__UINT_LEAST16_TYPE__=short unsigned int' -Dunix -D__INT16_MAX__=32767
> '-D__SIZE_TYPE__=long unsigned int' -D__UINT64_MAX__=18446744073709551615UL
> '-D__INT8_TYPE__=signed char' -D__ELF__ -D__FLT_RADIX__=2
> '-D__INT_LEAST16_TYPE__=short int'
> -D__LDBL_EPSILON__=1.08420217248550443401e-19L '-D__UINTMAX_C(c)=c ##UL'
> -D__GNUC_RH_RELEASE__=28 -D__k8 -D__SIG_ATOMIC_MAX__=2147483647
> -D__GCC_ATOMIC_WCHAR_T_LOCK_FREE=2 -D__SIZEOF_PTRDIFF_T__=8 -D__x86_64__
> -D__DEC32_SUBNORMAL_MIN__=0.000001E-95DF
> -D__INT_FAST16_MAX__=9223372036854775807L
> -D__UINT_FAST32_MAX__=18446744073709551615UL '-D__UINT_LEAST64_TYPE__=long
> unsigned int' -D__FLT_HAS_QUIET_NAN__ -D__FLT_MAX_10_EXP__=38
> -D__LONG_MAX__=9223372036854775807L
> -D__DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL
> -D__FLT_HAS_INFINITY__ '-D__UINT_FAST16_TYPE__=long unsigned int'
> -D__DEC64_MAX__=9.999999999999999E384DD '-D__CHAR16_TYPE__=short unsigned
> int' -D__PRAGMA_REDEFINE_EXTNAME -D__INT_LEAST16_MAX__=32767
> -D__DEC64_MANT_DIG__=16 -D__UINT_LEAST32_MAX__=4294967295U
> -D__GCC_ATOMIC_LONG_LOCK_FREE=2 '-D__INT_LEAST64_TYPE__=long int'
> '-D__INT16_TYPE__=short int' '-D__INT_LEAST8_TYPE__=signed char'
> -D__DEC32_MAX_EXP__=97 -D__INT_FAST8_MAX__=127
> -D__INTPTR_MAX__=9223372036854775807L -Dlinux -D__SSE2__ -D__EXCEPTIONS
> -D__LDBL_MANT_DIG__=64 -D__DBL_HAS_QUIET_NAN__
> '-D__SIG_ATOMIC_MIN__=(-__SIG_ATOMIC_MAX__ - 1)' -D__code_model_small__
> -D__k8__ '-D__INTPTR_TYPE__=long int' '-D__UINT16_TYPE__=short unsigned
> int' -D__WCHAR_TYPE__=int -D__SIZEOF_FLOAT__=4
> -D__UINTPTR_MAX__=18446744073709551615UL '-D__DEC64_MIN_EXP__=(-382)'
> -D__INT_FAST64_MAX__=9223372036854775807L
> -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL -D__FLT_DIG__=6
> '-D__UINT_FAST64_TYPE__=long unsigned int' -D__INT_MAX__=2147483647
> -D__amd64__ '-D__INT64_TYPE__=long int' -D__FLT_MAX_EXP__=128
> -D__ORDER_BIG_ENDIAN__=4321 -D__DBL_MANT_DIG__=53
> -D__INT_LEAST64_MAX__=9223372036854775807L -D__DEC64_MIN__=1E-383DD
> '-D__WINT_TYPE__=unsigned int' '-D__UINT_LEAST32_TYPE__=unsigned int'
> -D__SIZEOF_SHORT__=2 -D__SSE__ '-D__LDBL_MIN_EXP__=(-16381)'
> -D__INT_LEAST8_MAX__=127 -D__SIZEOF_INT128__=16 -D__LDBL_MAX_10_EXP__=4932
> -D__ATOMIC_RELAXED=0
> '-D__DBL_EPSILON__=double(2.22044604925031308085e-16L)' -D_LP64
> '-D__UINT8_C(c)=c' -D__INT_LEAST32_TYPE__=int -D__SIZEOF_WCHAR_T__=4
> '-D__UINT64_TYPE__=long unsigned int' '-D__INT_FAST8_TYPE__=signed char'
> -D__DBL_DECIMAL_DIG__=17 -D__FXSR__ -D__DEC_EVAL_METHOD__=2
> '-D__UINT32_C(c)=c ##U' -D__INTMAX_MAX__=9223372036854775807L
> -D__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__
> -D__FLT_DENORM_MIN__=1.40129846432481707092e-45F -D__INT8_MAX__=127
> '-D__UINT_FAST32_TYPE__=long unsigned int' '-D__CHAR32_TYPE__=unsigned int'
> -D__FLT_MAX__=3.40282346638528859812e+38F -D__INT32_TYPE__=int
> -D__SIZEOF_DOUBLE__=8 '-D__INTMAX_TYPE__=long int'
> -D__DEC128_MAX_EXP__=6145 -D__ATOMIC_CONSUME -D__GNUC_MINOR__=8
> -D__UINTMAX_MAX__=18446744073709551615UL -D__DEC32_MANT_DIG__=7
> -D__DBL_MAX_10_EXP__=308
> -D__LDBL_DENORM_MIN__=3.64519953188247460253e-4951L '-D__INT16_C(c)=c'
> -D__STDC__ '-D__PTRDIFF_TYPE__=long int' -D__ATOMIC_SEQ_CST=5
> '-D__UINT32_TYPE__=unsigned int' '-D__UINTPTR_TYPE__=long unsigned int'
> -D__DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD -D__DEC128_MANT_DIG__=34
> '-D__LDBL_MIN_10_EXP__=(-4931)' -D__SSE_MATH__ -D__SIZEOF_LONG_LONG__=8
> -D__GCC_ATOMIC_LLONG_LOCK_FREE=2 -D__LDBL_DIG__=18 -D__FLT_DECIMAL_DIG__=9
> -D__UINT_FAST16_MAX__=18446744073709551615UL -D__GNUC_GNU_INLINE__
> '-D__FLT_MIN_10_EXP__=(-37)' -D__GCC_ATOMIC_SHORT_LOCK_FREE=2
> '-D__UINT_FAST8_TYPE__=unsigned char' -D_GNU_SOURCE -D__ATOMIC_ACQ_REL=4
> -D__ATOMIC_RELEASE=3 -nostdinc -nostdlibinc -undef -isystem
> /home/twiser/programs/qtcreator-4.7.0/libexec/qtcreator/clang/lib/clang/6.0.1/include
> <list-of-project-include-paths> -I /usr/include/c++/4.8.2 -I
> /usr/include/c++/4.8.2/x86_64-redhat-linux -I
> /usr/include/c++/4.8.2/backward -I
> /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include -I /usr/local/include -I
> /usr/include -include <project>.config <source-file>.cpp
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20180809/1b332ed1/attachment.html>
More information about the Qt-creator
mailing list