Commit 0637b1b6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add 'make analyze' to call the clang static analyzer

Also fix some of the things that it reported.

Have to patch the tool to make it work, since it wants
to use the CLANG_CXX environment variable to pass information around,
but the Pyston Makefile uses that variable as well.
parent 96cc5efa
From b1b7a1de4895a5d821592f0221c3ae0b14200ff1 Mon Sep 17 00:00:00 2001
From: Kevin Modzelewski <kevmod@gmail.com>
Date: Tue, 27 May 2014 17:03:25 -0700
Subject: [PATCH] Rename one of scan-builds internal environment variables to not conflict
---
tools/scan-build/ccc-analyzer | 2 +-
tools/scan-build/scan-build | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index b5445e6..65f8455 100755
--- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer
@@ -43,7 +43,7 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) {
$Compiler = $ENV{'CCC_CXX'};
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCXXCompiler; }
- $Clang = $ENV{'CLANG_CXX'};
+ $Clang = $ENV{'CCC_CLANG_CXX'};
if (!defined $Clang || ! -x $Clang) { $Clang = 'clang++'; }
$IsCXX = 1
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 31dbfb4..9a3c9e8 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -884,7 +884,7 @@ sub AddIfNotPresent {
sub SetEnv {
my $Options = shift @_;
- foreach my $opt ('CC', 'CXX', 'CLANG', 'CLANG_CXX',
+ foreach my $opt ('CC', 'CXX', 'CLANG', 'CCC_CLANG_CXX',
'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS',
'CCC_ANALYZER_CONFIG') {
die "$opt is undefined\n" if (!defined $opt);
@@ -1653,7 +1653,7 @@ my %Options = (
'CC' => $Cmd,
'CXX' => $CmdCXX,
'CLANG' => $Clang,
- 'CLANG_CXX' => $ClangCXX,
+ 'CCC_CLANG_CXX' => $ClangCXX,
'VERBOSE' => $Verbose,
'CCC_ANALYZER_ANALYSIS' => $CCC_ANALYZER_ANALYSIS,
'CCC_ANALYZER_PLUGINS' => $CCC_ANALYZER_PLUGINS,
--
1.7.4.1
==============================================================================
LLVM Release License
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
LLVM Team
University of Illinois at Urbana-Champaign
http://llvm.org
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of the LLVM Team, University of Illinois at
Urbana-Champaign, nor the names of its contributors may be used to
endorse or promote products derived from this Software without specific
prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
......@@ -313,6 +313,13 @@ check_format:
$(ECHO) checking formatting...
$(VERB) $(TOOLS_DIR)/check_format.sh $(LLVM_BIN)/clang-format
.PHONY: analyze
analyze:
$(MAKE) clean
PATH=$$PATH:$(DEPS_DIR)/llvm-trunk/tools/clang/tools/scan-view $(DEPS_DIR)/llvm-trunk/tools/clang/tools/scan-build/scan-build \
--use-analyzer $(CLANG_EXE) --use-c++ $(CLANG_EXE) -V \
$(MAKE) pyston_dbg USE_DISTCC=0 USE_CCACHE=0
.PHONY: test test_debug test_prof test_release
test_debug: pyston_dbg ext
python ../tools/tester.py -j$(TEST_THREADS) -k $(TESTS_DIR) $(ARGS)
......
......@@ -385,12 +385,13 @@ CompiledFunction* resolveCLFunc(CLFunction* f, int64_t nargs, Box* arg1, Box* ar
printf("Error: couldn't find suitable function version and no source to recompile!\n");
printf("%ld args:", nargs);
for (int i = 0; i < nargs; i++) {
Box* firstargs[] = { arg1, arg2, arg3 };
printf(" %s", getTypeName(firstargs[i])->c_str());
if (i == 3) {
printf(" [and more]");
break;
}
Box* firstargs[] = { arg1, arg2, arg3 };
printf(" %s", getTypeName(firstargs[i])->c_str());
}
printf("\n");
for (int j = 0; j < f->versions.size(); j++) {
......@@ -450,6 +451,7 @@ Box* callCompiledFunc(CompiledFunction* cf, int64_t nargs, Box* arg1, Box* arg2,
} else {
rargs = args;
}
assert(rargs);
}
int nsig_args = cf->sig->arg_types.size();
......
......@@ -119,6 +119,8 @@ public:
const Value* baseA, *baseB;
baseA = GIa->getPointerOperand();
baseB = GIb->getPointerOperand();
assert(baseA);
assert(baseB);
if (VERBOSITY("opt.aa") >= 2) {
indent();
......@@ -181,6 +183,7 @@ public:
// ASSERT(GI->getNumIndices() > 1, "%d %u", i, GI->getNumIndices());
const Value* gep_base = GI->getPointerOperand();
assert(gep_base);
if (VERBOSITY("opt.aa") >= 2) {
indent();
errs() << "loc " << i << " is gep, recursing\n";
......
......@@ -117,7 +117,6 @@ public:
uint64_t addr, size;
if (name == ".eh_frame") {
assert(!found_eh_frame);
found_eh_frame = true;
if (I->getAddress(eh_frame_addr))
continue;
if (I->getSize(eh_frame_size))
......@@ -125,9 +124,9 @@ public:
if (VERBOSITY())
printf("eh_frame: %lx %lx\n", eh_frame_addr, eh_frame_size);
found_eh_frame = true;
} else if (name == ".text") {
assert(!found_text);
found_text = true;
if (I->getAddress(text_addr))
continue;
if (I->getSize(text_size))
......@@ -135,6 +134,7 @@ public:
if (VERBOSITY())
printf("text: %lx %lx\n", text_addr, text_size);
found_text = true;
}
}
......
......@@ -319,11 +319,15 @@ HiddenClass* HiddenClass::getRoot() {
HCBox::HCBox(const ObjectFlavor* flavor, BoxedClass* cls)
: Box(flavor, cls), hcls(HiddenClass::getRoot()), attr_list(NULL) {
assert(!cls || flavor->isUserDefined() == isUserDefined(cls));
// first part of this check is to handle if we're building "type" itself, since when
// it's constructed its type (which should be "type") is NULL.
assert((cls == NULL && type_cls == NULL) || cls->hasattrs);
// the only way cls should be NULL is if we're creating the type_cls
// object itself:
if (cls == NULL) {
assert(type_cls == NULL);
} else {
assert(flavor->isUserDefined() == isUserDefined(cls));
assert(cls->hasattrs);
}
}
......
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