[cfe-dev] Need clarification on clang static analyzer

Aashish goel via cfe-dev cfe-dev at lists.llvm.org
Tue May 21 05:49:14 PDT 2019


Hi 

I am trying to run clang static analyzer(scan-build-py) on my project. In that I have successfully generated the compilation database. But in the analysis phase, I just want to know does scan-build run the clang static analyzer  against the .C file or against an AST. If it runs against AST then why it needs the compiler flags that it generated while building the project. My main problem is that clang static analyzer is failing to analyze this file because those flags are not supported by clang. I don’t understand why the analyzer needs those flags for the analysis. It just needs the AST to analyze the file and AST is generated in the build step with the appropriate compiler.
For e.g.:-
scan-build: DEBUG: Run analyzer against '['/volume/hab/Linux/Ubuntu-12.04/x86_64/gcc/jnpr/4.2.1/mips64-juniper-junos.11/bin/mips64-juniper-junos-gcc', '-c', '-nostdinc', '-Wno-pointer-sign', '-Wno-error=address', '-pg', '-DNEED_GPROF', '-pg', '-O', '-pipe', '-fno-builtin-printf', '-D__ELF__', '-Dunix', '-D__unix', '-D__unix__', '-D__FreeBSD__=6', '-D__mips64__', '-DJUNOS_LEGACY', '-I../../../../../src/pan-release', '-I../../../../../src/pan-release/shared', '-I../../../../../src/pfe-shared/ipc', '-DSC_BIG_ENDIAN', '-DSC_LP64', '-DSC_JSR_XLR64', '-DSC_JSR_XLR', '-DSC_JSR', '-DMIPS', '-O2', '-DXLR_JUNOS', '-DSC_INCLUDE_SSL_DECRYPTION', '-DSC_DFA_COMPRESSED', '-DSC_INCLUDE_FILE_FORMAT', '-fno-builtin-snprintf', '-O2', '-DJCPP_KERNEL', '-DJCPP_JSR', '-DENV_UKERN', '-DSC_JUNOS', '-DSC_KERNEL', '-DSC_BUILD_DEBUG', '-DJCPP_BIG_ENDIAN', '-I../../../../../src/idp/jcpp/pfe/include', '-I../../../../../src/idp/jcpp/pfe/services/http/include', '-I../../../../../src/pfe/include', '-I../../../../../src/pfe/ukern/include', '-I../../../../../src/pfe/usp/mpsafe/include', '-I../../../../../src/pfe/common/toolkits', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/idp/lib/pfe/kabs/common', '-I../../../../../src/idp/lib/pfe/kabs/include', '-I../../../../../src/idp/lib/pfe/ds/common', '-I../../../../../src/idp/idp/pfe/engine/counter/include', '-I/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/include', '-I/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/src', '-Wno-pointer-to-int-cast', '-std=gnu99', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-DTARGET_JUNOS', '-I../../../../../src/bsd/include', '-I../../../../../src/junos/bsd/include', '-I../../../../../src/junos-shared/idl/include', '-I../../../../../obj/xlr64-static/bsd/include', '-I../../../../../obj/xlr64-static/junos/bsd/include', '-I../../../../../obj/xlr64-static/junos/bsd/include/machine_arch/junos', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-G', '0', '-EB', '-march=xlr', '-mabi=64', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-msoft-float', '-mno-flush-func', '-msym32', '-G', '0', '-EB', '-march=xlr', '-mabi=64', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-msoft-float', '-mno-flush-func', '-msym32', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-DSC_BIG_ENDIAN', '-DSC_LP64', '-DSC_JSR_XLR64', '-DSC_JSR_XLR', '-DSC_JSR', '-DMIPS', '-O2', '-DXLR_JUNOS', '-DSC_INCLUDE_SSL_DECRYPTION', '-DSC_DFA_COMPRESSED', '-DSC_INCLUDE_FILE_FORMAT', '-fno-builtin-snprintf', '-I../../../../../src/usp/lib/libjcpp', '-I../../../../../obj/xlr64-static/usp/lib/libjcpp', '-DJUNOS_INTERNAL_BUILD', '-DJUNOS_MAJOR=19', '-DJUNOS_MINOR=3', '-DJUNOS_DEV_BUILD', '-DJUNOS_BUILD', '-W', '-Wall', '-Wchar-subscripts', '-Wcomment', '-Werror', '-Wformat', '-Wimplicit', '-Winline', '-Wmissing-declarations', '-Wmissing-prototypes', '-Wnested-externs', '-Wparentheses', '-Wpointer-arith', '-Wreturn-type', '-Wshadow', '-Wstrict-prototypes', '-Wswitch', '-Wtrigraphs', '-Wuninitialized', '-Wunused', '-Wwrite-strings', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/usr/include', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-D__libuspjcpp__', '-Wno-strict-aliasing', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/usr/include', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-o', 'sc_detector_api_access.p.o', '/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/src/sc_detector_api_access.c’]'
scan-build: DEBUG: analysis, on default arch
scan-build: DEBUG: analysis, language: c
scan-build: DEBUG: exec command ['/volume/hab/Linux/Ubuntu-12.04/x86_64/llvm/5.0/current/bin/clang', '-###', '--analyze', '-Xclang', '-analyzer-output=html', '-x', 'c', '-nostdinc', '-Wno-pointer-sign', '-Wno-error=address', '-pg', '-DNEED_GPROF', '-pg', '-O', '-pipe', '-fno-builtin-printf', '-D__ELF__', '-Dunix', '-D__unix', '-D__unix__', '-D__FreeBSD__=6', '-D__mips64__', '-DJUNOS_LEGACY', '-I../../../../../src/pan-release', '-I../../../../../src/pan-release/shared', '-I../../../../../src/pfe-shared/ipc', '-DSC_BIG_ENDIAN', '-DSC_LP64', '-DSC_JSR_XLR64', '-DSC_JSR_XLR', '-DSC_JSR', '-DMIPS', '-O2', '-DXLR_JUNOS', '-DSC_INCLUDE_SSL_DECRYPTION', '-DSC_DFA_COMPRESSED', '-DSC_INCLUDE_FILE_FORMAT', '-fno-builtin-snprintf', '-O2', '-DJCPP_KERNEL', '-DJCPP_JSR', '-DENV_UKERN', '-DSC_JUNOS', '-DSC_KERNEL', '-DSC_BUILD_DEBUG', '-DJCPP_BIG_ENDIAN', '-I../../../../../src/idp/jcpp/pfe/include', '-I../../../../../src/idp/jcpp/pfe/services/http/include', '-I../../../../../src/pfe/include', '-I../../../../../src/pfe/ukern/include', '-I../../../../../src/pfe/usp/mpsafe/include', '-I../../../../../src/pfe/common/toolkits', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/idp/lib/pfe/kabs/common', '-I../../../../../src/idp/lib/pfe/kabs/include', '-I../../../../../src/idp/lib/pfe/ds/common', '-I../../../../../src/idp/idp/pfe/engine/counter/include', '-I/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/include', '-I/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/src', '-Wno-pointer-to-int-cast', '-std=gnu99', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-DTARGET_JUNOS', '-I../../../../../src/bsd/include', '-I../../../../../src/junos/bsd/include', '-I../../../../../src/junos-shared/idl/include', '-I../../../../../obj/xlr64-static/bsd/include', '-I../../../../../obj/xlr64-static/junos/bsd/include', '-I../../../../../obj/xlr64-static/junos/bsd/include/machine_arch/junos', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-G', '0', '-EB', '-march=xlr', '-mabi=64', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-msoft-float', '-mno-flush-func', '-msym32', '-G', '0', '-EB', '-march=xlr', '-mabi=64', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-msoft-float', '-mno-flush-func', '-msym32', '-ggdb', '-gdwarf-2', '-g2', '-feliminate-unused-debug-types', '-DSC_BIG_ENDIAN', '-DSC_LP64', '-DSC_JSR_XLR64', '-DSC_JSR_XLR', '-DSC_JSR', '-DMIPS', '-O2', '-DXLR_JUNOS', '-DSC_INCLUDE_SSL_DECRYPTION', '-DSC_DFA_COMPRESSED', '-DSC_INCLUDE_FILE_FORMAT', '-fno-builtin-snprintf', '-I../../../../../src/usp/lib/libjcpp', '-I../../../../../obj/xlr64-static/usp/lib/libjcpp', '-DJUNOS_INTERNAL_BUILD', '-DJUNOS_MAJOR=19', '-DJUNOS_MINOR=3', '-DJUNOS_DEV_BUILD', '-DJUNOS_BUILD', '-W', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/usr/include', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-D__libuspjcpp__', '-Wno-strict-aliasing', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/usr/include', '-I/b/aashisha/DCB_new/obj/stage/xlr64-static/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', '-I../../../../../src/pfe-shared/include', '-I../../../../../src/pfe-shared/toolkits', '-I../../../../../src/junos/bsd/sys', '-I../../../../../src/bsd/sys', '-I../../../../../src/junos/include', '-I../../../../../src/junos-shared/include', '-I../../../../../src/junos-shared/platform/bsd', '-I/volume/uidev/pub/ui/dev_common_branch/20190427.rbu-builder.r1023565/stage/gcc-4.2.1/xlr64-static/usr/include', u'/b/aashisha/DCB_new/obj/linux3-x86_64/junos/lib/libidp-detector/junos-idp-detector-20110307/detector-api/version-6/src/sc_detector_api_access.c', '-o', '/b/aashisha/report/scan-build-2019-05-01-12-20-32-036300-7V_KyT'] in /b/aashisha/DCB_new/obj/xlr64-static/usp/lib/libjcpp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190521/f85d56d8/attachment.html>


More information about the cfe-dev mailing list