Skip to content

Commit

Permalink
Removing on-the-fly CTU functionality as it is not supported by clang
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrupp committed May 8, 2018
1 parent 0add91f commit 1c38743
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 89 deletions.
5 changes: 0 additions & 5 deletions libcodechecker/analyze/analyzers/analyzer_clangsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ def construct_analyzer_cmd(self, result_handler):
if config.ctu_has_analyzer_display_ctu_progress:
analyzer_cmd.extend(['-Xclang',
'-analyzer-display-ctu-progress'])
if config.ctu_in_memory:
analyzer_cmd.extend(['-Xclang', '-analyzer-config',
'-Xclang',
'xtu-reparse=' +
os.path.abspath(config.log_file[0])])

# Set language.
analyzer_cmd.extend(['-x', self.buildaction.lang])
Expand Down
1 change: 0 additions & 1 deletion libcodechecker/analyze/analyzers/analyzer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def __build_clangsa_config_handler(args, context):
if 'ctu_phases' in args:
config_handler.ctu_dir = os.path.join(args.output_path,
args.ctu_dir)
config_handler.ctu_in_memory = 'ctu_in_memory' in args

config_handler.ctu_has_analyzer_display_ctu_progress = \
host_check.has_analyzer_feature(
Expand Down
9 changes: 0 additions & 9 deletions libcodechecker/analyze/analyzers/config_handler_clangsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def __init__(self):
super(ClangSAConfigHandler, self).__init__()
self.__checker_configs = []
self.__ctu_dir = ''
self.__ctu_in_memory = False
self.__log_file = ''
self.__path_env_extra = ''
self.__ld_lib_path_extra = ''
Expand Down Expand Up @@ -70,14 +69,6 @@ def ctu_dir(self):
def ctu_dir(self, value):
self.__ctu_dir = value

@property
def ctu_in_memory(self):
return self.__ctu_in_memory

@ctu_in_memory.setter
def ctu_in_memory(self, value):
self.__ctu_in_memory = value

@property
def log_file(self):
return self.__log_file
Expand Down
18 changes: 7 additions & 11 deletions libcodechecker/analyze/ctu_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def generate_ast(triple_arch, action, source, config, env):
cmdstr, err)


def func_map_list_src_to_ast(func_src_list, ctu_in_memory):
def func_map_list_src_to_ast(func_src_list):
""" Turns textual function map list with source files into a
function map list with ast files. """

Expand All @@ -124,14 +124,11 @@ def func_map_list_src_to_ast(func_src_list, ctu_in_memory):
dpos = fn_src_txt.find(" ")
mangled_name = fn_src_txt[0:dpos]
path = fn_src_txt[dpos + 1:]
if ctu_in_memory:
ast_path = path
else:
# Normalize path on windows as well
path = os.path.splitdrive(path)[1]
# Make relative path out of absolute
path = path[1:] if path[0] == os.sep else path
ast_path = os.path.join("ast", path + ".ast")
# Normalize path on windows as well
path = os.path.splitdrive(path)[1]
# Make relative path out of absolute
path = path[1:] if path[0] == os.sep else path
ast_path = os.path.join("ast", path + ".ast")
func_ast_list.append(mangled_name + " " + ast_path)
return func_ast_list

Expand All @@ -157,8 +154,7 @@ def map_functions(triple_arch, action, source, config, env,
return

func_src_list = stdout.splitlines()
func_ast_list = func_map_list_src_to_ast(func_src_list,
config.ctu_in_memory)
func_ast_list = func_map_list_src_to_ast(func_src_list)
extern_fns_map_folder = os.path.join(config.ctu_dir, triple_arch,
temp_fnmap_folder)
if not os.path.isdir(extern_fns_map_folder):
Expand Down
5 changes: 2 additions & 3 deletions libcodechecker/analyze/pre_analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ def pre_analyze(params):
ctu_triple_arch.get_triple_arch(action, source,
config,
analyzer_environment)
if not config.ctu_in_memory:
ctu_manager.generate_ast(triple_arch, action, source,
config, analyzer_environment)
ctu_manager.generate_ast(triple_arch, action, source,
config, analyzer_environment)
ctu_manager.map_functions(triple_arch, action, source, config,
analyzer_environment,
context.ctu_func_map_cmd,
Expand Down
10 changes: 0 additions & 10 deletions libcodechecker/libhandlers/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,6 @@ def add_arguments_to_parser(parser):
"'<OUTPUT_DIR>/ctu-dir'. (These files "
"will not be cleaned up in this mode.)")

ctu_opts.add_argument('--ctu-on-the-fly',
action='store_true',
dest='ctu_in_memory',
default=argparse.SUPPRESS,
help="If specified, the 'collect' phase will "
"not create the extra AST dumps, but "
"rather analysis will be run with an "
"in-memory recompilation of the source "
"files.")

ctu_opts.add_argument('--ctu-reanalyze-on-failure',
action='store_true',
dest='ctu_reanalyze_on_failure',
Expand Down
11 changes: 0 additions & 11 deletions libcodechecker/libhandlers/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ def add_arguments_to_parser(parser):
"'<OUTPUT_DIR>/ctu-dir'. (These files "
"will not be cleaned up in this mode.)")

ctu_opts.add_argument('--ctu-on-the-fly',
action='store_true',
dest='ctu_in_memory',
default=argparse.SUPPRESS,
help="If specified, the 'collect' phase will "
"not create the extra AST dumps, but "
"rather analysis will be run with an "
"in-memory recompilation of the source "
"files.")

checkers_opts = parser.add_argument_group(
"checker configuration",
"See 'codechecker-checkers' for the list of available checkers. "
Expand Down Expand Up @@ -453,7 +443,6 @@ def __update_if_key_exists(source, target, key):
'tidy_args_cfg_file',
'capture_analysis_output',
'ctu_phases',
'ctu_in_memory',
'enable_all',
'ordered_checkers', # --enable and --disable.
'timeout'
Expand Down
54 changes: 15 additions & 39 deletions tests/functional/ctu/test_ctu.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,98 +66,74 @@ def tearDown(self):
def test_ctu_all_no_reparse(self):
""" Test full CTU without reparse. """

self.__test_ctu_all(False)
self.__test_ctu_all()

def test_ctu_collect_no_reparse(self):
""" Test CTU collect phase without reparse. """

self.__test_ctu_collect(False)
self.__test_ctu_collect()

def test_ctu_analyze_no_reparse(self):
""" Test CTU analyze phase without reparse. """

self.__test_ctu_analyze(False)
self.__test_ctu_analyze()

def test_ctu_all_reparse(self):
""" Test full CTU with reparse. """

self.__test_ctu_all(True)

def test_ctu_collect_reparse(self):
""" Test CTU collect phase with reparse. """

self.__test_ctu_collect(True)

def test_ctu_analyze_reparse(self):
""" Test CTU analyze phase with reparse. """

self.__test_ctu_analyze(True)

def __test_ctu_all(self, reparse):
def __test_ctu_all(self):
""" Test full CTU. """

if not self.ctu_capable:
self.skipTest(NO_CTU_MESSAGE)
output = self.__do_ctu_all(reparse)
output = self.__do_ctu_all()
self.__check_ctu_analyze(output)

def __test_ctu_collect(self, reparse):
def __test_ctu_collect(self):
""" Test CTU collect phase. """

if not self.ctu_capable:
self.skipTest(NO_CTU_MESSAGE)
self.__do_ctu_collect(reparse)
self.__check_ctu_collect(reparse)
self.__do_ctu_collect()
self.__check_ctu_collect()

def __test_ctu_analyze(self, reparse):
def __test_ctu_analyze(self):
""" Test CTU analyze phase. """

if not self.ctu_capable:
self.skipTest(NO_CTU_MESSAGE)
self.__do_ctu_collect(reparse)
output = self.__do_ctu_analyze(reparse)
self.__do_ctu_collect()
output = self.__do_ctu_analyze()
self.__check_ctu_analyze(output)

def __do_ctu_all(self, reparse):
def __do_ctu_all(self):
""" Execute a full CTU run. """

cmd = [self._codechecker_cmd, 'analyze', '-o', self.report_dir,
'--analyzers', 'clangsa', '--ctu-all']
if reparse:
cmd.append('--ctu-on-the-fly')
cmd.append(self.buildlog)
out, _ = call_command(cmd, cwd=self.test_dir, env=self.env)
return out

def __do_ctu_collect(self, reparse):
def __do_ctu_collect(self):
""" Execute CTU collect phase. """

cmd = [self._codechecker_cmd, 'analyze', '-o', self.report_dir,
'--analyzers', 'clangsa', '--ctu-collect']
if reparse:
cmd.append('--ctu-on-the-fly')
cmd.append(self.buildlog)
call_command(cmd, cwd=self.test_dir, env=self.env)

def __check_ctu_collect(self, reparse):
def __check_ctu_collect(self):
""" Check artifacts of CTU collect phase. """

ctu_dir = os.path.join(self.report_dir, 'ctu-dir')
self.assertTrue(os.path.isdir(ctu_dir))
for arch in glob.glob(os.path.join(ctu_dir, '*')):
fn_map_file = os.path.join(ctu_dir, arch, 'externalFnMap.txt')
self.assertTrue(os.path.isfile(fn_map_file))
if not reparse:
ast_dir = os.path.join(ctu_dir, arch, 'ast')
self.assertTrue(os.path.isdir(ast_dir))

def __do_ctu_analyze(self, reparse):
def __do_ctu_analyze(self):
""" Execute CTU analyze phase. """

cmd = [self._codechecker_cmd, 'analyze', '-o', self.report_dir,
'--analyzers', 'clangsa', '--ctu-analyze']
if reparse:
cmd.append('--ctu-on-the-fly')
cmd.append(self.buildlog)
out, _ = call_command(cmd, cwd=self.test_dir, env=self.env)
return out
Expand Down

0 comments on commit 1c38743

Please sign in to comment.