Commit 167b87b5 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Merge branch 'conv.CheckerGccPlugins-20220703' into 'master'

CheckerGccPlugins: Updates

See merge request !969
parents 962d9245 5fe81909
Pipeline #4184805 passed with stage
in 74 minutes and 36 seconds
......@@ -102,5 +102,6 @@ CheckerGccPlugins_test( callcheck3 )
#CheckerGccPlugins_test( usingns8 )
#CheckerGccPlugins_test( usingns9 )
CheckerGccPlugins_test( thread10 ENVIRONMENT CHECKERGCCPLUGINS_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/share/test_unchecked.config )
CheckerGccPlugins_test( config ENVIRONMENT CHECKERGCCPLUGINS_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/share/test.config )
CheckerGccPlugins_test( check_ts2 ENVIRONMENT CHECKERGCCPLUGINS_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/share/test.config )
......@@ -50,8 +50,11 @@ Configuration file
==================
A configuration file may be used to tune the behavior of the checkers.
The environment variable `CHECKERGCCPLUGINS_CONFIG` should expand to
a colon-separated list of names of configuration files to read.
A colon-separated list of configuration files may be given with
the `-fplugin-arg-libchecker_gccplugins-config=` command-line argument.
After these are read, if the environment variable `CHECKERGCCPLUGINS_CONFIG`
is set, it should expand to a colon-separated list of names of additional
configuration files to read.
It is not an error if no configuration file is given.
Each configuration file consists of keys within square brackets
followed by a set of lines to be associated with that key.
......@@ -479,7 +482,7 @@ Control
-Control/AthenaPython
```
An directory tree may be marked for checking by creating a
A directory tree may be marked for checking by creating a
file at the root of the tree with the name `ATLAS_CHECK_THREAD_SAFETY`
(the contents of this file are ignored).
For a package, this file may also be placed in the include directory.
......@@ -488,6 +491,8 @@ in that case the file will be visible in an installed release.
Paths specified in the configuration file will override any
`ATLAS_CHECK_THREAD_SAFETY` files.
Headers included via `-isystem` are not checked.
An entire file may be marked for checking with the directive
`ATLAS_CHECK_FILE_THREAD_SAFETY`:
......@@ -1022,10 +1027,9 @@ void MyTool::doIt() const {
```
* In the future, there should also be a warning if a function checked
got thread-safety calls an unchecked function. This is presently
disabled until most of the core and data model code passes thread
checking.
* If the `thread.unchecked_calls_warning` configuration parameter
is set to a non-empty string, then the checker will warn if a
function checked for thread-safety calls an unchecked function.
......
......@@ -32,6 +32,7 @@
#include "print-tree.h"
#include "stringpool.h"
#include "attribs.h"
#include "input.h"
#if GCC_VERSION < 12000
......@@ -389,6 +390,11 @@ bool is_thread_safe_dir (const std::string& dir, int height /*= 0*/)
bool check_thread_safety_location_p (location_t loc)
{
// Never check code in headers found via -isystem.
if (in_system_header_at (loc)) {
return false;
}
std::string file = LOCATION_FILE(loc);
thread_safe_files_t::iterator it = thread_safe_files.find (file);
if (it != thread_safe_files.end()) return it->second;
......@@ -413,6 +419,12 @@ bool check_thread_safety_p (tree decl)
if (strstr (main_input_filename, "ReflexDict.cxx") != 0) {
checkedMain = SKIP;
}
else if (strstr (main_input_filename, "CintDict.cxx") != 0) {
checkedMain = SKIP;
}
else if (strstr (main_input_filename, "Dict_gen.cxx") != 0) {
checkedMain = SKIP;
}
else {
checkedMain = OK;
}
......
......@@ -10,6 +10,9 @@
#include <string>
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stdlib.h>
#include "checker_gccplugins.h"
#include "plugin-version.h"
......@@ -93,14 +96,8 @@ bool handle_checker_arg (const std::string& arg)
}
/** Collect command-line arguments from `plugin_init(..)`
*
* If more options are needed, do a couple of things:-
* 1. Add the option to `allowed_args`, making sure to increase
* its size by one.
* 2. Add a new `else if` clause, to deal with the option.
*
* Not very elegant cf. GCC, but does the job.
/**
* Collect command-line arguments from `plugin_init(..)`
*/
static
int
......@@ -117,6 +114,15 @@ collect_plugin_args (plugin_name_args *plugin_info)
if (key == "version")
print_plugin_version (plugin_info);
else if (key == "config" && arg.value) {
char* ptr = nullptr;
char* str = arg.value;
while (char* val = strtok_r (str, ":", &ptr)) {
str = 0;
CheckerGccPlugins::config.read (val);
}
}
else if (key == "checkers" && arg.value) {
char* ptr;
char* str = arg.value;
......@@ -141,6 +147,8 @@ collect_plugin_args (plugin_name_args *plugin_info)
std::cerr << "\n";
std::cerr << "Allowed arguments:\n";
std::cerr << "\t-fplugin-arg-" << plugin_info->base_name << "-version\n";
std::cerr << "\t-fplugin-arg-" << plugin_info->base_name << "-config=CONFIG\n";
std::cerr << "\t CONFIGS is a colon-separated list configuration files.\n";
std::cerr << "\t-fplugin-arg-" << plugin_info->base_name << "-checkers=LIST\n";
std::cerr << "\n";
std::cerr << "\tLIST is a comma-separated list of checker names.\n";
......@@ -153,6 +161,7 @@ collect_plugin_args (plugin_name_args *plugin_info)
return 1;
}
}
return 0;
}
......@@ -228,8 +237,12 @@ plugin_init(struct plugin_name_args *plugin_info,
return 1;
}
// Handle command-line arguments.
if (collect_plugin_args(plugin_info)!=0)
return 1;
return 1;
// Read any additional config files specified via the environment.
CheckerGccPlugins::config.readViaEnv ("CHECKERGCCPLUGINS_CONFIG");
// Dump configuration info if requested.
if (!CheckerGccPlugins::config["dump"].empty()) {
......@@ -266,7 +279,7 @@ namespace CheckerGccPlugins {
// Configuration info.
const CheckerConfig config ("CHECKERGCCPLUGINS_CONFIG");
CheckerConfig config;
......
......@@ -37,7 +37,8 @@ namespace CheckerGccPlugins {
// Configuration info.
extern const CheckerConfig config;
extern CheckerConfig config;
typedef gimple* gimplePtr;
......@@ -57,8 +58,8 @@ void inform_url (location_t loc, const char* url);
tree vcall_fndecl (gimplePtr stmt);
// Equivalent functions are defined by gcc as of 11.3.0 / 12.0
#if GCC_VERSION < 12000
// Equivalent functions are defined by gcc 12.
inline
bool startswith (const char* haystack, const char* needle)
{
......@@ -68,8 +69,10 @@ bool startswith (const char* haystack, const char* needle)
}
return true;
}
#endif
#if GCC_VERSION < 11003
inline
bool endswith (const char* haystack, const char* needle)
{
......
......@@ -999,15 +999,16 @@ void check_thread_safe_call (Attributes_t attribs,
}
}
#if 0
if (warning_at (gimple_location (stmt), 0,
"Unchecked function %<%D%> called from thread-safe function %<%D%>; may not be thread-safe.",
fndecl, fun->decl))
{
inform (loc, "Declared here:");
CheckerGccPlugins::inform_url (gimple_location (stmt), url);
static const bool unchecked_calls_warning = !CheckerGccPlugins::config["thread.unchecked_calls_warning"].empty();
if (unchecked_calls_warning) {
if (warning_at (gimple_location (stmt), 0,
"Unchecked function %<%D%> called from thread-safe function %<%D%>; may not be thread-safe.",
fndecl, fun->decl))
{
inform (loc, "Declared here:");
CheckerGccPlugins::inform_url (gimple_location (stmt), url);
}
}
#endif
}
......@@ -1877,6 +1878,8 @@ void check_virtual_overrides (tree type)
"Gaudi::Algorithm::stop",
"Gaudi::Algorithm::start",
"Gaudi::Algorithm::initialize",
"Converter::initialize",
"Converter::finalize",
"IStateful::initialize",
"Service::initialize",
"AlgTool::initialize",
......
/**
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
* Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*
* @file CheckerGccPlugins/src/usingns_plugin.cxx
* @author scott snyder <snyder@bnl.gov>
......@@ -49,6 +49,8 @@
#if GCC_VERSION < 12000
using CheckerGccPlugins::startswith;
#endif
#if GCC_VERSION < 11003
using CheckerGccPlugins::endswith;
#endif
......
Supports Markdown
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