Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
7c18edaa
Commit
7c18edaa
authored
10 years ago
by
Joshua Colp
Committed by
Gerrit Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Example script for scan-build (the llvm static analyzer)"
parents
5e965848
1e747930
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/scripts/clang-scan-build
+136
-0
136 additions, 0 deletions
contrib/scripts/clang-scan-build
with
136 additions
and
0 deletions
contrib/scripts/clang-scan-build
0 → 100755
+
136
−
0
View file @
7c18edaa
#!/bin/bash
#
# clang-scan-build: configure and compile asterisk using the llvm static analyzer
# Options/Flags:
# -c|--compiler : either [clang|gcc]
# --cflags : cflags you would like to add to the default set
# --configure : configure flags you would like to use instead off the default set
# --make : make flags you would like to use instead off the default set
# --scanbuild : scanbuild flags you would like to use instead of the default set
# --outputdir : directory where scan-build should create the html files
# -h|--help : this help
# Usage:
# contrib/scripts/clang-scan-build
# This script will use clang if available and no compiler has been specified
#
# Example usage:
#
# contrib/scripts/clang-scan-build
# contrib/scripts/clang-scan-build -c gcc
# contrib/scripts/clang-scan-build --compiler clang --configure "--enable-dev-mode" --outputdir="/tmp/scan-build_output"
# contrib/scripts/clang-scan-build --make "-j2"
#
# scan-build will generate html files during the make process, which will be stored in the specified outputdir or ./scan-build_output" by default
# Copyright (C) 2015 Diederik de Groot <dddegroot@users.sf.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
COMPILER
=
clang
SCANBUILD
=
"
`
which scan-build
`
"
CFLAGS
=
""
CONFIGURE_FLAGS
=
"--enable-coverage --disable-xmldoc"
MAKE_FLAGS
=
""
SCANBUILD_FLAGS
=
"-maxloop 10 -disable-checker deadcode.DeadStores -enable-checker alpha.core.BoolAssignment -enable-checker alpha.core.CallAndMessageUnInitRefArg -enable-checker alpha.core.CastSize -enable-checker alpha.core.CastToStruct -enable-checker alpha.core.IdenticalExpr -enable-checker alpha.core.PointerArithm -enable-checker alpha.core.PointerSub -enable-checker alpha.core.SizeofPtr -enable-checker alpha.core.TestAfterDivZero -enable-checker alpha.security.ArrayBound -enable-checker alpha.security.ArrayBoundV2 -enable-checker alpha.security.MallocOverflow -enable-checker alpha.security.ReturnPtrRange -enable-checker alpha.security.taint.TaintPropagation -enable-checker alpha.unix.MallocWithAnnotations -enable-checker alpha.unix.PthreadLock -enable-checker alpha.unix.SimpleStream -enable-checker alpha.unix.Stream -enable-checker alpha.unix.cstring.BufferOverlap -enable-checker alpha.unix.cstring.NotNullTerminated -enable-checker alpha.unix.cstring.OutOfBounds"
OUTPUTDIR
=
"scan-build_output"
function
print_usage
{
cat
<<
EOF
$0
Usage:
Options/Flags:
-c|--compiler : either [clang|gcc]
--cflags : cflags you would like to add to the default set:
"
${
CFLAGS
}
"
--configure : configure flags you would like to use instead off the default set:
"
${
CONFIGURE_FLAGS
}
"
--make : make flags you would like to use instead off the default set:
"
${
MAKE_FLAGS
}
"
--scanbuild : scanbuild flags you would like to use instead of the default set:
"
${
SCANBUILD_FLAGS
}
"
--outputdir : directory where scan-build should create the html files. default:
"`pwd`/
${
OUTPUTDIR
}
"
-h|--help : this help
EOF
}
for
i
in
"
$@
"
do
case
$i
in
-c
=
*
|
--compiler
=
*
)
COMPILER
=
"
${
i
#*=
}
"
shift
;;
--cflags
=
*
)
CFLAGS
=
"
${
i
#*=
}
"
shift
;;
--configure
=
*
)
CONFIGURE_FLAGS
=
"
${
i
#*=
}
"
shift
;;
--make
=
*
)
MAKE_FLAGS
=
"
${
i
#*=
}
"
shift
;;
--scanbuild
=
*
)
SCANBUILD_FLAGS
=
"
${
i
#*=
}
"
shift
;;
--outputdir
=
*
)
OUTPUTDIR
=
"
${
i
#*=
}
"
shift
;;
-h
|
--help
)
print_usage
exit
;;
esac
done
if
[
"
${
COMPILER
}
"
==
"clang"
]
&&
[
!
-z
"
`
which clang
`
"
]
;
then
CCC_CC
=
"
`
which
`
clang"
CCC_CXX
=
"
`
which clang++
`
"
CFLAGS
=
"-fblocks
${
CFLAGS
}
"
elif
[
"
${
COMPILER
}
"
==
"gcc"
]
&&
[
!
-z
"
`
which gcc
`
"
]
;
then
CCC_CC
=
"
`
which gcc
`
"
CCC_CXX
=
"
`
which g++
`
"
CFLAGS
=
"
${
CFLAGS
}
"
else
echo
"Unknown compiler:
$2
, needs to be either clang or gcc"
exit
fi
if
[
!
-f
config.status
]
;
then
echo
"Running ./configure
${
CONFIGURE_FLAGS
}
..."
${
SCANBUILD
}
${
SCANBUILD_FLAGS
}
-o
${
OUTPUTDIR
}
./configure
${
CONFIGURE_FLAGS
}
if
[
$?
!=
0
]
;
then
echo
"Configure error occurred, see output / config.log"
exit
fi
make clean
fi
if
[
-f
config.status
]
;
then
echo
"Running scan-build make
${
MAKE_FLAGS
}
..."
${
SCANBUILD
}
${
SCANBUILD_FLAGS
}
-o
${
OUTPUTDIR
}
make
${
MAKE_FLAGS
}
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment