diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000..19b860c187 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +6.4.0 diff --git a/Makefile b/Makefile index 0865c75884..c46325944f 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,11 @@ all: $(MAKE) out/bin/infer PRUNE_AND_FIND := find . \( -path ./third_party \ +-o -path ./build/output \ -o -path ./clang-tidy \ -o -path ./misra_c_2012 \ -o -path ./out \ +-o -path ./podman_image/tmpWorkSpace \ -o -path ./vm \ -o -path ./vscode/nsa-result-highlight/analyze-demo \ -o -path '*/_bad0*' -o -path '*/_good00*' \ diff --git a/README.md b/README.md index 3e472227a6..4248e3478c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ directly from the source code. ### Using prebuilt container images -Refer to [analyze-demo](https://github.com/naivesystems/analyze-demo) for an example. +Refer to [analyze-demo](https://github.com/naivesystems/analyze-demo) for an +example. For projects using Makefiles, run the commands below in your project root: @@ -43,7 +44,7 @@ podman run --rm \ -v $PWD:/src:O \ -v $PWD/.naivesystems:/config:Z \ -v $PWD/output:/output:Z \ - ghcr.io/naivesystems/analyze:2023.3.3.0 \ + ghcr.io/naivesystems/analyze:latest \ /opt/naivesystems/misra_analyzer -show_results ``` @@ -65,7 +66,7 @@ A few notes: * You may remove `:Z` if you are not using SELinux. -* Replace `2023.3.3.0` with the actual version that you want to use. +* Replace `latest` with the actual version that you want to use. NaiveSystems Analyze can trace and capture your build process automatically. Currently we only publish Fedora-based images in the Community Edition, so your @@ -92,7 +93,7 @@ information. ### Building from source -To build from source, follow the steps below on Fedora 36 or 37. Other versions +To build from source, follow the steps below on Fedora 37. Other versions may also work but are not officially supported in the Community Edition. 1. Install build dependencies diff --git a/analyzer/proto/analyzer.proto b/analyzer/proto/analyzer.proto index 849f79653c..2c73cf92fa 100644 --- a/analyzer/proto/analyzer.proto +++ b/analyzer/proto/analyzer.proto @@ -49,11 +49,10 @@ message Definitions { } message CheckerConfiguration { - // System library options for CSA checker. string csa_system_lib_options = 1; string infer_bin = 2; string clang_bin = 3; - string code_checker_bin = 4; + reserved 4; string cppcheck_bin = 5; string python_bin = 6; string clangtidy_bin = 7; @@ -65,4 +64,5 @@ message CheckerConfiguration { string clangmapping_bin = 13; int64 infer_jobs = 14; string cpplint_script = 15; + reserved 16; } diff --git a/analyzer/proto/results.proto b/analyzer/proto/results.proto index 94fd181215..1e156e5fed 100644 --- a/analyzer/proto/results.proto +++ b/analyzer/proto/results.proto @@ -95,12 +95,14 @@ message Result { MISRA_C_2012_RULE_5_9 = 1050901; MISRA_C_2012_RULE_6_1 = 1060100; MISRA_C_2012_RULE_6_2 = 1060200; + MISRA_C_2012_RULE_6_3 = 1060301; MISRA_C_2012_RULE_7_1 = 1070100; MISRA_C_2012_RULE_7_2 = 1070200; MISRA_C_2012_RULE_7_3 = 1070300; MISRA_C_2012_RULE_7_4_CPPCHECK = 1070400; MISRA_C_2012_RULE_7_4 = 1070401; MISRA_C_2012_RULE_7_4_EXTERNAL = 1070402; + MISRA_C_2012_RULE_7_5 = 1070501; MISRA_C_2012_RULE_8_1 = 1080100; MISRA_C_2012_RULE_8_2_FUNC_DECL_PARM_NOT_NAMED_ERROR = 1080201; MISRA_C_2012_RULE_8_2_FUNC_POINTER_PARM_NOT_NAMED_ERROR = 1080202; @@ -123,6 +125,9 @@ message Result { MISRA_C_2012_RULE_8_11 = 1081100; MISRA_C_2012_RULE_8_12 = 1081200; MISRA_C_2012_RULE_8_14 = 1081400; + MISRA_C_2012_RULE_8_15 = 1081501; + MISRA_C_2012_RULE_8_16 = 1081601; + MISRA_C_2012_RULE_8_17 = 1081701; MISRA_C_2012_RULE_9_1 = 1090101; MISRA_C_2012_RULE_9_2 = 1090200; MISRA_C_2012_RULE_9_3 = 1090300; @@ -203,6 +208,10 @@ message Result { MISRA_C_2012_RULE_17_7 = 1170700; MISRA_C_2012_RULE_17_8_CPPCHECK = 1170800; MISRA_C_2012_RULE_17_8 = 1170801; + MISRA_C_2012_RULE_17_9 = 1170901; + MISRA_C_2012_RULE_17_10 = 1171001; + MISRA_C_2012_RULE_17_12 = 1171201; + MISRA_C_2012_RULE_17_13 = 1171301; MISRA_C_2012_RULE_18_1 = 1180101; MISRA_C_2012_RULE_18_2 = 1180201; MISRA_C_2012_RULE_18_3 = 1180301; @@ -240,6 +249,7 @@ message Result { MISRA_C_2012_RULE_21_10 = 1211000; MISRA_C_2012_RULE_21_11 = 1211100; MISRA_C_2012_RULE_21_12 = 1211200; + MISRA_C_2012_RULE_21_12_AMD3 = 1211210; MISRA_C_2012_RULE_21_13 = 1211301; MISRA_C_2012_RULE_21_14 = 1211401; MISRA_C_2012_RULE_21_15 = 1211500; @@ -251,6 +261,9 @@ message Result { MISRA_C_2012_RULE_21_19_EXTERNAL = 1211902; MISRA_C_2012_RULE_21_20 = 1212001; MISRA_C_2012_RULE_21_21 = 1212100; + MISRA_C_2012_RULE_21_22 = 1212201; + MISRA_C_2012_RULE_21_23 = 1212301; + MISRA_C_2012_RULE_21_24 = 1212401; MISRA_C_2012_RULE_22_1 = 1220101; MISRA_C_2012_RULE_22_2 = 1220201; MISRA_C_2012_RULE_22_3 = 1220301; @@ -261,6 +274,11 @@ message Result { MISRA_C_2012_RULE_22_8 = 1220801; MISRA_C_2012_RULE_22_9 = 1220901; MISRA_C_2012_RULE_22_10 = 1221001; + MISRA_C_2012_RULE_23_1 = 1230101; + MISRA_C_2012_RULE_23_2 = 1230201; + MISRA_C_2012_RULE_23_3 = 1230301; + MISRA_C_2012_RULE_23_4 = 1230401; + MISRA_C_2012_RULE_23_5 = 1230501; // prefix 2 for misra-c-2012 dir MISRA_C_2012_DIR_4_3_ASM_SHOULD_BE_ISOLATED = 2040301; MISRA_C_2012_DIR_4_3_ASM_SHOULD_BE_ENCAPSULATED = 2040302; diff --git a/autosar/rule_A0_1_3/libtooling/rule_A0_1_3.cc b/autosar/rule_A0_1_3/libtooling/rule_A0_1_3.cc index d12ff42966..d475cfbb20 100644 --- a/autosar/rule_A0_1_3/libtooling/rule_A0_1_3.cc +++ b/autosar/rule_A0_1_3/libtooling/rule_A0_1_3.cc @@ -47,13 +47,13 @@ int rule_A0_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A0_1_4/libtooling/rule_A0_1_4.cc b/autosar/rule_A0_1_4/libtooling/rule_A0_1_4.cc index 98d02ef3bf..eb2a222fe0 100644 --- a/autosar/rule_A0_1_4/libtooling/rule_A0_1_4.cc +++ b/autosar/rule_A0_1_4/libtooling/rule_A0_1_4.cc @@ -47,7 +47,7 @@ int rule_A0_1_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A0_1_5/libtooling/rule_A0_1_5.cc b/autosar/rule_A0_1_5/libtooling/rule_A0_1_5.cc index 073aa0cc33..dd44d738e9 100644 --- a/autosar/rule_A0_1_5/libtooling/rule_A0_1_5.cc +++ b/autosar/rule_A0_1_5/libtooling/rule_A0_1_5.cc @@ -47,13 +47,13 @@ int rule_A0_1_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A0_4_2/libtooling/checker.cc b/autosar/rule_A0_4_2/libtooling/checker.cc index 5d9131e0e6..f2852794fc 100644 --- a/autosar/rule_A0_4_2/libtooling/checker.cc +++ b/autosar/rule_A0_4_2/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace autosar { namespace rule_A0_4_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl(unless(isExpansionInSystemHeader())).bind("func"), this); @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto checkTypeAndReport = [&result, this](const QualType type, const Decl* decl) { if (!type->isSpecificBuiltinType(BuiltinType::LongDouble)) return; @@ -78,10 +77,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A0_4_2/libtooling/rule_A0_4_2.cc b/autosar/rule_A0_4_2/libtooling/rule_A0_4_2.cc index 12694fcb7a..fe53c705cd 100644 --- a/autosar/rule_A0_4_2/libtooling/rule_A0_4_2.cc +++ b/autosar/rule_A0_4_2/libtooling/rule_A0_4_2.cc @@ -48,7 +48,7 @@ int rule_A0_4_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A10_1_1/libtooling/checker.cc b/autosar/rule_A10_1_1/libtooling/checker.cc index d835d129cd..ce45235788 100644 --- a/autosar/rule_A10_1_1/libtooling/checker.cc +++ b/autosar/rule_A10_1_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Class shall not be derived from more than one base class which is not an interface class."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -56,10 +55,9 @@ bool isInterfaceClass(const CXXRecordDecl* decl) { return true; } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -67,7 +65,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* decl = cast(result.Nodes.getNodeAs("decl")); if (!decl->hasDefinition()) { @@ -83,7 +81,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (!isInterfaceClass(rd)) { cnt++; if (cnt > 1) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -95,10 +93,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A10_1_1/libtooling/rule_A10_1_1.cc b/autosar/rule_A10_1_1/libtooling/rule_A10_1_1.cc index 1772992dc3..bc78977cd9 100644 --- a/autosar/rule_A10_1_1/libtooling/rule_A10_1_1.cc +++ b/autosar/rule_A10_1_1/libtooling/rule_A10_1_1.cc @@ -48,7 +48,7 @@ int rule_A10_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A10_2_1/libtooling/checker.cc b/autosar/rule_A10_2_1/libtooling/checker.cc index 9ef8075a8e..a76ad0baf5 100644 --- a/autosar/rule_A10_2_1/libtooling/checker.cc +++ b/autosar/rule_A10_2_1/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Non-virtual public or protected member functions shall not be redefined in derived classes."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -62,10 +61,9 @@ bool isRedefined(const CXXMethodDecl* a, const CXXMethodDecl* b) { } } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -78,7 +76,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* decl = result.Nodes.getNodeAs("decl"); const CXXRecordDecl* rd = result.Nodes.getNodeAs("rd"); @@ -91,7 +89,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (method->isUserProvided() && isRedefined(method, decl)) { if (!method->isVirtual() && method->getAccess() != clang::AS_private) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -106,10 +104,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A10_2_1/libtooling/rule_A10_2_1.cc b/autosar/rule_A10_2_1/libtooling/rule_A10_2_1.cc index 457c45fb26..afa25aceec 100644 --- a/autosar/rule_A10_2_1/libtooling/rule_A10_2_1.cc +++ b/autosar/rule_A10_2_1/libtooling/rule_A10_2_1.cc @@ -48,7 +48,7 @@ int rule_A10_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A10_3_1/libtooling/rule_A10_3_1.cc b/autosar/rule_A10_3_1/libtooling/rule_A10_3_1.cc index ef210a4ac0..6cf4269289 100644 --- a/autosar/rule_A10_3_1/libtooling/rule_A10_3_1.cc +++ b/autosar/rule_A10_3_1/libtooling/rule_A10_3_1.cc @@ -47,7 +47,7 @@ int rule_A10_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A10_3_2/libtooling/rule_A10_3_2.cc b/autosar/rule_A10_3_2/libtooling/rule_A10_3_2.cc index ab657dcc12..41827dc9f1 100644 --- a/autosar/rule_A10_3_2/libtooling/rule_A10_3_2.cc +++ b/autosar/rule_A10_3_2/libtooling/rule_A10_3_2.cc @@ -47,7 +47,7 @@ int rule_A10_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A10_3_3/libtooling/rule_A10_3_3.cc b/autosar/rule_A10_3_3/libtooling/rule_A10_3_3.cc index 964678d131..1686662739 100644 --- a/autosar/rule_A10_3_3/libtooling/rule_A10_3_3.cc +++ b/autosar/rule_A10_3_3/libtooling/rule_A10_3_3.cc @@ -47,7 +47,7 @@ int rule_A10_3_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A10_3_5/libtooling/rule_A10_3_5.cc b/autosar/rule_A10_3_5/libtooling/rule_A10_3_5.cc index 84a8122778..4915a18404 100644 --- a/autosar/rule_A10_3_5/libtooling/rule_A10_3_5.cc +++ b/autosar/rule_A10_3_5/libtooling/rule_A10_3_5.cc @@ -47,7 +47,7 @@ int rule_A10_3_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A11_0_1/libtooling/checker.cc b/autosar/rule_A11_0_1/libtooling/checker.cc index 9070cdc242..f3127f4621 100644 --- a/autosar/rule_A11_0_1/libtooling/checker.cc +++ b/autosar/rule_A11_0_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "A non-POD type should be defined as class."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "A non-POD type should be defined as class."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A11_0_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl(hasDefinition(), unless(isExpansionInSystemHeader())) @@ -57,10 +55,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* decl = result.Nodes.getNodeAs("decl"); if (!decl->isClass() && !decl->isPOD()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -69,10 +67,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A11_0_1/libtooling/rule_A11_0_1.cc b/autosar/rule_A11_0_1/libtooling/rule_A11_0_1.cc index 126c3b3c9d..7e7e799fe0 100644 --- a/autosar/rule_A11_0_1/libtooling/rule_A11_0_1.cc +++ b/autosar/rule_A11_0_1/libtooling/rule_A11_0_1.cc @@ -48,7 +48,7 @@ int rule_A11_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A11_0_2/libtooling/checker.cc b/autosar/rule_A11_0_2/libtooling/checker.cc index 734b35144b..8e778dc75e 100644 --- a/autosar/rule_A11_0_2/libtooling/checker.cc +++ b/autosar/rule_A11_0_2/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A type defined as struct shall: (1) provide only public data members, (2) not provide any special member functions or methods, (3) not be a base of another struct or class, (4) not inherit from another struct or class."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -52,10 +51,9 @@ auto isPrivateOrProtected(StringRef spec) -> bool { return spec.contains("private") || spec.contains("protected"); }; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -71,7 +69,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* decl = result.Nodes.getNodeAs("decl"); const AccessSpecDecl* spec = result.Nodes.getNodeAs("spec"); @@ -83,7 +81,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { continue; } if (rd->isStruct()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(rd, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(rd, result.SourceManager); @@ -105,7 +103,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { result.Context->getLangOpts()); if (isPrivateOrProtected(source)) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -120,7 +118,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // (constructor, destructor, copy operation, // move operation), etc. if (decl->getNumBases() || !decl->isPOD()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -131,10 +129,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A11_0_2/libtooling/rule_A11_0_2.cc b/autosar/rule_A11_0_2/libtooling/rule_A11_0_2.cc index 2de78c6d06..526b0082cb 100644 --- a/autosar/rule_A11_0_2/libtooling/rule_A11_0_2.cc +++ b/autosar/rule_A11_0_2/libtooling/rule_A11_0_2.cc @@ -48,7 +48,7 @@ int rule_A11_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A11_3_1/libtooling/checker.cc b/autosar/rule_A11_3_1/libtooling/checker.cc index e6d840eea5..fb1f135eab 100644 --- a/autosar/rule_A11_3_1/libtooling/checker.cc +++ b/autosar/rule_A11_3_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "Friend declarations shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "Friend declarations shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A11_3_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(friendDecl(unless(isExpansionInSystemHeader()), @@ -69,7 +67,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); const FunctionDecl* func = result.Nodes.getNodeAs("func"); @@ -82,7 +80,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } } - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -90,10 +88,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A11_3_1/libtooling/rule_A11_3_1.cc b/autosar/rule_A11_3_1/libtooling/rule_A11_3_1.cc index abafabe262..c9d9d31458 100644 --- a/autosar/rule_A11_3_1/libtooling/rule_A11_3_1.cc +++ b/autosar/rule_A11_3_1/libtooling/rule_A11_3_1.cc @@ -48,7 +48,7 @@ int rule_A11_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_0_1/libtooling/checker.cc b/autosar/rule_A12_0_1/libtooling/checker.cc index 8a8d1f28af..319f5efade 100644 --- a/autosar/rule_A12_0_1/libtooling/checker.cc +++ b/autosar/rule_A12_0_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "If a class declares a copy or move operation, or a destructor, either via “=default”, “=delete”, or via a user-provided declaration, then all others of these five special member functions shall be declared as well."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_0_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl(anyOf(has(cxxDestructorDecl()), @@ -66,7 +64,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* crd = result.Nodes.getNodeAs("crd"); if (crd) ReportError( @@ -76,10 +74,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_0_1/libtooling/rule_A12_0_1.cc b/autosar/rule_A12_0_1/libtooling/rule_A12_0_1.cc index 765fdb5748..76e653d2a8 100644 --- a/autosar/rule_A12_0_1/libtooling/rule_A12_0_1.cc +++ b/autosar/rule_A12_0_1/libtooling/rule_A12_0_1.cc @@ -48,7 +48,7 @@ int rule_A12_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_1_1/libtooling/rule_A12_1_1.cc b/autosar/rule_A12_1_1/libtooling/rule_A12_1_1.cc index 24c0ce1ed3..e168c1f527 100644 --- a/autosar/rule_A12_1_1/libtooling/rule_A12_1_1.cc +++ b/autosar/rule_A12_1_1/libtooling/rule_A12_1_1.cc @@ -47,7 +47,7 @@ int rule_A12_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A12_1_2/libtooling/rule_A12_1_2.cc b/autosar/rule_A12_1_2/libtooling/rule_A12_1_2.cc index 11b3cfcf62..e9ea618344 100644 --- a/autosar/rule_A12_1_2/libtooling/rule_A12_1_2.cc +++ b/autosar/rule_A12_1_2/libtooling/rule_A12_1_2.cc @@ -47,7 +47,7 @@ int rule_A12_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A12_1_3/libtooling/checker.cc b/autosar/rule_A12_1_3/libtooling/checker.cc index 15d9ef2dc3..9819220e5d 100644 --- a/autosar/rule_A12_1_3/libtooling/checker.cc +++ b/autosar/rule_A12_1_3/libtooling/checker.cc @@ -37,12 +37,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "If all user-defined constructors of a class initialize data members with constant values that are the same across all constructors, then data members shall be initialized using NSDMI instrad."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -56,8 +55,7 @@ namespace libtooling { typedef unordered_map>*> CheckMap; -string getValue(const ast_matchers::MatchFinder::MatchResult& result, - const Expr* expr) { +string getValue(const MatchFinder::MatchResult& result, const Expr* expr) { clang::SourceRange range = SourceRange(result.SourceManager->getSpellingLoc(expr->getBeginLoc()), result.SourceManager->getSpellingLoc(expr->getEndLoc())); @@ -70,9 +68,9 @@ string getValue(const ast_matchers::MatchFinder::MatchResult& result, return source.str(); } -void addExprToCheckMapItem( - CheckMap* checkMap, const Expr* expr, const FieldDecl* FD, - const ast_matchers::MatchFinder::MatchResult& result) { +void addExprToCheckMapItem(CheckMap* checkMap, const Expr* expr, + const FieldDecl* FD, + const MatchFinder::MatchResult& result) { if (!checkMap->count(FD)) { vector>* valueList = new vector>; @@ -95,10 +93,9 @@ bool hasInitByVariable(CheckMap* checkMap, const FieldDecl* FD) { return checkMap->count(FD) && (*checkMap)[FD] == nullptr; } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -107,7 +104,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* record = result.Nodes.getNodeAs("record"); CheckMap initMap; @@ -131,7 +128,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // use NSDMI markAsInitByVariable(&initMap, FD); if (FD->hasInClassInitializer()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(FD, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(FD, result.SourceManager); @@ -177,7 +174,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // should not use NSDMI markAsInitByVariable(&initMap, FD); if (FD->hasInClassInitializer()) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( FD, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(FD, result.SourceManager); @@ -203,7 +200,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (memberInit.first->hasInClassInitializer()) { // this data member is initialized with different values, so it // should not use NSDMI - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( memberInit.first, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( memberInit.first, result.SourceManager); @@ -216,7 +213,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // this data member is initialized with the same constant values, so // it should use NSDMI, report error on each constructor decl for (auto value : values) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( value.first, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( value.first, result.SourceManager); @@ -245,10 +242,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_1_3/libtooling/rule_A12_1_3.cc b/autosar/rule_A12_1_3/libtooling/rule_A12_1_3.cc index 5c44787ca5..840abd602a 100644 --- a/autosar/rule_A12_1_3/libtooling/rule_A12_1_3.cc +++ b/autosar/rule_A12_1_3/libtooling/rule_A12_1_3.cc @@ -48,7 +48,7 @@ int rule_A12_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_1_4/libtooling/checker.cc b/autosar/rule_A12_1_4/libtooling/checker.cc index f0abbb47d9..db5dbc84df 100644 --- a/autosar/rule_A12_1_4/libtooling/checker.cc +++ b/autosar/rule_A12_1_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "All constructors that are callable with a single argument of fundamental type shall be declared explicit."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_1_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxConstructorDecl(unless(isExplicit()), @@ -59,13 +57,13 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXConstructorDecl* decl = result.Nodes.getNodeAs("decl"); if (decl->hasOneParamOrDefaultArgs()) { const ParmVarDecl* param = decl->getParamDecl(0); if (param->getType()->isBuiltinType()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -75,10 +73,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_1_4/libtooling/rule_A12_1_4.cc b/autosar/rule_A12_1_4/libtooling/rule_A12_1_4.cc index 4b16eaac8a..1dbad9e5e3 100644 --- a/autosar/rule_A12_1_4/libtooling/rule_A12_1_4.cc +++ b/autosar/rule_A12_1_4/libtooling/rule_A12_1_4.cc @@ -48,7 +48,7 @@ int rule_A12_1_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_1_5/libtooling/checker.cc b/autosar/rule_A12_1_5/libtooling/checker.cc index a5b5a62508..b6cfd08b8b 100644 --- a/autosar/rule_A12_1_5/libtooling/checker.cc +++ b/autosar/rule_A12_1_5/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::vector; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Common class initialization for non-constant members shall be done by a delegating constructor."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -48,10 +47,9 @@ namespace autosar { namespace rule_A12_1_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxRecordDecl(isClass(), unless(isImplicit()), unless(isExpansionInSystemHeader())) @@ -59,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* crd = result.Nodes.getNodeAs("crd"); if (crd) { vector> existedCtorInitsSequences{}; @@ -87,10 +85,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_1_5/libtooling/rule_A12_1_5.cc b/autosar/rule_A12_1_5/libtooling/rule_A12_1_5.cc index 3645b6afd9..2c4b7ef698 100644 --- a/autosar/rule_A12_1_5/libtooling/rule_A12_1_5.cc +++ b/autosar/rule_A12_1_5/libtooling/rule_A12_1_5.cc @@ -48,7 +48,7 @@ int rule_A12_1_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_1_6/libtooling/checker.cc b/autosar/rule_A12_1_6/libtooling/checker.cc index f3f525afa3..5f6da7ae02 100644 --- a/autosar/rule_A12_1_6/libtooling/checker.cc +++ b/autosar/rule_A12_1_6/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Derived classes that do not need further explicit initialization and require all the constructors from the base class shall use inheriting constructors."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -56,8 +55,7 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -66,7 +64,7 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXRecordDecl* class_decl = result.Nodes.getNodeAs("class_decl"); if (misra::libtooling_utils::IsInSystemHeader(class_decl, result.Context)) { @@ -158,7 +156,7 @@ class Callback : public MatchFinder::MatchCallback { // 数量相等,说明应该直接继承 if (num_of_matched_ctors_by_class == num_of_base_ctors) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( class_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(class_decl, result.SourceManager); @@ -168,10 +166,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_1_6/libtooling/rule_A12_1_6.cc b/autosar/rule_A12_1_6/libtooling/rule_A12_1_6.cc index 142c43656a..3845353242 100644 --- a/autosar/rule_A12_1_6/libtooling/rule_A12_1_6.cc +++ b/autosar/rule_A12_1_6/libtooling/rule_A12_1_6.cc @@ -48,7 +48,7 @@ int rule_A12_1_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_4_1/libtooling/rule_A12_4_1.cc b/autosar/rule_A12_4_1/libtooling/rule_A12_4_1.cc index 0f57e7236f..d8b5eea325 100644 --- a/autosar/rule_A12_4_1/libtooling/rule_A12_4_1.cc +++ b/autosar/rule_A12_4_1/libtooling/rule_A12_4_1.cc @@ -47,7 +47,7 @@ int rule_A12_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A12_4_2/libtooling/checker.cc b/autosar/rule_A12_4_2/libtooling/checker.cc index 7fc4266b68..1b0ab38715 100644 --- a/autosar/rule_A12_4_2/libtooling/checker.cc +++ b/autosar/rule_A12_4_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "If a public destructor of a class is non-virtual, then the class should be declared final."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_4_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -68,7 +66,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); const CXXRecordDecl* implicit_decl = result.Nodes.getNodeAs("implicit_decl"); @@ -76,7 +74,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { const CXXDestructorDecl* destructor = result.Nodes.getNodeAs("destructor"); if (destructor->getAccess() == AS_public) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -84,8 +82,8 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } } if (implicit_decl) { - std::string path = misra::libtooling_utils::GetFilename( - implicit_decl, result.SourceManager); + string path = misra::libtooling_utils::GetFilename(implicit_decl, + result.SourceManager); int line_number = misra::libtooling_utils::GetLine(implicit_decl, result.SourceManager); ReportError(path, line_number, results_list_); @@ -93,10 +91,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_4_2/libtooling/rule_A12_4_2.cc b/autosar/rule_A12_4_2/libtooling/rule_A12_4_2.cc index 5f615731a4..bbfcbff9fa 100644 --- a/autosar/rule_A12_4_2/libtooling/rule_A12_4_2.cc +++ b/autosar/rule_A12_4_2/libtooling/rule_A12_4_2.cc @@ -48,7 +48,7 @@ int rule_A12_4_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_6_1/libtooling/rule_A12_6_1.cc b/autosar/rule_A12_6_1/libtooling/rule_A12_6_1.cc index ce2c66a170..357d82b359 100644 --- a/autosar/rule_A12_6_1/libtooling/rule_A12_6_1.cc +++ b/autosar/rule_A12_6_1/libtooling/rule_A12_6_1.cc @@ -47,7 +47,7 @@ int rule_A12_6_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A12_7_1/libtooling/rule_A12_7_1.cc b/autosar/rule_A12_7_1/libtooling/rule_A12_7_1.cc index 368cba4d49..1ef1a7c8a6 100644 --- a/autosar/rule_A12_7_1/libtooling/rule_A12_7_1.cc +++ b/autosar/rule_A12_7_1/libtooling/rule_A12_7_1.cc @@ -47,7 +47,7 @@ int rule_A12_7_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A12_8_1/libtooling/checker.cc b/autosar/rule_A12_8_1/libtooling/checker.cc index 18ca544170..636b434127 100644 --- a/autosar/rule_A12_8_1/libtooling/checker.cc +++ b/autosar/rule_A12_8_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Move and copy constructors shall move and respectively copy base classes and data members of a class, without any side effects."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -84,10 +83,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_1/libtooling/rule_A12_8_1.cc b/autosar/rule_A12_8_1/libtooling/rule_A12_8_1.cc index f9aa60aab4..225c9875ea 100644 --- a/autosar/rule_A12_8_1/libtooling/rule_A12_8_1.cc +++ b/autosar/rule_A12_8_1/libtooling/rule_A12_8_1.cc @@ -48,7 +48,7 @@ int rule_A12_8_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_2/libtooling/checker.cc b/autosar/rule_A12_8_2/libtooling/checker.cc index e465348141..469c403bdf 100644 --- a/autosar/rule_A12_8_2/libtooling/checker.cc +++ b/autosar/rule_A12_8_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "User-defined copy and move assignment operators should use user-defined no-throw swap function."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_8_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxMethodDecl( @@ -63,7 +61,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* cmd = result.Nodes.getNodeAs("cmd"); if (cmd) ReportError( @@ -73,10 +71,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_2/libtooling/rule_A12_8_2.cc b/autosar/rule_A12_8_2/libtooling/rule_A12_8_2.cc index e627da61bd..8183931d68 100644 --- a/autosar/rule_A12_8_2/libtooling/rule_A12_8_2.cc +++ b/autosar/rule_A12_8_2/libtooling/rule_A12_8_2.cc @@ -48,7 +48,7 @@ int rule_A12_8_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_3/libtooling/checker.cc b/autosar/rule_A12_8_3/libtooling/checker.cc index a411ff9599..f7cfc3fe36 100644 --- a/autosar/rule_A12_8_3/libtooling/checker.cc +++ b/autosar/rule_A12_8_3/libtooling/checker.cc @@ -32,11 +32,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "Moved_from object shall not be read-accessed."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "Moved_from object shall not be read-accessed."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_8_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr( @@ -108,7 +106,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool ContainsDecl(const Stmt* stmt, const Decl* decl) { if (!stmt) { return false; @@ -125,7 +123,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_3/libtooling/rule_A12_8_3.cc b/autosar/rule_A12_8_3/libtooling/rule_A12_8_3.cc index d11cab7562..0a9aa7afe8 100644 --- a/autosar/rule_A12_8_3/libtooling/rule_A12_8_3.cc +++ b/autosar/rule_A12_8_3/libtooling/rule_A12_8_3.cc @@ -48,7 +48,7 @@ int rule_A12_8_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_4/libtooling/checker.cc b/autosar/rule_A12_8_4/libtooling/checker.cc index 47a92e415d..f49f3f3ad4 100644 --- a/autosar/rule_A12_8_4/libtooling/checker.cc +++ b/autosar/rule_A12_8_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Move constructor shall not initialize its class members and base classes using copy semantics."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -79,10 +78,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_4/libtooling/rule_A12_8_4.cc b/autosar/rule_A12_8_4/libtooling/rule_A12_8_4.cc index 56cf70f931..208e440f2f 100644 --- a/autosar/rule_A12_8_4/libtooling/rule_A12_8_4.cc +++ b/autosar/rule_A12_8_4/libtooling/rule_A12_8_4.cc @@ -48,7 +48,7 @@ int rule_A12_8_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_5/libtooling/checker.cc b/autosar/rule_A12_8_5/libtooling/checker.cc index 7a6a3ad33c..5dc57f5c1d 100644 --- a/autosar/rule_A12_8_5/libtooling/checker.cc +++ b/autosar/rule_A12_8_5/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A copy assignment and a move assignment operators shall handle self-assignment."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_8_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto this_pointer = anyOf( cxxThisExpr(), implicitCastExpr(hasSourceExpression(cxxThisExpr()))); @@ -70,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* cmd = result.Nodes.getNodeAs("cmd"); if (cmd) ReportError( @@ -80,10 +78,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_5/libtooling/rule_A12_8_5.cc b/autosar/rule_A12_8_5/libtooling/rule_A12_8_5.cc index 26d942e5cf..7230091652 100644 --- a/autosar/rule_A12_8_5/libtooling/rule_A12_8_5.cc +++ b/autosar/rule_A12_8_5/libtooling/rule_A12_8_5.cc @@ -48,7 +48,7 @@ int rule_A12_8_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_6/libtooling/checker.cc b/autosar/rule_A12_8_6/libtooling/checker.cc index f53ceda2f0..b0ba9797e5 100644 --- a/autosar/rule_A12_8_6/libtooling/checker.cc +++ b/autosar/rule_A12_8_6/libtooling/checker.cc @@ -32,19 +32,17 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, - ResultsList* results_list, string str = "") { - std::string error_message = +void ReportError(const string& path, int line_number, ResultsList* results_list, + string str = "") { + string error_message = "Copy and move constructors and copy assignment and move assignment operators shall be declared protected or defined \"=delete\" in base class." + str; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } -void InitFinder(MatchFinder* finder, - ast_matchers::MatchFinder::MatchCallback* callback) { +void InitFinder(MatchFinder* finder, MatchFinder::MatchCallback* callback) { finder->addMatcher( cxxRecordDecl(isClass(), hasDefinition(), unless(isImplicit()), unless(isExpansionInSystemHeader())) @@ -58,14 +56,14 @@ namespace autosar { namespace rule_A12_8_6 { namespace libtooling { -class CollectBasesCallback : public ast_matchers::MatchFinder::MatchCallback { +class CollectBasesCallback : public MatchFinder::MatchCallback { public: - CollectBasesCallback(analyzer::proto::ResultsList* results_list) + CollectBasesCallback(ResultsList* results_list) : results_list_(results_list) {} std::set GetBases() { return bases_; } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* crd = result.Nodes.getNodeAs("crd"); if (crd) for (const auto base : crd->bases()) { @@ -76,18 +74,17 @@ class CollectBasesCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::set bases_{}; friend class Checker; }; -class CheckBasesCallback : public ast_matchers::MatchFinder::MatchCallback { +class CheckBasesCallback : public MatchFinder::MatchCallback { public: - CheckBasesCallback(analyzer::proto::ResultsList* results_list, - std::set bases) + CheckBasesCallback(ResultsList* results_list, std::set bases) : results_list_(results_list), bases_(bases) {} - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* crd = result.Nodes.getNodeAs("crd"); QualType qt = result.Context->getTypeDeclType(crd); string type = TypeName::getFullyQualifiedName( @@ -108,12 +105,11 @@ class CheckBasesCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; const std::set bases_; }; -void Checker::InitCollectBasesCallback( - analyzer::proto::ResultsList* results_list) { +void Checker::InitCollectBasesCallback(ResultsList* results_list) { results_list_ = results_list; callback1_ = new CollectBasesCallback{results_list}; InitFinder(&finder1_, callback1_); diff --git a/autosar/rule_A12_8_6/libtooling/rule_A12_8_6.cc b/autosar/rule_A12_8_6/libtooling/rule_A12_8_6.cc index dc4dd54f68..718dabb11c 100644 --- a/autosar/rule_A12_8_6/libtooling/rule_A12_8_6.cc +++ b/autosar/rule_A12_8_6/libtooling/rule_A12_8_6.cc @@ -48,7 +48,7 @@ int rule_A12_8_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A12_8_7/libtooling/checker.cc b/autosar/rule_A12_8_7/libtooling/checker.cc index 7e811288b8..3810eee348 100644 --- a/autosar/rule_A12_8_7/libtooling/checker.cc +++ b/autosar/rule_A12_8_7/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Assignment operators should be declared with the ref-qualifier."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A12_8_7 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -59,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* decl = result.Nodes.getNodeAs("decl"); OverloadedOperatorKind op = decl->getOverloadedOperator(); set assignment_operators{OO_Equal, @@ -80,7 +78,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (op != clang::OO_None && decl->getRefQualifier() == RQ_None) { if (assignment_operators.find(op) != assignment_operators.end()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -91,10 +89,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A12_8_7/libtooling/rule_A12_8_7.cc b/autosar/rule_A12_8_7/libtooling/rule_A12_8_7.cc index 8b12a67446..9eed61a3fd 100644 --- a/autosar/rule_A12_8_7/libtooling/rule_A12_8_7.cc +++ b/autosar/rule_A12_8_7/libtooling/rule_A12_8_7.cc @@ -48,7 +48,7 @@ int rule_A12_8_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_1_2/libtooling/rule_A13_1_2.cc b/autosar/rule_A13_1_2/libtooling/rule_A13_1_2.cc index 3823de6a7b..a3d49112d1 100644 --- a/autosar/rule_A13_1_2/libtooling/rule_A13_1_2.cc +++ b/autosar/rule_A13_1_2/libtooling/rule_A13_1_2.cc @@ -48,7 +48,7 @@ int rule_A13_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A13_1_3/libtooling/checker.cc b/autosar/rule_A13_1_3/libtooling/checker.cc index 9c3cf389ca..fe8f9e6f20 100644 --- a/autosar/rule_A13_1_3/libtooling/checker.cc +++ b/autosar/rule_A13_1_3/libtooling/checker.cc @@ -35,12 +35,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "User defined literals operators shall only perform conversion of passed parameters."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -81,10 +80,9 @@ bool hasSideEffectsInFunction(const FunctionDecl* FD, return false; } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(hasDescendant(returnStmt()), @@ -97,7 +95,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* decl = result.Nodes.getNodeAs("decl"); const FunctionDecl* no_return_decl = result.Nodes.getNodeAs("no_return_decl"); @@ -109,7 +107,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { return; } if (isLiteralOperatorFunction(no_return_decl)) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( no_return_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( no_return_decl, result.SourceManager); @@ -126,7 +124,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // check side effect if (decl->getReturnType()->isVoidType() || hasSideEffectsInFunction(decl, *(result.Context))) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -136,10 +134,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_1_3/libtooling/rule_A13_1_3.cc b/autosar/rule_A13_1_3/libtooling/rule_A13_1_3.cc index 1e509b78da..bafdbeb70d 100644 --- a/autosar/rule_A13_1_3/libtooling/rule_A13_1_3.cc +++ b/autosar/rule_A13_1_3/libtooling/rule_A13_1_3.cc @@ -48,7 +48,7 @@ int rule_A13_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_2_1/libtooling/rule_A13_2_1.cc b/autosar/rule_A13_2_1/libtooling/rule_A13_2_1.cc index 40e5815796..3f01dda64c 100644 --- a/autosar/rule_A13_2_1/libtooling/rule_A13_2_1.cc +++ b/autosar/rule_A13_2_1/libtooling/rule_A13_2_1.cc @@ -47,7 +47,7 @@ int rule_A13_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A13_2_2/libtooling/rule_A13_2_2.cc b/autosar/rule_A13_2_2/libtooling/rule_A13_2_2.cc index d83e17fe19..cf8e5fec7a 100644 --- a/autosar/rule_A13_2_2/libtooling/rule_A13_2_2.cc +++ b/autosar/rule_A13_2_2/libtooling/rule_A13_2_2.cc @@ -47,7 +47,7 @@ int rule_A13_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A13_2_3/libtooling/rule_A13_2_3.cc b/autosar/rule_A13_2_3/libtooling/rule_A13_2_3.cc index e836361782..cf3eabfa16 100644 --- a/autosar/rule_A13_2_3/libtooling/rule_A13_2_3.cc +++ b/autosar/rule_A13_2_3/libtooling/rule_A13_2_3.cc @@ -47,7 +47,7 @@ int rule_A13_2_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A13_3_1/libtooling/checker.cc b/autosar/rule_A13_3_1/libtooling/checker.cc index 5bbb0d3582..a8b21eea56 100644 --- a/autosar/rule_A13_3_1/libtooling/checker.cc +++ b/autosar/rule_A13_3_1/libtooling/checker.cc @@ -34,8 +34,7 @@ void ReportError(const std::string& path, int line_number, ResultsList* results_list) { std::string error_message = "A function that contains \"forwarding reference\" as its argument shall not be overloaded."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A13_3_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -57,7 +55,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* function_decl = result.Nodes.getNodeAs("function_decl"); const auto forwarding_ref_function_iter = forwarding_ref_functions.find( @@ -103,7 +101,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; // = std::unordered_map forwarding_ref_functions; @@ -156,7 +154,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_3_1/libtooling/rule_A13_3_1.cc b/autosar/rule_A13_3_1/libtooling/rule_A13_3_1.cc index ab64a48a66..2d895f4958 100644 --- a/autosar/rule_A13_3_1/libtooling/rule_A13_3_1.cc +++ b/autosar/rule_A13_3_1/libtooling/rule_A13_3_1.cc @@ -48,7 +48,7 @@ int rule_A13_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_5_1/libtooling/checker.cc b/autosar/rule_A13_5_1/libtooling/checker.cc index 3af362871b..5bce247fef 100644 --- a/autosar/rule_A13_5_1/libtooling/checker.cc +++ b/autosar/rule_A13_5_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "If \"operator[]\" is to be overloaded with a non-const version, const version shall also be implemented."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A13_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxRecordDecl(hasMethod(hasOverloadedOperatorName("[]")), @@ -59,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXRecordDecl* decl = result.Nodes.getNodeAs("decl"); vector nonConstDeclArray; @@ -78,8 +76,8 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } for (const CXXMethodDecl* nonConstDecl : nonConstDeclArray) { - std::string path = misra::libtooling_utils::GetFilename( - nonConstDecl, result.SourceManager); + string path = misra::libtooling_utils::GetFilename(nonConstDecl, + result.SourceManager); int line_number = misra::libtooling_utils::GetLine(nonConstDecl, result.SourceManager); ReportError(path, line_number, results_list_); @@ -87,10 +85,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_5_1/libtooling/rule_A13_5_1.cc b/autosar/rule_A13_5_1/libtooling/rule_A13_5_1.cc index bcf26bab54..f805f292be 100644 --- a/autosar/rule_A13_5_1/libtooling/rule_A13_5_1.cc +++ b/autosar/rule_A13_5_1/libtooling/rule_A13_5_1.cc @@ -48,7 +48,7 @@ int rule_A13_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_5_2/libtooling/checker.cc b/autosar/rule_A13_5_2/libtooling/checker.cc index 75083e8118..078c00e92a 100644 --- a/autosar/rule_A13_5_2/libtooling/checker.cc +++ b/autosar/rule_A13_5_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "All user-defined conversion operators shall be defined explicit."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A13_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxConversionDecl(isUserProvided(), unless(isExplicit()), @@ -59,10 +57,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -70,10 +68,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_5_2/libtooling/rule_A13_5_2.cc b/autosar/rule_A13_5_2/libtooling/rule_A13_5_2.cc index 3d9f22c2df..a03362d134 100644 --- a/autosar/rule_A13_5_2/libtooling/rule_A13_5_2.cc +++ b/autosar/rule_A13_5_2/libtooling/rule_A13_5_2.cc @@ -48,7 +48,7 @@ int rule_A13_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_5_3/libtooling/checker.cc b/autosar/rule_A13_5_3/libtooling/checker.cc index 322d234184..bda396bc52 100644 --- a/autosar/rule_A13_5_3/libtooling/checker.cc +++ b/autosar/rule_A13_5_3/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "User-defined conversion operators should not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A13_5_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -59,10 +57,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -70,10 +68,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_5_3/libtooling/rule_A13_5_3.cc b/autosar/rule_A13_5_3/libtooling/rule_A13_5_3.cc index e5c01ec841..ccf3f16cd7 100644 --- a/autosar/rule_A13_5_3/libtooling/rule_A13_5_3.cc +++ b/autosar/rule_A13_5_3/libtooling/rule_A13_5_3.cc @@ -48,7 +48,7 @@ int rule_A13_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A13_5_4/libtooling/rule_A13_5_4.cc b/autosar/rule_A13_5_4/libtooling/rule_A13_5_4.cc index e752f2fa6e..79ab25f968 100644 --- a/autosar/rule_A13_5_4/libtooling/rule_A13_5_4.cc +++ b/autosar/rule_A13_5_4/libtooling/rule_A13_5_4.cc @@ -48,7 +48,7 @@ int rule_A13_5_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A13_5_5/libtooling/checker.cc b/autosar/rule_A13_5_5/libtooling/checker.cc index 119cfe09a0..b464081920 100644 --- a/autosar/rule_A13_5_5/libtooling/checker.cc +++ b/autosar/rule_A13_5_5/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::vector; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Comparison operators shall be non-member functions with identical parameter types and noexcept."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -48,10 +47,9 @@ namespace autosar { namespace rule_A13_5_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl( @@ -61,7 +59,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); if (!fd) return; const CXXMethodDecl* cmd = dynamic_cast(fd); @@ -86,10 +84,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A13_5_5/libtooling/rule_A13_5_5.cc b/autosar/rule_A13_5_5/libtooling/rule_A13_5_5.cc index 49c7753a3a..26f5c48f1c 100644 --- a/autosar/rule_A13_5_5/libtooling/rule_A13_5_5.cc +++ b/autosar/rule_A13_5_5/libtooling/rule_A13_5_5.cc @@ -48,7 +48,7 @@ int rule_A13_5_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A14_5_1/libtooling/checker.cc b/autosar/rule_A14_5_1/libtooling/checker.cc index 7eafe56e1c..05c4dc6c93 100644 --- a/autosar/rule_A14_5_1/libtooling/checker.cc +++ b/autosar/rule_A14_5_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2023 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "autosar/rule_A14_5_1/libtooling/checker.h" @@ -54,7 +66,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const CXXConstructorDecl* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(decl_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(decl_, result.SourceManager); diff --git a/autosar/rule_A14_5_1/libtooling/checker.h b/autosar/rule_A14_5_1/libtooling/checker.h index 8a275df726..abbb47bc84 100644 --- a/autosar/rule_A14_5_1/libtooling/checker.h +++ b/autosar/rule_A14_5_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2023 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_AUTOSAR_A14_5_1_LIBTOOLING_CHECKER_H_ diff --git a/autosar/rule_A14_5_1/libtooling/rule_A14_5_1.cc b/autosar/rule_A14_5_1/libtooling/rule_A14_5_1.cc index 9fa16bff8d..18e292e61e 100644 --- a/autosar/rule_A14_5_1/libtooling/rule_A14_5_1.cc +++ b/autosar/rule_A14_5_1/libtooling/rule_A14_5_1.cc @@ -47,7 +47,7 @@ int rule_A14_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A14_5_2/libtooling/checker.cc b/autosar/rule_A14_5_2/libtooling/checker.cc index a77cdeb330..75a99089c4 100644 --- a/autosar/rule_A14_5_2/libtooling/checker.cc +++ b/autosar/rule_A14_5_2/libtooling/checker.cc @@ -33,9 +33,9 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Class members that are not dependent on template class parameters should be defined in a separate base class."; AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, @@ -48,10 +48,9 @@ namespace autosar { namespace rule_A14_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxRecordDecl(isClass(), hasDefinition(), hasParent(classTemplateDecl()), @@ -85,7 +84,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool ContainsDependentMember(const DeclContext* dc) { if (!dc) return false; for (const Decl* child : dc->decls()) { @@ -117,7 +116,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A14_5_2/libtooling/rule_A14_5_2.cc b/autosar/rule_A14_5_2/libtooling/rule_A14_5_2.cc index 0c9c70112a..accb7be330 100644 --- a/autosar/rule_A14_5_2/libtooling/rule_A14_5_2.cc +++ b/autosar/rule_A14_5_2/libtooling/rule_A14_5_2.cc @@ -48,7 +48,7 @@ int rule_A14_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A14_5_3/libtooling/checker.cc b/autosar/rule_A14_5_3/libtooling/checker.cc index 7bce481675..e9bbb43e33 100644 --- a/autosar/rule_A14_5_3/libtooling/checker.cc +++ b/autosar/rule_A14_5_3/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A non-member generic operator shall only be declared in a namespace that does not contain class (struct) type, enum type or union type declarations."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A14_5_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionTemplateDecl(hasParent(namespaceDecl(has(tagDecl()))), @@ -59,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionTemplateDecl* ftd = result.Nodes.getNodeAs("ftd"); if (ftd) { @@ -73,10 +71,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A14_5_3/libtooling/rule_A14_5_3.cc b/autosar/rule_A14_5_3/libtooling/rule_A14_5_3.cc index 8890ec4f11..6bb625f53c 100644 --- a/autosar/rule_A14_5_3/libtooling/rule_A14_5_3.cc +++ b/autosar/rule_A14_5_3/libtooling/rule_A14_5_3.cc @@ -48,7 +48,7 @@ int rule_A14_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A14_7_1/libtooling/rule_A14_7_1.cc b/autosar/rule_A14_7_1/libtooling/rule_A14_7_1.cc index 161bd8901b..a96a49d176 100644 --- a/autosar/rule_A14_7_1/libtooling/rule_A14_7_1.cc +++ b/autosar/rule_A14_7_1/libtooling/rule_A14_7_1.cc @@ -48,7 +48,7 @@ int rule_A14_7_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A14_8_2/libtooling/checker.cc b/autosar/rule_A14_8_2/libtooling/checker.cc index 28f0f57a67..ae6694e1ef 100644 --- a/autosar/rule_A14_8_2/libtooling/checker.cc +++ b/autosar/rule_A14_8_2/libtooling/checker.cc @@ -33,12 +33,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Explicit specializations of function templates shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -49,10 +48,9 @@ namespace autosar { namespace rule_A14_8_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(unless(isExpansionInSystemHeader()), @@ -61,10 +59,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { if (const FunctionDecl* explicit_specialization = result.Nodes.getNodeAs("explicit_specialization")) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( explicit_specialization, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( explicit_specialization, result.SourceManager); @@ -73,10 +71,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A14_8_2/libtooling/rule_A14_8_2.cc b/autosar/rule_A14_8_2/libtooling/rule_A14_8_2.cc index 22ceb75651..d8ea6c876e 100644 --- a/autosar/rule_A14_8_2/libtooling/rule_A14_8_2.cc +++ b/autosar/rule_A14_8_2/libtooling/rule_A14_8_2.cc @@ -48,7 +48,7 @@ int rule_A14_8_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_1_1/libtooling/checker.cc b/autosar/rule_A15_1_1/libtooling/checker.cc index 6c1eb181a1..05ddb0561a 100644 --- a/autosar/rule_A15_1_1/libtooling/checker.cc +++ b/autosar/rule_A15_1_1/libtooling/checker.cc @@ -34,12 +34,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Only instances of types derived from std::exception should be thrown."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -50,10 +49,9 @@ namespace autosar { namespace rule_A15_1_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxThrowExpr(has(cxxConstructExpr().bind("construct")), @@ -67,14 +65,14 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXThrowExpr* expr = result.Nodes.getNodeAs("expr"); const CXXConstructExpr* construct = result.Nodes.getNodeAs("construct"); // if CXXThrowExpr does not throw an object (e.g., throw a integer literal), // report error and return if (!construct) { - std::string path = + string path = misra::libtooling_utils::GetFilename(expr, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(expr, result.SourceManager); @@ -99,7 +97,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } } } - std::string path = + string path = misra::libtooling_utils::GetFilename(expr, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(expr, result.SourceManager); @@ -108,10 +106,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_1_1/libtooling/rule_A15_1_1.cc b/autosar/rule_A15_1_1/libtooling/rule_A15_1_1.cc index 0cfd9fb5d1..efc62c6896 100644 --- a/autosar/rule_A15_1_1/libtooling/rule_A15_1_1.cc +++ b/autosar/rule_A15_1_1/libtooling/rule_A15_1_1.cc @@ -48,7 +48,7 @@ int rule_A15_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_1_3/libtooling/checker.cc b/autosar/rule_A15_1_3/libtooling/checker.cc index db04e882b2..4b6acb47f0 100644 --- a/autosar/rule_A15_1_3/libtooling/checker.cc +++ b/autosar/rule_A15_1_3/libtooling/checker.cc @@ -33,11 +33,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "All thrown exceptions should be unique."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "All thrown exceptions should be unique."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -48,10 +47,9 @@ namespace autosar { namespace rule_A15_1_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -61,19 +59,18 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXConstructExpr* exception_construct_expr = result.Nodes.getNodeAs("exception_construct_expr"); - const std::string exception = - misra::libtooling_utils::GetTokenFromSourceLoc( - result.SourceManager, exception_construct_expr->getBeginLoc(), - exception_construct_expr->getEndLoc()); + const string exception = misra::libtooling_utils::GetTokenFromSourceLoc( + result.SourceManager, exception_construct_expr->getBeginLoc(), + exception_construct_expr->getEndLoc()); if (exception_set.insert(exception).second) { return; } else { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( exception_construct_expr, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( exception_construct_expr, result.SourceManager); @@ -83,11 +80,11 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - std::set exception_set; - analyzer::proto::ResultsList* results_list_; + std::set exception_set; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_1_3/libtooling/rule_A15_1_3.cc b/autosar/rule_A15_1_3/libtooling/rule_A15_1_3.cc index 8334152cb5..92a4963fba 100644 --- a/autosar/rule_A15_1_3/libtooling/rule_A15_1_3.cc +++ b/autosar/rule_A15_1_3/libtooling/rule_A15_1_3.cc @@ -48,7 +48,7 @@ int rule_A15_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_2_1/libtooling/checker.cc b/autosar/rule_A15_2_1/libtooling/checker.cc index d0cc784ae7..fb53ca10fb 100644 --- a/autosar/rule_A15_2_1/libtooling/checker.cc +++ b/autosar/rule_A15_2_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Constructors that are not noexcept shall not be invoked before program startup."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -70,10 +69,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_2_1/libtooling/rule_A15_2_1.cc b/autosar/rule_A15_2_1/libtooling/rule_A15_2_1.cc index 0ea855b5d7..37b9e1972e 100644 --- a/autosar/rule_A15_2_1/libtooling/rule_A15_2_1.cc +++ b/autosar/rule_A15_2_1/libtooling/rule_A15_2_1.cc @@ -48,7 +48,7 @@ int rule_A15_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_4_1/libtooling/checker.cc b/autosar/rule_A15_4_1/libtooling/checker.cc index 1df5868ab3..371c2efd5b 100644 --- a/autosar/rule_A15_4_1/libtooling/checker.cc +++ b/autosar/rule_A15_4_1/libtooling/checker.cc @@ -31,12 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = - "Dynamic exception-specification shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "Dynamic exception-specification shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +45,9 @@ namespace autosar { namespace rule_A15_4_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(hasDynamicExceptionSpec(), unless(isExpansionInSystemHeader())) @@ -58,7 +55,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); if (fd) ReportError( @@ -68,10 +65,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_4_1/libtooling/rule_A15_4_1.cc b/autosar/rule_A15_4_1/libtooling/rule_A15_4_1.cc index f9095d944c..89ebac3d82 100644 --- a/autosar/rule_A15_4_1/libtooling/rule_A15_4_1.cc +++ b/autosar/rule_A15_4_1/libtooling/rule_A15_4_1.cc @@ -48,7 +48,7 @@ int rule_A15_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_4_4/libtooling/checker.cc b/autosar/rule_A15_4_4/libtooling/checker.cc index 58d85a1ebf..2a9f4584f3 100644 --- a/autosar/rule_A15_4_4/libtooling/checker.cc +++ b/autosar/rule_A15_4_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A declaration of non-throwing function shall contain noexcept specification."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -84,10 +83,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_4_4/libtooling/rule_A15_4_4.cc b/autosar/rule_A15_4_4/libtooling/rule_A15_4_4.cc index babfc1c475..9e11169226 100644 --- a/autosar/rule_A15_4_4/libtooling/rule_A15_4_4.cc +++ b/autosar/rule_A15_4_4/libtooling/rule_A15_4_4.cc @@ -48,7 +48,7 @@ int rule_A15_4_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_4_5/libtooling/checker.cc b/autosar/rule_A15_4_5/libtooling/checker.cc index 141b781a21..2cf86d2a35 100644 --- a/autosar/rule_A15_4_5/libtooling/checker.cc +++ b/autosar/rule_A15_4_5/libtooling/checker.cc @@ -34,12 +34,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Checked exceptions that could be thrown from a function shall be specified together with the function declaration and they shall be identical in all function declarations and for all its overriders."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -64,10 +63,9 @@ struct Info { unordered_map exception_map; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl( @@ -83,7 +81,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); string path = misra::libtooling_utils::GetFilename(fd, result.SourceManager); @@ -120,10 +118,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); @@ -144,13 +142,13 @@ void CheckCommentConsumer::HandleTranslationUnit(clang::ASTContext& context) { if (line->empty()) continue; string throw_str = "@throw "; size_t throw_pos = line->find(throw_str); - if (throw_pos != std::string::npos) { + if (throw_pos != string::npos) { size_t name_start = throw_pos + throw_str.length(); size_t name_end = line->find_first_of(" \t", name_start + 1); - if (name_end == std::string::npos) { + if (name_end == string::npos) { name_end = line->size(); } - std::string name = line->substr(name_start, name_end - name_start); + string name = line->substr(name_start, name_end - name_start); clang::SourceLocation loc = context.getSourceManager().getSpellingLoc(comment->getBeginLoc()); string path = context.getSourceManager().getFilename(loc).str(); diff --git a/autosar/rule_A15_4_5/libtooling/rule_A15_4_5.cc b/autosar/rule_A15_4_5/libtooling/rule_A15_4_5.cc index fc68c1069e..103402dfaf 100644 --- a/autosar/rule_A15_4_5/libtooling/rule_A15_4_5.cc +++ b/autosar/rule_A15_4_5/libtooling/rule_A15_4_5.cc @@ -48,7 +48,7 @@ int rule_A15_4_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A15_5_1/libtooling/checker.cc b/autosar/rule_A15_5_1/libtooling/checker.cc index a1a0ab61ac..221b87a9b9 100644 --- a/autosar/rule_A15_5_1/libtooling/checker.cc +++ b/autosar/rule_A15_5_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "All user-provided class destructors, deallocation functions, move constructors, move assignment operators and swap functions shall not exit with an exception. A noexcept exception specification shall be added to these functions as appropriate."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A15_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -59,10 +57,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* decl = result.Nodes.getNodeAs("main_function"); - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -70,10 +68,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A15_5_1/libtooling/rule_A15_5_1.cc b/autosar/rule_A15_5_1/libtooling/rule_A15_5_1.cc index c931e6c44c..cc2fac43e3 100644 --- a/autosar/rule_A15_5_1/libtooling/rule_A15_5_1.cc +++ b/autosar/rule_A15_5_1/libtooling/rule_A15_5_1.cc @@ -48,7 +48,7 @@ int rule_A15_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A17_6_1/libtooling/checker.cc b/autosar/rule_A17_6_1/libtooling/checker.cc index 51d8222251..7ae7a477c4 100644 --- a/autosar/rule_A17_6_1/libtooling/checker.cc +++ b/autosar/rule_A17_6_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Non-standard entities shall not be added to standard namespaces."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -103,10 +102,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A17_6_1/libtooling/rule_A17_6_1.cc b/autosar/rule_A17_6_1/libtooling/rule_A17_6_1.cc index bd9d5132ca..84b5e86faa 100644 --- a/autosar/rule_A17_6_1/libtooling/rule_A17_6_1.cc +++ b/autosar/rule_A17_6_1/libtooling/rule_A17_6_1.cc @@ -48,7 +48,7 @@ int rule_A17_6_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_0_2/libtooling/checker.cc b/autosar/rule_A18_0_2/libtooling/checker.cc index 46715aa15f..2dced75f7b 100644 --- a/autosar/rule_A18_0_2/libtooling/checker.cc +++ b/autosar/rule_A18_0_2/libtooling/checker.cc @@ -34,12 +34,11 @@ static bool isUsingStd = false; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The error state of a conversion from string to a numeric value shall be checked."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -49,7 +48,7 @@ void ReportError(const std::string& path, int line_number, // This checker tries to match the covertion from a string to a number by using // operator >> and stream: // std::istream cin; -// std::stringstream ss; +// stringstream ss; // int num; // cin >> num; ss >> num; @@ -64,8 +63,7 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; clang::ast_matchers::internal::BindableMatcher dre = declRefExpr(to(varDecl(anyOf(hasType(asString("std::istream")), @@ -83,10 +81,10 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXOperatorCallExpr* ce = result.Nodes.getNodeAs("ce"); - std::string path = + string path = misra::libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(ce, result.SourceManager); @@ -94,10 +92,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_0_2/libtooling/rule_A18_0_2.cc b/autosar/rule_A18_0_2/libtooling/rule_A18_0_2.cc index 9b5d57cebc..c80b5cdb66 100644 --- a/autosar/rule_A18_0_2/libtooling/rule_A18_0_2.cc +++ b/autosar/rule_A18_0_2/libtooling/rule_A18_0_2.cc @@ -48,7 +48,7 @@ int rule_A18_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_1_1/libtooling/checker.cc b/autosar/rule_A18_1_1/libtooling/checker.cc index d0a2dc9c5c..481fac3556 100644 --- a/autosar/rule_A18_1_1/libtooling/checker.cc +++ b/autosar/rule_A18_1_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "C-style arrays shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "C-style arrays shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A18_1_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(hasType(arrayType()), unless(isExpansionInSystemHeader())) @@ -65,7 +63,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* d = result.Nodes.getNodeAs("c_array"); const VarDecl* vd = result.Nodes.getNodeAs("c_array_vd"); if (d) { @@ -82,10 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_1_1/libtooling/rule_A18_1_1.cc b/autosar/rule_A18_1_1/libtooling/rule_A18_1_1.cc index db1766c0eb..5e83931537 100644 --- a/autosar/rule_A18_1_1/libtooling/rule_A18_1_1.cc +++ b/autosar/rule_A18_1_1/libtooling/rule_A18_1_1.cc @@ -48,7 +48,7 @@ int rule_A18_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_1_2/libtooling/checker.cc b/autosar/rule_A18_1_2/libtooling/checker.cc index f604cf5936..3b3b77a21d 100644 --- a/autosar/rule_A18_1_2/libtooling/checker.cc +++ b/autosar/rule_A18_1_2/libtooling/checker.cc @@ -35,12 +35,11 @@ static bool isUsingStd = false; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The std::vector specialization shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -53,17 +52,16 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( valueDecl(unless(isExpansionInSystemHeader())).bind("vd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ValueDecl* vd = result.Nodes.getNodeAs("vd"); if (vd) { - std::string str = TypeName::getFullyQualifiedName( + string str = TypeName::getFullyQualifiedName( vd->getType(), *result.Context, PrintingPolicy(result.Context->getLangOpts()), true); if (str.find("std::vector") != string::npos) { @@ -76,10 +74,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_1_2/libtooling/rule_A18_1_2.cc b/autosar/rule_A18_1_2/libtooling/rule_A18_1_2.cc index b41f9b19fd..952b202577 100644 --- a/autosar/rule_A18_1_2/libtooling/rule_A18_1_2.cc +++ b/autosar/rule_A18_1_2/libtooling/rule_A18_1_2.cc @@ -48,7 +48,7 @@ int rule_A18_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_1_3/libtooling/checker.cc b/autosar/rule_A18_1_3/libtooling/checker.cc index b8d9d10952..b5748a93e2 100644 --- a/autosar/rule_A18_1_3/libtooling/checker.cc +++ b/autosar/rule_A18_1_3/libtooling/checker.cc @@ -35,11 +35,10 @@ static bool isUsingStd = false; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "The std::auto_ptr type shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "The std::auto_ptr type shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -52,17 +51,16 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( valueDecl(unless(isExpansionInSystemHeader())).bind("vd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ValueDecl* vd = result.Nodes.getNodeAs("vd"); if (vd) { - std::string str = TypeName::getFullyQualifiedName( + string str = TypeName::getFullyQualifiedName( vd->getType(), *result.Context, PrintingPolicy(result.Context->getLangOpts()), true); if (str.find("std::auto_ptr") != string::npos) { @@ -75,10 +73,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_1_3/libtooling/rule_A18_1_3.cc b/autosar/rule_A18_1_3/libtooling/rule_A18_1_3.cc index fe5d95308c..b05ff21591 100644 --- a/autosar/rule_A18_1_3/libtooling/rule_A18_1_3.cc +++ b/autosar/rule_A18_1_3/libtooling/rule_A18_1_3.cc @@ -48,7 +48,7 @@ int rule_A18_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_1_4/libtooling/checker.cc b/autosar/rule_A18_1_4/libtooling/checker.cc index d36ba428ef..a170c58d46 100644 --- a/autosar/rule_A18_1_4/libtooling/checker.cc +++ b/autosar/rule_A18_1_4/libtooling/checker.cc @@ -96,7 +96,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A18_1_4/libtooling/rule_A18_1_4.cc b/autosar/rule_A18_1_4/libtooling/rule_A18_1_4.cc index 173ffab00e..46a98f290a 100644 --- a/autosar/rule_A18_1_4/libtooling/rule_A18_1_4.cc +++ b/autosar/rule_A18_1_4/libtooling/rule_A18_1_4.cc @@ -48,7 +48,7 @@ int rule_A18_1_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_1_6/libtooling/checker.cc b/autosar/rule_A18_1_6/libtooling/checker.cc index d176072286..4a20aa25d8 100644 --- a/autosar/rule_A18_1_6/libtooling/checker.cc +++ b/autosar/rule_A18_1_6/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "All std::hash specializations for user-defined types shall have a noexcept function call operator."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A18_1_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( classTemplateSpecializationDecl( @@ -65,7 +63,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ClassTemplateSpecializationDecl* ctsd = result.Nodes.getNodeAs("ctsd"); if (ctsd && ctsd->isExplicitSpecialization()) { @@ -77,10 +75,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_1_6/libtooling/rule_A18_1_6.cc b/autosar/rule_A18_1_6/libtooling/rule_A18_1_6.cc index 6e48a8be74..e1ea689200 100644 --- a/autosar/rule_A18_1_6/libtooling/rule_A18_1_6.cc +++ b/autosar/rule_A18_1_6/libtooling/rule_A18_1_6.cc @@ -48,7 +48,7 @@ int rule_A18_1_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_5_1/libtooling/checker.cc b/autosar/rule_A18_5_1/libtooling/checker.cc index 853316dfe6..c75dcfe01a 100644 --- a/autosar/rule_A18_5_1/libtooling/checker.cc +++ b/autosar/rule_A18_5_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Functions malloc, calloc, realloc and free shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A18_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr( @@ -61,7 +59,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* f = result.Nodes.getNodeAs("f"); if (f) { ReportError(misra::libtooling_utils::GetFilename(f, result.SourceManager), @@ -71,10 +69,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_5_1/libtooling/rule_A18_5_1.cc b/autosar/rule_A18_5_1/libtooling/rule_A18_5_1.cc index b024c559fd..0b7680aae6 100644 --- a/autosar/rule_A18_5_1/libtooling/rule_A18_5_1.cc +++ b/autosar/rule_A18_5_1/libtooling/rule_A18_5_1.cc @@ -48,7 +48,7 @@ int rule_A18_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_5_11/libtooling/checker.cc b/autosar/rule_A18_5_11/libtooling/checker.cc index 6109f3d37b..43fbe11c2a 100644 --- a/autosar/rule_A18_5_11/libtooling/checker.cc +++ b/autosar/rule_A18_5_11/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "“operator new” and “operator delete” shall be defined together."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A18_5_11 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; global_check_done_ = false; @@ -69,7 +67,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { bool has_new = false; bool has_delete = false; bool has_array_new = false; @@ -126,7 +124,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if ((!has_new && has_delete) || (has_new && !has_delete)) { for (auto new_or_delete_decl : new_or_delete_decls) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( new_or_delete_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( new_or_delete_decl, result.SourceManager); @@ -136,7 +134,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if ((!has_array_new && has_array_delete) || (has_array_new && !has_array_delete)) { for (auto array_new_or_delete_decl : array_new_or_delete_decls) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( array_new_or_delete_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( array_new_or_delete_decl, result.SourceManager); @@ -146,11 +144,11 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool global_check_done_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_5_11/libtooling/rule_A18_5_11.cc b/autosar/rule_A18_5_11/libtooling/rule_A18_5_11.cc index 807a557c29..a130d2dc49 100644 --- a/autosar/rule_A18_5_11/libtooling/rule_A18_5_11.cc +++ b/autosar/rule_A18_5_11/libtooling/rule_A18_5_11.cc @@ -48,7 +48,7 @@ int rule_A18_5_11(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_5_4/libtooling/checker.cc b/autosar/rule_A18_5_4/libtooling/checker.cc index 8b66f78b48..ea8924a757 100644 --- a/autosar/rule_A18_5_4/libtooling/checker.cc +++ b/autosar/rule_A18_5_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string path, int line_number, +void ReportError(const string path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "If a project has sized or unsized versionof operator “delete” globally defined, then both sized and unsized versions shall be defined."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -138,12 +137,12 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map> decl_unsized_storage_; unordered_map> decl_sized_storage_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_5_4/libtooling/rule_A18_5_4.cc b/autosar/rule_A18_5_4/libtooling/rule_A18_5_4.cc index 62388911e0..d3e23a0f0b 100644 --- a/autosar/rule_A18_5_4/libtooling/rule_A18_5_4.cc +++ b/autosar/rule_A18_5_4/libtooling/rule_A18_5_4.cc @@ -49,7 +49,7 @@ int rule_A18_5_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_5_9/libtooling/rule_A18_5_9.cc b/autosar/rule_A18_5_9/libtooling/rule_A18_5_9.cc index f09e928746..fce0028dd9 100644 --- a/autosar/rule_A18_5_9/libtooling/rule_A18_5_9.cc +++ b/autosar/rule_A18_5_9/libtooling/rule_A18_5_9.cc @@ -48,7 +48,7 @@ int rule_A18_5_9(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_9_1/libtooling/checker.cc b/autosar/rule_A18_9_1/libtooling/checker.cc index a2b02de87a..e70f0d8ba3 100644 --- a/autosar/rule_A18_9_1/libtooling/checker.cc +++ b/autosar/rule_A18_9_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "The std::bind shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "The std::bind shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,17 +45,16 @@ namespace autosar { namespace rule_A18_9_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr(callee(functionDecl(hasName("::std::bind")))).bind("bind"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* bind = result.Nodes.getNodeAs("bind"); if (bind) { ReportError( @@ -67,10 +65,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_9_1/libtooling/rule_A18_9_1.cc b/autosar/rule_A18_9_1/libtooling/rule_A18_9_1.cc index 59dd89f7da..f86ef8c801 100644 --- a/autosar/rule_A18_9_1/libtooling/rule_A18_9_1.cc +++ b/autosar/rule_A18_9_1/libtooling/rule_A18_9_1.cc @@ -48,7 +48,7 @@ int rule_A18_9_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_9_2/libtooling/rule_A18_9_2.cc b/autosar/rule_A18_9_2/libtooling/rule_A18_9_2.cc index 3a87a8127a..a580fcccc9 100644 --- a/autosar/rule_A18_9_2/libtooling/rule_A18_9_2.cc +++ b/autosar/rule_A18_9_2/libtooling/rule_A18_9_2.cc @@ -48,7 +48,7 @@ int rule_A18_9_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_9_3/libtooling/checker.cc b/autosar/rule_A18_9_3/libtooling/checker.cc index fdc319adc6..5c99dcd538 100644 --- a/autosar/rule_A18_9_3/libtooling/checker.cc +++ b/autosar/rule_A18_9_3/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The std::move shall not be used on objects declared const or const&."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A18_9_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr(callee(functionDecl(matchesName("std::move"), @@ -62,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CallExpr* ce = result.Nodes.getNodeAs("ce"); if (ce) ReportError( @@ -72,10 +70,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_9_3/libtooling/rule_A18_9_3.cc b/autosar/rule_A18_9_3/libtooling/rule_A18_9_3.cc index 89f34e1e88..a2eec43d6e 100644 --- a/autosar/rule_A18_9_3/libtooling/rule_A18_9_3.cc +++ b/autosar/rule_A18_9_3/libtooling/rule_A18_9_3.cc @@ -48,7 +48,7 @@ int rule_A18_9_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A18_9_4/libtooling/checker.cc b/autosar/rule_A18_9_4/libtooling/checker.cc index 24d128d9d0..0ccacf28ac 100644 --- a/autosar/rule_A18_9_4/libtooling/checker.cc +++ b/autosar/rule_A18_9_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "An argument to std::forward shall not be subsequently used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A18_9_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr( @@ -90,7 +88,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool ContainsDecl(const Stmt* stmt, const Decl* decl) { if (!stmt) { return false; @@ -107,7 +105,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A18_9_4/libtooling/rule_A18_9_4.cc b/autosar/rule_A18_9_4/libtooling/rule_A18_9_4.cc index 49bb0c88ab..efc4908377 100644 --- a/autosar/rule_A18_9_4/libtooling/rule_A18_9_4.cc +++ b/autosar/rule_A18_9_4/libtooling/rule_A18_9_4.cc @@ -48,7 +48,7 @@ int rule_A18_9_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A1_1_1/libtooling/checker.cc b/autosar/rule_A1_1_1/libtooling/checker.cc index 4a39d313b4..fc8a3c65e0 100644 --- a/autosar/rule_A1_1_1/libtooling/checker.cc +++ b/autosar/rule_A1_1_1/libtooling/checker.cc @@ -35,8 +35,7 @@ void ReportError(const std::string& path, int line_number, ResultsList* results_list) { std::string error_message = "All code shall conform to ISO/IEC 14882:2014 - Programming Language C++ and shall not use deprecated features."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -64,9 +63,7 @@ void Checker::HandleDiagnostic(DiagnosticsEngine::Level level, } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { - results_list_ = result_list; -} +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; } } // namespace libtooling } // namespace rule_A1_1_1 diff --git a/autosar/rule_A1_1_1/libtooling/rule_A1_1_1.cc b/autosar/rule_A1_1_1/libtooling/rule_A1_1_1.cc index 1e81044879..bbe4b3c606 100644 --- a/autosar/rule_A1_1_1/libtooling/rule_A1_1_1.cc +++ b/autosar/rule_A1_1_1/libtooling/rule_A1_1_1.cc @@ -49,7 +49,7 @@ int rule_A1_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_1/libtooling/rule_A20_8_1.cc b/autosar/rule_A20_8_1/libtooling/rule_A20_8_1.cc index aaf03d06c8..ef103c16bb 100644 --- a/autosar/rule_A20_8_1/libtooling/rule_A20_8_1.cc +++ b/autosar/rule_A20_8_1/libtooling/rule_A20_8_1.cc @@ -48,7 +48,7 @@ int rule_A20_8_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_2/libtooling/checker.cc b/autosar/rule_A20_8_2/libtooling/checker.cc index 46f205d5d0..d26b45762b 100644 --- a/autosar/rule_A20_8_2/libtooling/checker.cc +++ b/autosar/rule_A20_8_2/libtooling/checker.cc @@ -46,7 +46,7 @@ namespace rule_A20_8_2 { namespace libtooling { struct Loc { - const std::string Path; + const string Path; const int LineNumber; }; @@ -136,7 +136,7 @@ class Callback : public MatchFinder::MatchCallback { std::unordered_map pointer_map_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A20_8_2/libtooling/rule_A20_8_2.cc b/autosar/rule_A20_8_2/libtooling/rule_A20_8_2.cc index 5ad2ee2cf7..cc7c82d7a4 100644 --- a/autosar/rule_A20_8_2/libtooling/rule_A20_8_2.cc +++ b/autosar/rule_A20_8_2/libtooling/rule_A20_8_2.cc @@ -48,7 +48,7 @@ int rule_A20_8_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_3/libtooling/checker.cc b/autosar/rule_A20_8_3/libtooling/checker.cc index b3cd3c0847..2337576059 100644 --- a/autosar/rule_A20_8_3/libtooling/checker.cc +++ b/autosar/rule_A20_8_3/libtooling/checker.cc @@ -37,7 +37,7 @@ void ReportError(string path, int line_number, string previous_loc, string loc, ResultsList* results_list) { string error_message = "A std::shared_ptr shall be used to represent shared ownership."; - std::vector locations{previous_loc, loc}; + std::vector locations{previous_loc, loc}; AddMultipleLocationsResultToResultsList(results_list, path, line_number, error_message, locations); } @@ -89,7 +89,7 @@ class Callback : public MatchFinder::MatchCallback { private: ResultsList* results_list_; - std::unordered_map pointer_map_; + std::unordered_map pointer_map_; }; void Checker::Init(ResultsList* result_list) { diff --git a/autosar/rule_A20_8_3/libtooling/rule_A20_8_3.cc b/autosar/rule_A20_8_3/libtooling/rule_A20_8_3.cc index 333c57ef1a..d92fed32fe 100644 --- a/autosar/rule_A20_8_3/libtooling/rule_A20_8_3.cc +++ b/autosar/rule_A20_8_3/libtooling/rule_A20_8_3.cc @@ -48,7 +48,7 @@ int rule_A20_8_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_4/libtooling/checker.cc b/autosar/rule_A20_8_4/libtooling/checker.cc index 43cea94fd9..60f588afd8 100644 --- a/autosar/rule_A20_8_4/libtooling/checker.cc +++ b/autosar/rule_A20_8_4/libtooling/checker.cc @@ -46,7 +46,7 @@ namespace rule_A20_8_4 { namespace libtooling { struct Loc { - const std::string Path; + const string Path; const int LineNumber; }; @@ -128,7 +128,7 @@ class Callback : public MatchFinder::MatchCallback { std::unordered_map pointer_map_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A20_8_4/libtooling/rule_A20_8_4.cc b/autosar/rule_A20_8_4/libtooling/rule_A20_8_4.cc index 8518b5a42c..599e152d03 100644 --- a/autosar/rule_A20_8_4/libtooling/rule_A20_8_4.cc +++ b/autosar/rule_A20_8_4/libtooling/rule_A20_8_4.cc @@ -48,7 +48,7 @@ int rule_A20_8_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_5/libtooling/checker.cc b/autosar/rule_A20_8_5/libtooling/checker.cc index 5be44efb66..7113b3ba88 100644 --- a/autosar/rule_A20_8_5/libtooling/checker.cc +++ b/autosar/rule_A20_8_5/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "std::make_unique shall be used to construct objects owned by std::unique_ptr."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A20_8_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxConstructExpr( @@ -62,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXConstructExpr* cce = result.Nodes.getNodeAs("cce"); if (cce && cce->getNumArgs() != 2) { @@ -76,10 +74,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A20_8_5/libtooling/rule_A20_8_5.cc b/autosar/rule_A20_8_5/libtooling/rule_A20_8_5.cc index c54b1cdaa7..bd97dca7d4 100644 --- a/autosar/rule_A20_8_5/libtooling/rule_A20_8_5.cc +++ b/autosar/rule_A20_8_5/libtooling/rule_A20_8_5.cc @@ -48,7 +48,7 @@ int rule_A20_8_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A20_8_6/libtooling/checker.cc b/autosar/rule_A20_8_6/libtooling/checker.cc index 167fef6d8a..0ae3e55c67 100644 --- a/autosar/rule_A20_8_6/libtooling/checker.cc +++ b/autosar/rule_A20_8_6/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "std::make_shared shall be used to construct objects owned by std::shared_ptr."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A20_8_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxConstructExpr( @@ -62,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXConstructExpr* cce = result.Nodes.getNodeAs("cce"); if (cce && cce->getNumArgs() != 2) { @@ -76,10 +74,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A20_8_6/libtooling/rule_A20_8_6.cc b/autosar/rule_A20_8_6/libtooling/rule_A20_8_6.cc index dd2cb70f94..ccae63d00e 100644 --- a/autosar/rule_A20_8_6/libtooling/rule_A20_8_6.cc +++ b/autosar/rule_A20_8_6/libtooling/rule_A20_8_6.cc @@ -48,7 +48,7 @@ int rule_A20_8_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A21_8_1/libtooling/checker.cc b/autosar/rule_A21_8_1/libtooling/checker.cc index 95a147e559..79628a373e 100644 --- a/autosar/rule_A21_8_1/libtooling/checker.cc +++ b/autosar/rule_A21_8_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Arguments to character-handling functions shall be representable as an unsigned char."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A21_8_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( callExpr(callee(functionDecl( @@ -65,7 +63,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CallExpr* ce = result.Nodes.getNodeAs("ce"); const Expr* arg = result.Nodes.getNodeAs("arg"); if (ce) { @@ -80,10 +78,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A21_8_1/libtooling/rule_A21_8_1.cc b/autosar/rule_A21_8_1/libtooling/rule_A21_8_1.cc index a810edc9d6..f22a4da569 100644 --- a/autosar/rule_A21_8_1/libtooling/rule_A21_8_1.cc +++ b/autosar/rule_A21_8_1/libtooling/rule_A21_8_1.cc @@ -48,7 +48,7 @@ int rule_A21_8_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A23_0_1/libtooling/checker.cc b/autosar/rule_A23_0_1/libtooling/checker.cc index 8899d39971..ff896b0480 100644 --- a/autosar/rule_A23_0_1/libtooling/checker.cc +++ b/autosar/rule_A23_0_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "An iterator shall not be implicitly converted to const_iterator."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A23_0_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( valueDecl( @@ -63,7 +61,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ValueDecl* vd = result.Nodes.getNodeAs("vd"); if (vd) { ReportError( @@ -74,10 +72,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A23_0_1/libtooling/rule_A23_0_1.cc b/autosar/rule_A23_0_1/libtooling/rule_A23_0_1.cc index fef6557e31..8a783db62b 100644 --- a/autosar/rule_A23_0_1/libtooling/rule_A23_0_1.cc +++ b/autosar/rule_A23_0_1/libtooling/rule_A23_0_1.cc @@ -48,7 +48,7 @@ int rule_A23_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A25_1_1/libtooling/checker.cc b/autosar/rule_A25_1_1/libtooling/checker.cc index 1ae06ea087..65c46f9da7 100644 --- a/autosar/rule_A25_1_1/libtooling/checker.cc +++ b/autosar/rule_A25_1_1/libtooling/checker.cc @@ -33,12 +33,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Non-static data members or captured values of predicate function objects that are state related to this object's identity shall not be copied."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -51,8 +50,7 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; BindableMatcher pred = parmVarDecl(hasName("__pred")); Matcher non_const_parm = @@ -101,10 +99,10 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Stmt* op = result.Nodes.getNodeAs("op"); if (op != nullptr) { - std::string path = + string path = misra::libtooling_utils::GetFilename(op, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(op, result.SourceManager); @@ -112,15 +110,15 @@ class Callback : public MatchFinder::MatchCallback { } const Decl* non_const_parm = result.Nodes.getNodeAs("non_const_parm"); if (non_const_parm != nullptr) { - std::string path = misra::libtooling_utils::GetFilename( - non_const_parm, result.SourceManager); + string path = misra::libtooling_utils::GetFilename(non_const_parm, + result.SourceManager); int line_number = misra::libtooling_utils::GetLine(non_const_parm, result.SourceManager); ReportError(path, line_number, results_list_); } const CallExpr* ce = result.Nodes.getNodeAs("ce"); if (ce != nullptr) { - std::string path = + string path = misra::libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(ce, result.SourceManager); @@ -129,10 +127,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A25_1_1/libtooling/rule_A25_1_1.cc b/autosar/rule_A25_1_1/libtooling/rule_A25_1_1.cc index 79c05c7188..c1c13603e3 100644 --- a/autosar/rule_A25_1_1/libtooling/rule_A25_1_1.cc +++ b/autosar/rule_A25_1_1/libtooling/rule_A25_1_1.cc @@ -48,7 +48,7 @@ int rule_A25_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A26_5_1/libtooling/checker.cc b/autosar/rule_A26_5_1/libtooling/checker.cc index d70db5750f..2e5dc194cc 100644 --- a/autosar/rule_A26_5_1/libtooling/checker.cc +++ b/autosar/rule_A26_5_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Pseudorandom numbers shall not be generated using std::rand()."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A26_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( declRefExpr(hasDeclaration( @@ -60,7 +58,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const DeclRefExpr* dre = result.Nodes.getNodeAs("dre"); const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); if (dre && fd) { @@ -76,10 +74,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A26_5_1/libtooling/rule_A26_5_1.cc b/autosar/rule_A26_5_1/libtooling/rule_A26_5_1.cc index a4e00da493..dbac04c128 100644 --- a/autosar/rule_A26_5_1/libtooling/rule_A26_5_1.cc +++ b/autosar/rule_A26_5_1/libtooling/rule_A26_5_1.cc @@ -48,7 +48,7 @@ int rule_A26_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A26_5_2/libtooling/checker.cc b/autosar/rule_A26_5_2/libtooling/checker.cc index 085eb2e723..9ed78685b9 100644 --- a/autosar/rule_A26_5_2/libtooling/checker.cc +++ b/autosar/rule_A26_5_2/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { string error_message = "Random number engines shall not be default-initialized."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ void ReportError(const std::string& path, int line_number, namespace autosar { namespace rule_A26_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl(unless(isExpansionInSystemHeader()), has(cxxConstructExpr().bind("ce"))) @@ -58,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* vd = result.Nodes.getNodeAs("vd"); const CXXConstructExpr* ce = result.Nodes.getNodeAs("ce"); @@ -82,10 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A26_5_2/libtooling/rule_A26_5_2.cc b/autosar/rule_A26_5_2/libtooling/rule_A26_5_2.cc index a793052218..cc6e0917e5 100644 --- a/autosar/rule_A26_5_2/libtooling/rule_A26_5_2.cc +++ b/autosar/rule_A26_5_2/libtooling/rule_A26_5_2.cc @@ -48,7 +48,7 @@ int rule_A26_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A27_0_2/libtooling/checker.cc b/autosar/rule_A27_0_2/libtooling/checker.cc index 79617f5a7b..653888f957 100644 --- a/autosar/rule_A27_0_2/libtooling/checker.cc +++ b/autosar/rule_A27_0_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A C-style string shall guarantee sufficient space for data and the null terminator."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -53,10 +52,9 @@ unordered_set dangerous_func_set = {"memcpy", "bcopy", "strcpy", "strncpy", "strcat", "strncat", "memmove", "memcmp", "memset"}; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; Matcher c_string_var = @@ -76,7 +74,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher( cxxConstructExpr( hasDescendant(c_string_ref), - // filter cases like std::string str(buffer, in.gcount()); + // filter cases like string str(buffer, in.gcount()); unless(hasDescendant(declRefExpr(unless(to(c_string_var)))))), this); // to match functions like strcpy(...); @@ -161,7 +159,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const DeclRefExpr* decl_ref = result.Nodes.getNodeAs("decl_ref"); string path = @@ -182,10 +180,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A27_0_2/libtooling/rule_A27_0_2.cc b/autosar/rule_A27_0_2/libtooling/rule_A27_0_2.cc index ab3898e1b2..70312ed9d9 100644 --- a/autosar/rule_A27_0_2/libtooling/rule_A27_0_2.cc +++ b/autosar/rule_A27_0_2/libtooling/rule_A27_0_2.cc @@ -48,7 +48,7 @@ int rule_A27_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A27_0_3/libtooling/checker.cc b/autosar/rule_A27_0_3/libtooling/checker.cc index e522296306..743840480a 100644 --- a/autosar/rule_A27_0_3/libtooling/checker.cc +++ b/autosar/rule_A27_0_3/libtooling/checker.cc @@ -53,12 +53,11 @@ typedef std::priority_queue, Compare> namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Alternate input and output operations on a file stream shall not be used without an intervening flush or position call."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -71,8 +70,7 @@ namespace libtooling { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; clang::ast_matchers::internal::BindableMatcher fstream = declRefExpr( @@ -126,7 +124,7 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* fstream = result.Nodes.getNodeAs("fstream"); const VarDecl* ptr_FILE = result.Nodes.getNodeAs("ptr_FILE"); int64_t id; @@ -140,7 +138,7 @@ class Callback : public MatchFinder::MatchCallback { } const Stmt* ostream = result.Nodes.getNodeAs("ostream"); if (ostream != nullptr) { - std::string path = + string path = misra::libtooling_utils::GetFilename(ostream, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(ostream, result.SourceManager); @@ -149,7 +147,7 @@ class Callback : public MatchFinder::MatchCallback { } const Stmt* istream = result.Nodes.getNodeAs("istream"); if (istream != nullptr) { - std::string path = + string path = misra::libtooling_utils::GetFilename(istream, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(istream, result.SourceManager); @@ -158,7 +156,7 @@ class Callback : public MatchFinder::MatchCallback { } const Stmt* position = result.Nodes.getNodeAs("position"); if (position != nullptr) { - std::string path = + string path = misra::libtooling_utils::GetFilename(position, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(position, result.SourceManager); @@ -188,11 +186,11 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::unordered_map stream_map_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A27_0_3/libtooling/rule_A27_0_3.cc b/autosar/rule_A27_0_3/libtooling/rule_A27_0_3.cc index eff81e0b69..cd0cf47874 100644 --- a/autosar/rule_A27_0_3/libtooling/rule_A27_0_3.cc +++ b/autosar/rule_A27_0_3/libtooling/rule_A27_0_3.cc @@ -48,7 +48,7 @@ int rule_A27_0_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A27_0_4/libtooling/checker.cc b/autosar/rule_A27_0_4/libtooling/checker.cc index 2af94d4cee..49c17f1372 100644 --- a/autosar/rule_A27_0_4/libtooling/checker.cc +++ b/autosar/rule_A27_0_4/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "C-style string shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "C-style string shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A27_0_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(hasType(arrayType(hasElementType(isAnyCharacter()))), @@ -58,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); const InitListExpr* list = result.Nodes.getNodeAs("list"); if (misra::libtooling_utils::IsInSystemHeader(var_decl, result.Context)) { @@ -72,7 +70,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (isa(last_element) || (isa(last_element) && cast(last_element)->getValue() == 0)) { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( var_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(var_decl, result.SourceManager); @@ -82,10 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A27_0_4/libtooling/rule_A27_0_4.cc b/autosar/rule_A27_0_4/libtooling/rule_A27_0_4.cc index b82fb7aef4..8af0af1266 100644 --- a/autosar/rule_A27_0_4/libtooling/rule_A27_0_4.cc +++ b/autosar/rule_A27_0_4/libtooling/rule_A27_0_4.cc @@ -48,7 +48,7 @@ int rule_A27_0_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A2_10_4/libtooling/checker.cc b/autosar/rule_A2_10_4/libtooling/checker.cc index efa119d361..ee9580b604 100644 --- a/autosar/rule_A2_10_4/libtooling/checker.cc +++ b/autosar/rule_A2_10_4/libtooling/checker.cc @@ -121,7 +121,7 @@ void Callback::Report() { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A2_10_4/libtooling/rule_A2_10_4.cc b/autosar/rule_A2_10_4/libtooling/rule_A2_10_4.cc index 80ea591ead..260bf851de 100644 --- a/autosar/rule_A2_10_4/libtooling/rule_A2_10_4.cc +++ b/autosar/rule_A2_10_4/libtooling/rule_A2_10_4.cc @@ -47,13 +47,13 @@ int rule_A2_10_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A2_10_6/libtooling/rule_A2_10_6.cc b/autosar/rule_A2_10_6/libtooling/rule_A2_10_6.cc index 453c94dc99..648d94d99b 100644 --- a/autosar/rule_A2_10_6/libtooling/rule_A2_10_6.cc +++ b/autosar/rule_A2_10_6/libtooling/rule_A2_10_6.cc @@ -47,7 +47,7 @@ int rule_A2_10_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A2_11_1/libtooling/checker.cc b/autosar/rule_A2_11_1/libtooling/checker.cc index f936f67307..e42b2468da 100644 --- a/autosar/rule_A2_11_1/libtooling/checker.cc +++ b/autosar/rule_A2_11_1/libtooling/checker.cc @@ -32,8 +32,7 @@ using std::string; namespace { void ReportError(string path, int line_number, ResultsList* results_list_) { - std::string error_message = - absl::StrFormat("Volatile keyword shall not be used."); + string error_message = absl::StrFormat("Volatile keyword shall not be used."); analyzer::proto::Result* pb_result = AddResultToResultsList(results_list_, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, @@ -46,10 +45,9 @@ namespace autosar { namespace rule_A2_11_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -96,12 +94,12 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); if (misra::libtooling_utils::IsInSystemHeader(decl, result.Context)) { return; } - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -110,10 +108,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A2_11_1/libtooling/rule_A2_11_1.cc b/autosar/rule_A2_11_1/libtooling/rule_A2_11_1.cc index 8bb9443bb0..3176eeef58 100644 --- a/autosar/rule_A2_11_1/libtooling/rule_A2_11_1.cc +++ b/autosar/rule_A2_11_1/libtooling/rule_A2_11_1.cc @@ -48,7 +48,7 @@ int rule_A2_11_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A2_13_3/libtooling/checker.cc b/autosar/rule_A2_13_3/libtooling/checker.cc index e780314d15..ee08314e55 100644 --- a/autosar/rule_A2_13_3/libtooling/checker.cc +++ b/autosar/rule_A2_13_3/libtooling/checker.cc @@ -31,10 +31,10 @@ using std::string; namespace { -void ReportError(const Decl* decl, std::string error_message, - const ast_matchers::MatchFinder::MatchResult& result, +void ReportError(const Decl* decl, string error_message, + const MatchFinder::MatchResult& result, ResultsList* results_list_) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -45,10 +45,10 @@ void ReportError(const Decl* decl, std::string error_message, line_number); } -void ReportError(const Stmt* stmt, std::string error_message, - const ast_matchers::MatchFinder::MatchResult& result, +void ReportError(const Stmt* stmt, string error_message, + const MatchFinder::MatchResult& result, ResultsList* results_list_) { - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -72,10 +72,9 @@ auto isWideChar(const Type* type) -> bool { return type->isWideCharType(); } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(unless(isExpansionInSystemHeader())).bind("value_decl"), this); @@ -90,9 +89,8 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { - std::string error_message = - absl::StrFormat("Type wchar_t shall not be used."); + void run(const MatchFinder::MatchResult& result) { + string error_message = absl::StrFormat("Type wchar_t shall not be used."); const ValueDecl* value_decl = result.Nodes.getNodeAs("value_decl"); @@ -116,10 +114,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A2_13_3/libtooling/rule_A2_13_3.cc b/autosar/rule_A2_13_3/libtooling/rule_A2_13_3.cc index 2dcb18ee80..0afef8df56 100644 --- a/autosar/rule_A2_13_3/libtooling/rule_A2_13_3.cc +++ b/autosar/rule_A2_13_3/libtooling/rule_A2_13_3.cc @@ -48,7 +48,7 @@ int rule_A2_13_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A2_13_5/libtooling/checker.cc b/autosar/rule_A2_13_5/libtooling/checker.cc index 1fd53072a4..dc90f6b7ea 100644 --- a/autosar/rule_A2_13_5/libtooling/checker.cc +++ b/autosar/rule_A2_13_5/libtooling/checker.cc @@ -33,7 +33,7 @@ using std::string; namespace { void ReportError(string path, int line_number, ResultsList* results_list_) { - std::string error_message = + string error_message = absl::StrFormat("Hexadecimal constants should be upper case."); analyzer::proto::Result* pb_result = AddResultToResultsList(results_list_, path, line_number, error_message); @@ -51,16 +51,15 @@ auto isHexadecimal(StringRef num) -> bool { return num.startswith_insensitive("0x"); }; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( integerLiteral(unless(isExpansionInSystemHeader())).bind("lit"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Stmt* lit = result.Nodes.getNodeAs("lit"); clang::SourceRange range = @@ -77,7 +76,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { const int start_loc = 2; // length of "0x" for (int i = start_loc; i < source.size(); i++) { if (source[i] >= 'a' && source[i] <= 'f') { - std::string path = + string path = misra::libtooling_utils::GetFilename(lit, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(lit, result.SourceManager); @@ -90,10 +89,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A2_13_5/libtooling/rule_A2_13_5.cc b/autosar/rule_A2_13_5/libtooling/rule_A2_13_5.cc index 923f7667b6..eb64c4a222 100644 --- a/autosar/rule_A2_13_5/libtooling/rule_A2_13_5.cc +++ b/autosar/rule_A2_13_5/libtooling/rule_A2_13_5.cc @@ -48,7 +48,7 @@ int rule_A2_13_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A2_3_1/libtooling/checker.cc b/autosar/rule_A2_3_1/libtooling/checker.cc index c785349fe9..229ce72f46 100644 --- a/autosar/rule_A2_3_1/libtooling/checker.cc +++ b/autosar/rule_A2_3_1/libtooling/checker.cc @@ -49,10 +49,9 @@ namespace autosar { namespace rule_A2_3_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(unless(isExpansionInSystemHeader())).bind("value_decl"), this); @@ -70,7 +69,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const VarDecl* var_decl = result.Nodes.getNodeAs("value_decl"); if (var_decl && !misra::libtooling_utils::IsInSystemHeader(var_decl, result.Context)) { @@ -123,10 +122,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A2_3_1/libtooling/rule_A2_3_1.cc b/autosar/rule_A2_3_1/libtooling/rule_A2_3_1.cc index c128a94ad3..80ab1bdc6a 100644 --- a/autosar/rule_A2_3_1/libtooling/rule_A2_3_1.cc +++ b/autosar/rule_A2_3_1/libtooling/rule_A2_3_1.cc @@ -48,7 +48,7 @@ int rule_A2_3_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A2_7_1/libtooling/checker.cc b/autosar/rule_A2_7_1/libtooling/checker.cc index 10d7a0d4b1..e6b0088d88 100644 --- a/autosar/rule_A2_7_1/libtooling/checker.cc +++ b/autosar/rule_A2_7_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2023 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "autosar/rule_A2_7_1/libtooling/checker.h" @@ -65,8 +77,7 @@ void CheckCommentConsumer::ReportError(std::string path, int line_number, std::string error_message = "The character \\ shall not occur as a last character of a C++ comment."; analyzer::proto::Result* pb_result = - misra::proto_util::AddResultToResultsList(results_list_, path, - line_number, error_message); + AddResultToResultsList(results_list_, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/autosar/rule_A2_7_1/libtooling/checker.h b/autosar/rule_A2_7_1/libtooling/checker.h index ae7b80f1a8..2aababeb0a 100644 --- a/autosar/rule_A2_7_1/libtooling/checker.h +++ b/autosar/rule_A2_7_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2023 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_AUTOSAR_RULE_A2_7_1_LIBTOOLING_CHECKER_H_ diff --git a/autosar/rule_A2_7_1/libtooling/lib.h b/autosar/rule_A2_7_1/libtooling/lib.h index 6ceab58a4c..c5df2e84bb 100644 --- a/autosar/rule_A2_7_1/libtooling/lib.h +++ b/autosar/rule_A2_7_1/libtooling/lib.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_AUTOSAR_RULE_A2_7_1_LIBTOOLING_LIB_H_ diff --git a/autosar/rule_A2_7_1/libtooling/rule_A2_7_1.cc b/autosar/rule_A2_7_1/libtooling/rule_A2_7_1.cc index b4c2961d18..9d001e8fb7 100644 --- a/autosar/rule_A2_7_1/libtooling/rule_A2_7_1.cc +++ b/autosar/rule_A2_7_1/libtooling/rule_A2_7_1.cc @@ -48,13 +48,13 @@ int rule_A2_7_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/autosar/rule_A2_7_3/libtooling/checker.cc b/autosar/rule_A2_7_3/libtooling/checker.cc index 280c19ce00..4694d304fa 100644 --- a/autosar/rule_A2_7_3/libtooling/checker.cc +++ b/autosar/rule_A2_7_3/libtooling/checker.cc @@ -44,10 +44,9 @@ namespace autosar { namespace rule_A2_7_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Match data members and "user-defined" types. finder->addMatcher(decl(anyOf(fieldDecl(), tagDecl())).bind("decl"), this); @@ -55,7 +54,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(functionDecl().bind("func_decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; SourceManager* source_manager = result.SourceManager; const Decl* decl = result.Nodes.getNodeAs("decl"); @@ -100,10 +99,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/autosar/rule_A2_7_3/libtooling/main.cc b/autosar/rule_A2_7_3/libtooling/main.cc index caa2cb09a9..9735d15c2c 100644 --- a/autosar/rule_A2_7_3/libtooling/main.cc +++ b/autosar/rule_A2_7_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_A2_7_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A3_1_3/rule_A3_1_3.go b/autosar/rule_A3_1_3/rule_A3_1_3.go index bc4e7aaefb..b05dce2bec 100644 --- a/autosar/rule_A3_1_3/rule_A3_1_3.go +++ b/autosar/rule_A3_1_3/rule_A3_1_3.go @@ -34,6 +34,7 @@ func checkFileNameExtension(buildActions *[]csa.BuildAction) (*pb.ResultsList, e if !strings.HasSuffix(path, ".cpp") { results.Results = append(results.Results, &pb.Result{ Path: path, + LineNumber: 1, ErrorMessage: "Implementation files, that are defined locally in the project, should have a file name extension of \".cpp\".", }) } diff --git a/autosar/rule_A3_1_4/libtooling/checker.cc b/autosar/rule_A3_1_4/libtooling/checker.cc index b17bacd3de..353234d377 100644 --- a/autosar/rule_A3_1_4/libtooling/checker.cc +++ b/autosar/rule_A3_1_4/libtooling/checker.cc @@ -30,15 +30,14 @@ using namespace llvm; namespace autosar { namespace rule_A3_1_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl(hasType(arrayType())).bind("vd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const VarDecl* vd = result.Nodes.getNodeAs("vd"); if (misra::libtooling_utils::IsInSystemHeader(vd, result.Context)) { return; diff --git a/autosar/rule_A3_1_4/libtooling/main.cc b/autosar/rule_A3_1_4/libtooling/main.cc index 957e51fbbd..47cd6d2522 100644 --- a/autosar/rule_A3_1_4/libtooling/main.cc +++ b/autosar/rule_A3_1_4/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_A3_1_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A3_1_5/libtooling/rule_A3_1_5.cc b/autosar/rule_A3_1_5/libtooling/rule_A3_1_5.cc index 255caef2ac..93a7fc208f 100644 --- a/autosar/rule_A3_1_5/libtooling/rule_A3_1_5.cc +++ b/autosar/rule_A3_1_5/libtooling/rule_A3_1_5.cc @@ -47,13 +47,13 @@ int rule_A3_1_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A3_1_6/libtooling/checker.cc b/autosar/rule_A3_1_6/libtooling/checker.cc index f653d8091a..46135bed17 100644 --- a/autosar/rule_A3_1_6/libtooling/checker.cc +++ b/autosar/rule_A3_1_6/libtooling/checker.cc @@ -47,10 +47,9 @@ namespace autosar { namespace rule_A3_1_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxMethodDecl(unless(isExpansionInSystemHeader()), @@ -59,7 +58,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const auto* md = result.Nodes.getNodeAs("method"); if (!md->hasBody()) { return; @@ -87,7 +86,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool IsAccessor(CXXMethodDecl const* md) { auto body = md->getBody(); @@ -126,7 +125,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A3_1_6/libtooling/rule_A3_1_6.cc b/autosar/rule_A3_1_6/libtooling/rule_A3_1_6.cc index 957662118c..8f4ef625e6 100644 --- a/autosar/rule_A3_1_6/libtooling/rule_A3_1_6.cc +++ b/autosar/rule_A3_1_6/libtooling/rule_A3_1_6.cc @@ -48,7 +48,7 @@ int rule_A3_1_6(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A3_3_2/libtooling/rule_A3_3_2.cc b/autosar/rule_A3_3_2/libtooling/rule_A3_3_2.cc index 9c8fe3feb4..62cdbbaf8e 100644 --- a/autosar/rule_A3_3_2/libtooling/rule_A3_3_2.cc +++ b/autosar/rule_A3_3_2/libtooling/rule_A3_3_2.cc @@ -47,7 +47,7 @@ int rule_A3_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A3_9_1/libtooling/rule_A3_9_1.cc b/autosar/rule_A3_9_1/libtooling/rule_A3_9_1.cc index 08436cd779..5467ee2e9b 100644 --- a/autosar/rule_A3_9_1/libtooling/rule_A3_9_1.cc +++ b/autosar/rule_A3_9_1/libtooling/rule_A3_9_1.cc @@ -48,7 +48,7 @@ int rule_A3_9_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A4_10_1/libtooling/rule_A4_10_1.cc b/autosar/rule_A4_10_1/libtooling/rule_A4_10_1.cc index 0d48955eff..1d87101e88 100644 --- a/autosar/rule_A4_10_1/libtooling/rule_A4_10_1.cc +++ b/autosar/rule_A4_10_1/libtooling/rule_A4_10_1.cc @@ -47,7 +47,7 @@ int rule_A4_10_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A4_5_1/libtooling/checker.cc b/autosar/rule_A4_5_1/libtooling/checker.cc index f1d154efd2..231239bf46 100644 --- a/autosar/rule_A4_5_1/libtooling/checker.cc +++ b/autosar/rule_A4_5_1/libtooling/checker.cc @@ -41,17 +41,16 @@ void ReportError(string path, int line_number, line_number); } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(binaryOperator().bind("bin_op"), this); finder->addMatcher(unaryOperator().bind("un_op"), this); finder->addMatcher(cxxOperatorCallExpr().bind("op_call"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const BinaryOperator* bin_op = result.Nodes.getNodeAs("bin_op"); if (bin_op && diff --git a/autosar/rule_A4_5_1/libtooling/rule_A4_5_1.cc b/autosar/rule_A4_5_1/libtooling/rule_A4_5_1.cc index f1e88b8f77..91d4f5623f 100644 --- a/autosar/rule_A4_5_1/libtooling/rule_A4_5_1.cc +++ b/autosar/rule_A4_5_1/libtooling/rule_A4_5_1.cc @@ -50,7 +50,7 @@ int rule_A4_5_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A4_7_1/libtooling/rule_A4_7_1.cc b/autosar/rule_A4_7_1/libtooling/rule_A4_7_1.cc index 0eff8954e6..773907175b 100644 --- a/autosar/rule_A4_7_1/libtooling/rule_A4_7_1.cc +++ b/autosar/rule_A4_7_1/libtooling/rule_A4_7_1.cc @@ -48,7 +48,7 @@ int rule_A4_7_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_0_4/libtooling/rule_A5_0_4.cc b/autosar/rule_A5_0_4/libtooling/rule_A5_0_4.cc index 4d63aa5484..fa5319d6cc 100644 --- a/autosar/rule_A5_0_4/libtooling/rule_A5_0_4.cc +++ b/autosar/rule_A5_0_4/libtooling/rule_A5_0_4.cc @@ -48,7 +48,7 @@ int rule_A5_0_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_10_1/libtooling/checker.cc b/autosar/rule_A5_10_1/libtooling/checker.cc index fa40f680a0..0ef6a75374 100644 --- a/autosar/rule_A5_10_1/libtooling/checker.cc +++ b/autosar/rule_A5_10_1/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A pointer to member virtual function shall only be tested for equality with null-pointer-constant."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -58,10 +57,9 @@ bool isVirtualMemberFunctionPointer(const Expr* expr, const DeclRefExpr* ref) { return false; }; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -73,7 +71,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const BinaryOperator* stmt = result.Nodes.getNodeAs("stmt"); const DeclRefExpr* left = result.Nodes.getNodeAs("left"); @@ -85,7 +83,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (left) { if (isVirtualMemberFunctionPointer(lhs, left)) { if (!isa(rhs)) { - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -99,7 +97,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (right) { if (isVirtualMemberFunctionPointer(rhs, right)) { if (!isa(lhs)) { - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -111,10 +109,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A5_10_1/libtooling/rule_A5_10_1.cc b/autosar/rule_A5_10_1/libtooling/rule_A5_10_1.cc index 203ad2797d..e4f90c618d 100644 --- a/autosar/rule_A5_10_1/libtooling/rule_A5_10_1.cc +++ b/autosar/rule_A5_10_1/libtooling/rule_A5_10_1.cc @@ -48,7 +48,7 @@ int rule_A5_10_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A5_16_1/libtooling/checker.cc b/autosar/rule_A5_16_1/libtooling/checker.cc index 8f10f354ed..7049ffe1a5 100644 --- a/autosar/rule_A5_16_1/libtooling/checker.cc +++ b/autosar/rule_A5_16_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The ternary conditional operator shall not be used as a sub-expression."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A5_16_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -71,10 +69,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Stmt* stmt = result.Nodes.getNodeAs("stmt"); - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -82,10 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A5_16_1/libtooling/rule_A5_16_1.cc b/autosar/rule_A5_16_1/libtooling/rule_A5_16_1.cc index a4dc1a831f..5ec00eac32 100644 --- a/autosar/rule_A5_16_1/libtooling/rule_A5_16_1.cc +++ b/autosar/rule_A5_16_1/libtooling/rule_A5_16_1.cc @@ -48,7 +48,7 @@ int rule_A5_16_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A5_1_1/libtooling/checker.cc b/autosar/rule_A5_1_1/libtooling/checker.cc index 84e3244d75..bbfdf3f294 100644 --- a/autosar/rule_A5_1_1/libtooling/checker.cc +++ b/autosar/rule_A5_1_1/libtooling/checker.cc @@ -56,10 +56,9 @@ decltype(parentMatcher) nestedHasParentMatcher(int level) { hasParent(decl(matcher))); } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; const auto matcher = allOf( // skip 5 in `int x[5];`, `C c;`, `std::array` as they @@ -79,7 +78,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(stringLiteral(matcher).bind("literal"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const auto* literal = result.Nodes.getNodeAs("literal"); ReportError( misra::libtooling_utils::GetFilename(literal, result.SourceManager), @@ -88,10 +87,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A5_1_1/libtooling/rule_A5_1_1.cc b/autosar/rule_A5_1_1/libtooling/rule_A5_1_1.cc index 81bc8abb9e..b12d4a2524 100644 --- a/autosar/rule_A5_1_1/libtooling/rule_A5_1_1.cc +++ b/autosar/rule_A5_1_1/libtooling/rule_A5_1_1.cc @@ -48,7 +48,7 @@ int rule_A5_1_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/autosar/rule_A5_1_2/libtooling/rule_A5_1_2.cc b/autosar/rule_A5_1_2/libtooling/rule_A5_1_2.cc index 31ed154f0e..ba93b11b3f 100644 --- a/autosar/rule_A5_1_2/libtooling/rule_A5_1_2.cc +++ b/autosar/rule_A5_1_2/libtooling/rule_A5_1_2.cc @@ -48,7 +48,7 @@ int rule_A5_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_1_3/libtooling/checker.cc b/autosar/rule_A5_1_3/libtooling/checker.cc index 0c444ec5aa..31ef822696 100644 --- a/autosar/rule_A5_1_3/libtooling/checker.cc +++ b/autosar/rule_A5_1_3/libtooling/checker.cc @@ -59,7 +59,7 @@ void Callback::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A5_1_3/libtooling/rule_A5_1_3.cc b/autosar/rule_A5_1_3/libtooling/rule_A5_1_3.cc index 3857695dc8..aeb90d149d 100644 --- a/autosar/rule_A5_1_3/libtooling/rule_A5_1_3.cc +++ b/autosar/rule_A5_1_3/libtooling/rule_A5_1_3.cc @@ -47,7 +47,7 @@ int rule_A5_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_1_4/libtooling/checker.cc b/autosar/rule_A5_1_4/libtooling/checker.cc index 8900d71510..476ce781f0 100644 --- a/autosar/rule_A5_1_4/libtooling/checker.cc +++ b/autosar/rule_A5_1_4/libtooling/checker.cc @@ -63,7 +63,7 @@ void Callback::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A5_1_4/libtooling/rule_A5_1_4.cc b/autosar/rule_A5_1_4/libtooling/rule_A5_1_4.cc index cb9dd51299..e43732d2f3 100644 --- a/autosar/rule_A5_1_4/libtooling/rule_A5_1_4.cc +++ b/autosar/rule_A5_1_4/libtooling/rule_A5_1_4.cc @@ -47,13 +47,13 @@ int rule_A5_1_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A5_1_6/libtooling/rule_A5_1_6.cc b/autosar/rule_A5_1_6/libtooling/rule_A5_1_6.cc index aae560a1fe..d90086e165 100644 --- a/autosar/rule_A5_1_6/libtooling/rule_A5_1_6.cc +++ b/autosar/rule_A5_1_6/libtooling/rule_A5_1_6.cc @@ -47,7 +47,7 @@ int rule_A5_1_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_1_7/libtooling/rule_A5_1_7.cc b/autosar/rule_A5_1_7/libtooling/rule_A5_1_7.cc index 3fe61e065e..4ab7d7a983 100644 --- a/autosar/rule_A5_1_7/libtooling/rule_A5_1_7.cc +++ b/autosar/rule_A5_1_7/libtooling/rule_A5_1_7.cc @@ -47,7 +47,7 @@ int rule_A5_1_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_1_8/libtooling/rule_A5_1_8.cc b/autosar/rule_A5_1_8/libtooling/rule_A5_1_8.cc index 15941bec27..45e118b763 100644 --- a/autosar/rule_A5_1_8/libtooling/rule_A5_1_8.cc +++ b/autosar/rule_A5_1_8/libtooling/rule_A5_1_8.cc @@ -47,7 +47,7 @@ int rule_A5_1_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_1_9/libtooling/rule_A5_1_9.cc b/autosar/rule_A5_1_9/libtooling/rule_A5_1_9.cc index 56e0fd3896..586d64034f 100644 --- a/autosar/rule_A5_1_9/libtooling/rule_A5_1_9.cc +++ b/autosar/rule_A5_1_9/libtooling/rule_A5_1_9.cc @@ -47,7 +47,7 @@ int rule_A5_1_9(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_2_1/libtooling/rule_A5_2_1.cc b/autosar/rule_A5_2_1/libtooling/rule_A5_2_1.cc index 1126bd9cd3..cda63f92a6 100644 --- a/autosar/rule_A5_2_1/libtooling/rule_A5_2_1.cc +++ b/autosar/rule_A5_2_1/libtooling/rule_A5_2_1.cc @@ -48,7 +48,7 @@ int rule_A5_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_2_2/libtooling/rule_A5_2_2.cc b/autosar/rule_A5_2_2/libtooling/rule_A5_2_2.cc index 64a48d82de..4596997187 100644 --- a/autosar/rule_A5_2_2/libtooling/rule_A5_2_2.cc +++ b/autosar/rule_A5_2_2/libtooling/rule_A5_2_2.cc @@ -48,7 +48,7 @@ int rule_A5_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_2_3/libtooling/rule_A5_2_3.cc b/autosar/rule_A5_2_3/libtooling/rule_A5_2_3.cc index d8d147e736..9281fa084e 100644 --- a/autosar/rule_A5_2_3/libtooling/rule_A5_2_3.cc +++ b/autosar/rule_A5_2_3/libtooling/rule_A5_2_3.cc @@ -48,7 +48,7 @@ int rule_A5_2_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_2_4/libtooling/rule_A5_2_4.cc b/autosar/rule_A5_2_4/libtooling/rule_A5_2_4.cc index f7f7d12e59..e080d187ea 100644 --- a/autosar/rule_A5_2_4/libtooling/rule_A5_2_4.cc +++ b/autosar/rule_A5_2_4/libtooling/rule_A5_2_4.cc @@ -48,7 +48,7 @@ int rule_A5_2_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A5_5_1/libtooling/rule_A5_5_1.cc b/autosar/rule_A5_5_1/libtooling/rule_A5_5_1.cc index ef15395c69..54f208aaa0 100644 --- a/autosar/rule_A5_5_1/libtooling/rule_A5_5_1.cc +++ b/autosar/rule_A5_5_1/libtooling/rule_A5_5_1.cc @@ -48,7 +48,7 @@ int rule_A5_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A6_2_1/libtooling/checker.cc b/autosar/rule_A6_2_1/libtooling/checker.cc index 7ec4a22ad1..8ffe896d2e 100644 --- a/autosar/rule_A6_2_1/libtooling/checker.cc +++ b/autosar/rule_A6_2_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Move and copy assignment operators shall either move or respectively copy base classes and data members of a class, without any side effects."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -85,10 +84,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A6_2_1/libtooling/rule_A6_2_1.cc b/autosar/rule_A6_2_1/libtooling/rule_A6_2_1.cc index ef6b53ff48..75b0b04c84 100644 --- a/autosar/rule_A6_2_1/libtooling/rule_A6_2_1.cc +++ b/autosar/rule_A6_2_1/libtooling/rule_A6_2_1.cc @@ -48,7 +48,7 @@ int rule_A6_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A6_2_2/libtooling/checker.cc b/autosar/rule_A6_2_2/libtooling/checker.cc index 9cf5374edb..e67f8be564 100644 --- a/autosar/rule_A6_2_2/libtooling/checker.cc +++ b/autosar/rule_A6_2_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Expression statements shall not be explicit calls to constructors of temporary objects only."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,21 +46,20 @@ namespace autosar { namespace rule_A6_2_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxBindTemporaryExpr(hasParent(exprWithCleanups())).bind("temp_obj"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* temp_obj = result.Nodes.getNodeAs("temp_obj"); if (temp_obj) { - std::string path = + string path = misra::libtooling_utils::GetFilename(temp_obj, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(temp_obj, result.SourceManager); @@ -70,10 +68,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A6_2_2/libtooling/rule_A6_2_2.cc b/autosar/rule_A6_2_2/libtooling/rule_A6_2_2.cc index 63f574b7e6..2e00130efb 100644 --- a/autosar/rule_A6_2_2/libtooling/rule_A6_2_2.cc +++ b/autosar/rule_A6_2_2/libtooling/rule_A6_2_2.cc @@ -48,7 +48,7 @@ int rule_A6_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A6_4_1/libtooling/checker.cc b/autosar/rule_A6_4_1/libtooling/checker.cc index 1d191cb3c7..59f4aba3bd 100644 --- a/autosar/rule_A6_4_1/libtooling/checker.cc +++ b/autosar/rule_A6_4_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A switch statement shall have at least two case-clauses, distinct from the default label."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,17 +46,16 @@ namespace autosar { namespace rule_A6_4_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( switchStmt(unless(isExpansionInSystemHeader())).bind("stmt"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const SwitchStmt* stmt = result.Nodes.getNodeAs("stmt"); const SwitchCase* p = stmt->getSwitchCaseList(); int cnt = 0; @@ -70,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } p = p->getNextSwitchCase(); } - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -78,10 +76,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A6_4_1/libtooling/rule_A6_4_1.cc b/autosar/rule_A6_4_1/libtooling/rule_A6_4_1.cc index dfb7882bf2..132027b614 100644 --- a/autosar/rule_A6_4_1/libtooling/rule_A6_4_1.cc +++ b/autosar/rule_A6_4_1/libtooling/rule_A6_4_1.cc @@ -48,7 +48,7 @@ int rule_A6_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A6_5_1/libtooling/rule_A6_5_1.cc b/autosar/rule_A6_5_1/libtooling/rule_A6_5_1.cc index 76bb08c29f..08d54472ed 100644 --- a/autosar/rule_A6_5_1/libtooling/rule_A6_5_1.cc +++ b/autosar/rule_A6_5_1/libtooling/rule_A6_5_1.cc @@ -48,7 +48,7 @@ int rule_A6_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A6_5_3/libtooling/rule_A6_5_3.cc b/autosar/rule_A6_5_3/libtooling/rule_A6_5_3.cc index 73894d815e..c3afd23138 100644 --- a/autosar/rule_A6_5_3/libtooling/rule_A6_5_3.cc +++ b/autosar/rule_A6_5_3/libtooling/rule_A6_5_3.cc @@ -48,7 +48,7 @@ int rule_A6_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A6_5_4/libtooling/rule_A6_5_4.cc b/autosar/rule_A6_5_4/libtooling/rule_A6_5_4.cc index abb1b7cb7b..916fe1520c 100644 --- a/autosar/rule_A6_5_4/libtooling/rule_A6_5_4.cc +++ b/autosar/rule_A6_5_4/libtooling/rule_A6_5_4.cc @@ -48,7 +48,7 @@ int rule_A6_5_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A6_6_1/libtooling/rule_A6_6_1.cc b/autosar/rule_A6_6_1/libtooling/rule_A6_6_1.cc index 305f8691e8..8800a53b61 100644 --- a/autosar/rule_A6_6_1/libtooling/rule_A6_6_1.cc +++ b/autosar/rule_A6_6_1/libtooling/rule_A6_6_1.cc @@ -48,7 +48,7 @@ int rule_A6_6_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A7_1_1/libtooling/checker.cc b/autosar/rule_A7_1_1/libtooling/checker.cc index 190edc093f..f776cc3015 100644 --- a/autosar/rule_A7_1_1/libtooling/checker.cc +++ b/autosar/rule_A7_1_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Constexpr or const specifiers shall be used for immutable data declaration."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A7_1_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; clang::ast_matchers::internal::BindableMatcher unchanged_vd_ref = declRefExpr(to(varDecl(equalsBoundNode("vd"))), @@ -70,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); if (!var_decl) { return; @@ -86,7 +84,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { return; } - std::string path = + string path = misra::libtooling_utils::GetFilename(var_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(var_decl, result.SourceManager); @@ -94,10 +92,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_1/libtooling/rule_A7_1_1.cc b/autosar/rule_A7_1_1/libtooling/rule_A7_1_1.cc index 8e20ec7f5b..c64290948f 100644 --- a/autosar/rule_A7_1_1/libtooling/rule_A7_1_1.cc +++ b/autosar/rule_A7_1_1/libtooling/rule_A7_1_1.cc @@ -48,7 +48,7 @@ int rule_A7_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_2/libtooling/checker.cc b/autosar/rule_A7_1_2/libtooling/checker.cc index d6376a1735..ce2ce53ce1 100644 --- a/autosar/rule_A7_1_2/libtooling/checker.cc +++ b/autosar/rule_A7_1_2/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The constexpr specifier shall be used for values that can be determined at compile time."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A7_1_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(unless(isInstantiated()), hasInitializer(expr().bind("init"))) @@ -58,12 +56,12 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); if (!var_decl) { return; } - std::string path = + string path = misra::libtooling_utils::GetFilename(var_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(var_decl, result.SourceManager); @@ -82,10 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_2/libtooling/rule_A7_1_2.cc b/autosar/rule_A7_1_2/libtooling/rule_A7_1_2.cc index 077f5bcce9..ea6d51364c 100644 --- a/autosar/rule_A7_1_2/libtooling/rule_A7_1_2.cc +++ b/autosar/rule_A7_1_2/libtooling/rule_A7_1_2.cc @@ -48,7 +48,7 @@ int rule_A7_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_3/libtooling/checker.cc b/autosar/rule_A7_1_3/libtooling/checker.cc index 8942170b38..d3168a3601 100644 --- a/autosar/rule_A7_1_3/libtooling/checker.cc +++ b/autosar/rule_A7_1_3/libtooling/checker.cc @@ -32,13 +32,12 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, - ResultsList* results_list, string str = "") { - std::string error_message = +void ReportError(const string& path, int line_number, ResultsList* results_list, + string str = "") { + string error_message = "CV-qualifiers shall be placed on the right hand side of the type that is a typedef or a using name." + str; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -49,10 +48,9 @@ namespace autosar { namespace rule_A7_1_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( valueDecl( @@ -64,7 +62,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ValueDecl* vd = result.Nodes.getNodeAs("vd"); if (vd) { const QualType qt = vd->getType().getLocalUnqualifiedType(); @@ -85,10 +83,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_3/libtooling/rule_A7_1_3.cc b/autosar/rule_A7_1_3/libtooling/rule_A7_1_3.cc index bb94a01e06..494eff4ec4 100644 --- a/autosar/rule_A7_1_3/libtooling/rule_A7_1_3.cc +++ b/autosar/rule_A7_1_3/libtooling/rule_A7_1_3.cc @@ -48,7 +48,7 @@ int rule_A7_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_4/libtooling/checker.cc b/autosar/rule_A7_1_4/libtooling/checker.cc index 6425246365..3ebfa4cc76 100644 --- a/autosar/rule_A7_1_4/libtooling/checker.cc +++ b/autosar/rule_A7_1_4/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "The register keyword shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "The register keyword shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,21 +45,20 @@ namespace autosar { namespace rule_A7_1_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl(unless(isExpansionInSystemHeader())).bind("vd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); if (var_decl && var_decl->hasLocalStorage() && var_decl->getStorageClass() == clang::SC_Register) { - std::string path = + string path = misra::libtooling_utils::GetFilename(var_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(var_decl, result.SourceManager); @@ -69,10 +67,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_4/libtooling/rule_A7_1_4.cc b/autosar/rule_A7_1_4/libtooling/rule_A7_1_4.cc index 0211f15039..045dd04d0d 100644 --- a/autosar/rule_A7_1_4/libtooling/rule_A7_1_4.cc +++ b/autosar/rule_A7_1_4/libtooling/rule_A7_1_4.cc @@ -48,7 +48,7 @@ int rule_A7_1_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_5/libtooling/checker.cc b/autosar/rule_A7_1_5/libtooling/checker.cc index 1c918264c5..54299f6843 100644 --- a/autosar/rule_A7_1_5/libtooling/checker.cc +++ b/autosar/rule_A7_1_5/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "The auto specifier shall not be used apart from following cases: (1) to declare that a variable has the same type as return type of a function call, (2) to declare that a variable has the same type as initializer of non-fundamental type, (3) to declare parameters of a generic lambda expression, (4) to declare a function template using trailing return type syntax."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A7_1_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl(unless(isExpansionInSystemHeader()), hasInitializer(expr().bind("init")), @@ -69,7 +67,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); const FunctionDecl* function_decl = result.Nodes.getNodeAs("fd"); @@ -114,10 +112,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_5/libtooling/rule_A7_1_5.cc b/autosar/rule_A7_1_5/libtooling/rule_A7_1_5.cc index 8beb4bb01c..dd0603a237 100644 --- a/autosar/rule_A7_1_5/libtooling/rule_A7_1_5.cc +++ b/autosar/rule_A7_1_5/libtooling/rule_A7_1_5.cc @@ -48,7 +48,7 @@ int rule_A7_1_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_6/libtooling/checker.cc b/autosar/rule_A7_1_6/libtooling/checker.cc index 24754470c4..94a813a49a 100644 --- a/autosar/rule_A7_1_6/libtooling/checker.cc +++ b/autosar/rule_A7_1_6/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "The typedef specifier shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "The typedef specifier shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,24 +45,23 @@ namespace autosar { namespace rule_A7_1_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( typedefDecl(unless(isExpansionInSystemHeader())).bind("decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* decl = result.Nodes.getNodeAs("decl"); FullSourceLoc location = result.Context->getFullLoc(decl->getBeginLoc()); if (location.isInvalid()) { return; } - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -71,10 +69,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_6/libtooling/rule_A7_1_6.cc b/autosar/rule_A7_1_6/libtooling/rule_A7_1_6.cc index af51ab0810..75b51e6890 100644 --- a/autosar/rule_A7_1_6/libtooling/rule_A7_1_6.cc +++ b/autosar/rule_A7_1_6/libtooling/rule_A7_1_6.cc @@ -48,7 +48,7 @@ int rule_A7_1_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_7/libtooling/checker.cc b/autosar/rule_A7_1_7/libtooling/checker.cc index cafdbf621a..4d4a8938c1 100644 --- a/autosar/rule_A7_1_7/libtooling/checker.cc +++ b/autosar/rule_A7_1_7/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Each expression statement and identifier declaration shall be placed on a separate line."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A7_1_7 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; last_decl_line_ = -1; has_reported_in_last_decl_line_ = false; @@ -63,7 +61,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { typedefDecl(unless(isExpansionInSystemHeader())).bind("decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const DeclStmt* stmt = result.Nodes.getNodeAs("stmt"); const Decl* decl = result.Nodes.getNodeAs("decl"); @@ -74,7 +72,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { cnt++; } if (cnt > 1) { - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -106,13 +104,13 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; int last_decl_line_; - std::string last_decl_path_; + string last_decl_path_; bool has_reported_in_last_decl_line_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_7/libtooling/rule_A7_1_7.cc b/autosar/rule_A7_1_7/libtooling/rule_A7_1_7.cc index 647bb16d61..f1de608765 100644 --- a/autosar/rule_A7_1_7/libtooling/rule_A7_1_7.cc +++ b/autosar/rule_A7_1_7/libtooling/rule_A7_1_7.cc @@ -48,7 +48,7 @@ int rule_A7_1_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_8/libtooling/checker.cc b/autosar/rule_A7_1_8/libtooling/checker.cc index 5e0d9538d6..d8c3c46019 100644 --- a/autosar/rule_A7_1_8/libtooling/checker.cc +++ b/autosar/rule_A7_1_8/libtooling/checker.cc @@ -35,12 +35,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A non-type specifier shall be placed before a type specifier in a declaration."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -52,7 +51,7 @@ namespace rule_A7_1_8 { namespace libtooling { StringRef getDeclSource(SourceLocation startLoc, SourceLocation endLoc, - const ast_matchers::MatchFinder::MatchResult& result) { + const MatchFinder::MatchResult& result) { clang::SourceRange range = SourceRange(result.SourceManager->getSpellingLoc(startLoc), result.SourceManager->getSpellingLoc(endLoc)); @@ -64,10 +63,9 @@ StringRef getDeclSource(SourceLocation startLoc, SourceLocation endLoc, return source; } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -84,7 +82,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { set non_type_specifier_set{ "friend", "constexpr", "register", "static", "extern", "thread_local", "mutable", "inline", "virtual", "explicit"}; @@ -118,7 +116,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { while (regex_search(begin, end, match, re_token)) { if (non_type_specifier_set.find(match[0]) != non_type_specifier_set.end()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(decl, result.SourceManager); @@ -141,7 +139,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { regex_search(str, match, re_token); // the first token in typedef decl should be 'typedef' if (match[0] != "typedef") { - std::string path = misra::libtooling_utils::GetFilename( + string path = misra::libtooling_utils::GetFilename( typedef_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine( typedef_decl, result.SourceManager); @@ -172,10 +170,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_8/libtooling/rule_A7_1_8.cc b/autosar/rule_A7_1_8/libtooling/rule_A7_1_8.cc index fee62c83a7..acfa280b92 100644 --- a/autosar/rule_A7_1_8/libtooling/rule_A7_1_8.cc +++ b/autosar/rule_A7_1_8/libtooling/rule_A7_1_8.cc @@ -48,7 +48,7 @@ int rule_A7_1_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_1_9/libtooling/checker.cc b/autosar/rule_A7_1_9/libtooling/checker.cc index c2d1087393..7b06162a20 100644 --- a/autosar/rule_A7_1_9/libtooling/checker.cc +++ b/autosar/rule_A7_1_9/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A class, structure, or enumeration shall not be declared in the definition of its type."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A7_1_9 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(hasType(elaboratedType()), unless(isExpansionInSystemHeader())) @@ -58,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); const SourceManager& SM = *result.SourceManager; auto vd_loc = SM.getSpellingLoc(var_decl->getBeginLoc()); @@ -96,10 +94,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_1_9/libtooling/rule_A7_1_9.cc b/autosar/rule_A7_1_9/libtooling/rule_A7_1_9.cc index 2fca78baf9..e2e6d1702d 100644 --- a/autosar/rule_A7_1_9/libtooling/rule_A7_1_9.cc +++ b/autosar/rule_A7_1_9/libtooling/rule_A7_1_9.cc @@ -48,7 +48,7 @@ int rule_A7_1_9(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_2_2/libtooling/rule_A7_2_2.cc b/autosar/rule_A7_2_2/libtooling/rule_A7_2_2.cc index c8ca9fc04e..63b1362af9 100644 --- a/autosar/rule_A7_2_2/libtooling/rule_A7_2_2.cc +++ b/autosar/rule_A7_2_2/libtooling/rule_A7_2_2.cc @@ -47,7 +47,7 @@ int rule_A7_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A7_2_3/libtooling/rule_A7_2_3.cc b/autosar/rule_A7_2_3/libtooling/rule_A7_2_3.cc index a28dc9a684..86ccc21c08 100644 --- a/autosar/rule_A7_2_3/libtooling/rule_A7_2_3.cc +++ b/autosar/rule_A7_2_3/libtooling/rule_A7_2_3.cc @@ -47,7 +47,7 @@ int rule_A7_2_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A7_2_4/libtooling/checker.cc b/autosar/rule_A7_2_4/libtooling/checker.cc index fe024a7817..27551ea225 100644 --- a/autosar/rule_A7_2_4/libtooling/checker.cc +++ b/autosar/rule_A7_2_4/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "In an enumeration, either (1) none, (2) the first or (3) all enumerators shall be initialized."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,16 +46,15 @@ namespace autosar { namespace rule_A7_2_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( enumDecl(unless(isExpansionInSystemHeader())).bind("enum"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const EnumDecl* enum_decl = result.Nodes.getNodeAs("enum"); int enum_count = 0; int init_count = 0; @@ -72,7 +70,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (!(init_count == 0 || (first_inited && init_count == 1) || init_count == enum_count)) { - std::string path = + string path = misra::libtooling_utils::GetFilename(enum_decl, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(enum_decl, result.SourceManager); @@ -81,10 +79,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_2_4/libtooling/rule_A7_2_4.cc b/autosar/rule_A7_2_4/libtooling/rule_A7_2_4.cc index 55f1275bf5..b64afceed9 100644 --- a/autosar/rule_A7_2_4/libtooling/rule_A7_2_4.cc +++ b/autosar/rule_A7_2_4/libtooling/rule_A7_2_4.cc @@ -48,7 +48,7 @@ int rule_A7_2_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_3_1/libtooling/checker.cc b/autosar/rule_A7_3_1/libtooling/checker.cc index 9813a43a5d..0ce154e0b9 100644 --- a/autosar/rule_A7_3_1/libtooling/checker.cc +++ b/autosar/rule_A7_3_1/libtooling/checker.cc @@ -151,7 +151,7 @@ void Callback::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/autosar/rule_A7_3_1/libtooling/rule_A7_3_1.cc b/autosar/rule_A7_3_1/libtooling/rule_A7_3_1.cc index 3c2883da8d..c668e1d5f0 100644 --- a/autosar/rule_A7_3_1/libtooling/rule_A7_3_1.cc +++ b/autosar/rule_A7_3_1/libtooling/rule_A7_3_1.cc @@ -47,13 +47,13 @@ int rule_A7_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/autosar/rule_A7_4_1/libtooling/checker.cc b/autosar/rule_A7_4_1/libtooling/checker.cc index ffe63f15ed..1b0626dfba 100644 --- a/autosar/rule_A7_4_1/libtooling/checker.cc +++ b/autosar/rule_A7_4_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "The asm declaration shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "The asm declaration shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -46,20 +45,19 @@ namespace autosar { namespace rule_A7_4_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(asmStmt(unless(isExpansionInSystemHeader())).bind("asm"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Stmt* asm_stmt = result.Nodes.getNodeAs("asm"); if (asm_stmt) { - std::string path = + string path = misra::libtooling_utils::GetFilename(asm_stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(asm_stmt, result.SourceManager); @@ -68,10 +66,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_4_1/libtooling/rule_A7_4_1.cc b/autosar/rule_A7_4_1/libtooling/rule_A7_4_1.cc index bfaeb3c5a6..c3e3ef98f3 100644 --- a/autosar/rule_A7_4_1/libtooling/rule_A7_4_1.cc +++ b/autosar/rule_A7_4_1/libtooling/rule_A7_4_1.cc @@ -48,7 +48,7 @@ int rule_A7_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A7_5_1/libtooling/checker.cc b/autosar/rule_A7_5_1/libtooling/checker.cc index 46a80351db..a1adcfc74f 100644 --- a/autosar/rule_A7_5_1/libtooling/checker.cc +++ b/autosar/rule_A7_5_1/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A function shall not return a reference or a pointer to a parameter that is passed by reference to const."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -48,10 +47,9 @@ namespace autosar { namespace rule_A7_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -75,7 +73,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* decl = result.Nodes.getNodeAs("decl"); const DeclRefExpr* ref = result.Nodes.getNodeAs("ref"); const Stmt* stmt = result.Nodes.getNodeAs("stmt"); @@ -84,7 +82,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { const QualType parmType = cast(ref->getDecl())->getType(); if (parmType->isReferenceType() && parmType.getNonReferenceType().isConstQualified()) { - std::string path = + string path = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); int line_number = misra::libtooling_utils::GetLine(stmt, result.SourceManager); @@ -95,10 +93,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A7_5_1/libtooling/rule_A7_5_1.cc b/autosar/rule_A7_5_1/libtooling/rule_A7_5_1.cc index 09897618bd..e100eab9aa 100644 --- a/autosar/rule_A7_5_1/libtooling/rule_A7_5_1.cc +++ b/autosar/rule_A7_5_1/libtooling/rule_A7_5_1.cc @@ -48,7 +48,7 @@ int rule_A7_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_2_1/libtooling/checker.cc b/autosar/rule_A8_2_1/libtooling/checker.cc index b04608e3d7..d8d843b98b 100644 --- a/autosar/rule_A8_2_1/libtooling/checker.cc +++ b/autosar/rule_A8_2_1/libtooling/checker.cc @@ -32,12 +32,11 @@ using std::string; namespace { constexpr char kFunctionDeclString[] = "functionDecl"; -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "When declaring function templates, the trailing return type syntax shall be used if the return type depends on the type of parameters."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -48,26 +47,24 @@ namespace autosar { namespace rule_A8_2_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder); + void Init(ResultsList* results_list, MatchFinder* finder); - void run(const ast_matchers::MatchFinder::MatchResult& result); + void run(const MatchFinder::MatchResult& result); private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Callback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void Callback::Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(isDefinition(), unless(hasTrailingReturn())) .bind(kFunctionDeclString), this); } -void Callback::run(const ast_matchers::MatchFinder::MatchResult& result) { +void Callback::run(const MatchFinder::MatchResult& result) { const FunctionDecl* function_decl = result.Nodes.getNodeAs(kFunctionDeclString); if (misra::libtooling_utils::IsInSystemHeader(function_decl, @@ -79,15 +76,15 @@ void Callback::run(const ast_matchers::MatchFinder::MatchResult& result) { function_decl->getReturnType()->isDependentType())) { // The checker reports errors when the return type is a dependent type or it // starts with "typename". - std::string path = misra::libtooling_utils::GetFilename( - function_decl, result.SourceManager); + string path = misra::libtooling_utils::GetFilename(function_decl, + result.SourceManager); int line_number = misra::libtooling_utils::GetLine(function_decl, result.SourceManager); ReportError(path, line_number, results_list_); } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A8_2_1/libtooling/rule_A8_2_1.cc b/autosar/rule_A8_2_1/libtooling/rule_A8_2_1.cc index 3310d70aea..cf8c544c8c 100644 --- a/autosar/rule_A8_2_1/libtooling/rule_A8_2_1.cc +++ b/autosar/rule_A8_2_1/libtooling/rule_A8_2_1.cc @@ -48,7 +48,7 @@ int rule_A8_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_10/libtooling/rule_A8_4_10.cc b/autosar/rule_A8_4_10/libtooling/rule_A8_4_10.cc index 508ae73673..90fcd7c09b 100644 --- a/autosar/rule_A8_4_10/libtooling/rule_A8_4_10.cc +++ b/autosar/rule_A8_4_10/libtooling/rule_A8_4_10.cc @@ -48,7 +48,7 @@ int rule_A8_4_10(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_11/libtooling/checker.cc b/autosar/rule_A8_4_11/libtooling/checker.cc index 19d33f3446..71c02aa914 100644 --- a/autosar/rule_A8_4_11/libtooling/checker.cc +++ b/autosar/rule_A8_4_11/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "A smart pointer shall only be used as a parameter type if it expresses lifetime semantics."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -178,10 +177,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A8_4_11/libtooling/rule_A8_4_11.cc b/autosar/rule_A8_4_11/libtooling/rule_A8_4_11.cc index 5b5d66da36..3c474c9065 100644 --- a/autosar/rule_A8_4_11/libtooling/rule_A8_4_11.cc +++ b/autosar/rule_A8_4_11/libtooling/rule_A8_4_11.cc @@ -48,7 +48,7 @@ int rule_A8_4_11(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_12/libtooling/rule_A8_4_12.cc b/autosar/rule_A8_4_12/libtooling/rule_A8_4_12.cc index 02cf87ee84..34bb4562f6 100644 --- a/autosar/rule_A8_4_12/libtooling/rule_A8_4_12.cc +++ b/autosar/rule_A8_4_12/libtooling/rule_A8_4_12.cc @@ -48,7 +48,7 @@ int rule_A8_4_12(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_13/libtooling/rule_A8_4_13.cc b/autosar/rule_A8_4_13/libtooling/rule_A8_4_13.cc index 29f90d8e43..f042f66d59 100644 --- a/autosar/rule_A8_4_13/libtooling/rule_A8_4_13.cc +++ b/autosar/rule_A8_4_13/libtooling/rule_A8_4_13.cc @@ -48,7 +48,7 @@ int rule_A8_4_13(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_4/libtooling/checker.cc b/autosar/rule_A8_4_4/libtooling/checker.cc index 69466ee98b..f8a3aa1ef1 100644 --- a/autosar/rule_A8_4_4/libtooling/checker.cc +++ b/autosar/rule_A8_4_4/libtooling/checker.cc @@ -33,15 +33,14 @@ namespace rule_A8_4_4 { namespace libtooling { extern FuncInfo2ParamInfos func_info_2_param_infos; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; AddFuncOutputParamMatchers(finder, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { FuncOutputParamCallback(result, func_info_2_param_infos); } diff --git a/autosar/rule_A8_4_4/libtooling/rule_A8_4_4.cc b/autosar/rule_A8_4_4/libtooling/rule_A8_4_4.cc index ab3980f12e..1db890a22b 100644 --- a/autosar/rule_A8_4_4/libtooling/rule_A8_4_4.cc +++ b/autosar/rule_A8_4_4/libtooling/rule_A8_4_4.cc @@ -65,13 +65,13 @@ int rule_A8_4_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); ClangTool tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); - analyzer::proto::ResultsList all_results; + ResultsList all_results; autosar::rule_A8_4_4::libtooling::Checker checker; checker.Init(&all_results); int status = diff --git a/autosar/rule_A8_4_5/libtooling/checker.cc b/autosar/rule_A8_4_5/libtooling/checker.cc index 322ebedf43..c3a6f0ac8f 100644 --- a/autosar/rule_A8_4_5/libtooling/checker.cc +++ b/autosar/rule_A8_4_5/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "\"consume\" parameters declared as X && shall always be moved from."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A8_4_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( declRefExpr(to(parmVarDecl().bind("pvd")), @@ -61,7 +59,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const DeclRefExpr* dre = result.Nodes.getNodeAs("dre"); const ParmVarDecl* pvd = result.Nodes.getNodeAs("pvd"); if (dre && isNonTemplateNonConstRValueReference(pvd->getType())) { @@ -73,7 +71,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; bool isNonTemplateNonConstRValueReference(QualType qt) { qt = qt.getNonPackExpansionType(); if (const RValueReferenceType* parm_ref = @@ -87,7 +85,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A8_4_5/libtooling/rule_A8_4_5.cc b/autosar/rule_A8_4_5/libtooling/rule_A8_4_5.cc index 65263ae54c..b83c490a15 100644 --- a/autosar/rule_A8_4_5/libtooling/rule_A8_4_5.cc +++ b/autosar/rule_A8_4_5/libtooling/rule_A8_4_5.cc @@ -48,7 +48,7 @@ int rule_A8_4_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_6/libtooling/checker.cc b/autosar/rule_A8_4_6/libtooling/checker.cc index 4dff3d8487..316266f47c 100644 --- a/autosar/rule_A8_4_6/libtooling/checker.cc +++ b/autosar/rule_A8_4_6/libtooling/checker.cc @@ -32,9 +32,9 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "\"forward\" parameters declared as T && shall always be forwarded."; AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, @@ -47,10 +47,9 @@ namespace autosar { namespace rule_A8_4_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( declRefExpr( @@ -61,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const DeclRefExpr* dre = result.Nodes.getNodeAs("dre"); const ParmVarDecl* pvd = result.Nodes.getNodeAs("pvd"); const FunctionTemplateDecl* ftd = @@ -86,10 +85,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A8_4_6/libtooling/rule_A8_4_6.cc b/autosar/rule_A8_4_6/libtooling/rule_A8_4_6.cc index 91c653663e..4853e85aae 100644 --- a/autosar/rule_A8_4_6/libtooling/rule_A8_4_6.cc +++ b/autosar/rule_A8_4_6/libtooling/rule_A8_4_6.cc @@ -48,7 +48,7 @@ int rule_A8_4_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_4_7/libtooling/checker.cc b/autosar/rule_A8_4_7/libtooling/checker.cc index 1d6b824190..27872657a7 100644 --- a/autosar/rule_A8_4_7/libtooling/checker.cc +++ b/autosar/rule_A8_4_7/libtooling/checker.cc @@ -33,15 +33,14 @@ namespace rule_A8_4_7 { namespace libtooling { extern FuncInfo2ParamInfos func_info_2_param_infos; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; AddFuncOutputParamMatchers(finder, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { FuncOutputParamCallback(result, func_info_2_param_infos); } diff --git a/autosar/rule_A8_4_7/libtooling/rule_A8_4_7.cc b/autosar/rule_A8_4_7/libtooling/rule_A8_4_7.cc index 026db51438..c4a0891f61 100644 --- a/autosar/rule_A8_4_7/libtooling/rule_A8_4_7.cc +++ b/autosar/rule_A8_4_7/libtooling/rule_A8_4_7.cc @@ -65,13 +65,13 @@ int rule_A8_4_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); ClangTool tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); - analyzer::proto::ResultsList all_results; + ResultsList all_results; autosar::rule_A8_4_7::libtooling::Checker checker; checker.Init(&all_results); int status = diff --git a/autosar/rule_A8_4_8/libtooling/rule_A8_4_8.cc b/autosar/rule_A8_4_8/libtooling/rule_A8_4_8.cc index 398d63c857..8d8e8f8a6c 100644 --- a/autosar/rule_A8_4_8/libtooling/rule_A8_4_8.cc +++ b/autosar/rule_A8_4_8/libtooling/rule_A8_4_8.cc @@ -47,7 +47,7 @@ int rule_A8_4_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A8_4_9/libtooling/rule_A8_4_9.cc b/autosar/rule_A8_4_9/libtooling/rule_A8_4_9.cc index 0728cf282b..57d09f79c6 100644 --- a/autosar/rule_A8_4_9/libtooling/rule_A8_4_9.cc +++ b/autosar/rule_A8_4_9/libtooling/rule_A8_4_9.cc @@ -50,7 +50,7 @@ int rule_A8_4_9(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A8_5_2/libtooling/checker.cc b/autosar/rule_A8_5_2/libtooling/checker.cc index 3a537cf6e5..a4ef87c95c 100644 --- a/autosar/rule_A8_5_2/libtooling/checker.cc +++ b/autosar/rule_A8_5_2/libtooling/checker.cc @@ -33,12 +33,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Braced-initialization {}, without equalssign, shall be used for variable initialization."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -211,10 +210,10 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A8_5_2/libtooling/rule_A8_5_2.cc b/autosar/rule_A8_5_2/libtooling/rule_A8_5_2.cc index 7b7f7ad5c9..7af9bd1814 100644 --- a/autosar/rule_A8_5_2/libtooling/rule_A8_5_2.cc +++ b/autosar/rule_A8_5_2/libtooling/rule_A8_5_2.cc @@ -48,7 +48,7 @@ int rule_A8_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A8_5_3/libtooling/checker.cc b/autosar/rule_A8_5_3/libtooling/checker.cc index ef8278655b..827da9cfdf 100644 --- a/autosar/rule_A8_5_3/libtooling/checker.cc +++ b/autosar/rule_A8_5_3/libtooling/checker.cc @@ -41,10 +41,9 @@ void ReportError(string path, int line_number, line_number); } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(hasInitializer(initListExpr()), hasType(autoType())) @@ -56,7 +55,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const VarDecl* varDecl = result.Nodes.getNodeAs("bracedInit"); if (varDecl && diff --git a/autosar/rule_A8_5_3/libtooling/rule_A8_5_3.cc b/autosar/rule_A8_5_3/libtooling/rule_A8_5_3.cc index fed209d5a3..828bb5fbf6 100644 --- a/autosar/rule_A8_5_3/libtooling/rule_A8_5_3.cc +++ b/autosar/rule_A8_5_3/libtooling/rule_A8_5_3.cc @@ -48,7 +48,7 @@ int rule_A8_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A8_5_4/libtooling/rule_A8_5_4.cc b/autosar/rule_A8_5_4/libtooling/rule_A8_5_4.cc index 2b0191556b..f5b896c78e 100644 --- a/autosar/rule_A8_5_4/libtooling/rule_A8_5_4.cc +++ b/autosar/rule_A8_5_4/libtooling/rule_A8_5_4.cc @@ -48,7 +48,7 @@ int rule_A8_5_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/autosar/rule_A9_3_1/libtooling/checker.cc b/autosar/rule_A9_3_1/libtooling/checker.cc index 378c95c891..4bad34c865 100644 --- a/autosar/rule_A9_3_1/libtooling/checker.cc +++ b/autosar/rule_A9_3_1/libtooling/checker.cc @@ -31,12 +31,11 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = + string error_message = "Member functions shall not return non-const \"raw\" pointers or references to private or protected data owned by the class."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -47,10 +46,9 @@ namespace autosar { namespace rule_A9_3_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; const auto CMDReturnsRawPtrOrRef = cxxMethodDecl( @@ -74,7 +72,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* cmd = result.Nodes.getNodeAs("cmd"); const ReturnStmt* rs = result.Nodes.getNodeAs("rs"); const MemberExpr* me = result.Nodes.getNodeAs("me"); @@ -99,10 +97,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A9_3_1/libtooling/rule_A9_3_1.cc b/autosar/rule_A9_3_1/libtooling/rule_A9_3_1.cc index 52b34eab03..e452b349b0 100644 --- a/autosar/rule_A9_3_1/libtooling/rule_A9_3_1.cc +++ b/autosar/rule_A9_3_1/libtooling/rule_A9_3_1.cc @@ -48,7 +48,7 @@ int rule_A9_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/autosar/rule_A9_5_1/libtooling/checker.cc b/autosar/rule_A9_5_1/libtooling/checker.cc index 03364d380b..2beea7ee0d 100644 --- a/autosar/rule_A9_5_1/libtooling/checker.cc +++ b/autosar/rule_A9_5_1/libtooling/checker.cc @@ -31,11 +31,10 @@ using std::string; namespace { -void ReportError(const std::string& path, int line_number, +void ReportError(const string& path, int line_number, ResultsList* results_list) { - std::string error_message = "Unions shall not be used."; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + string error_message = "Unions shall not be used."; + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -45,10 +44,9 @@ void ReportError(const std::string& path, int line_number, namespace autosar { namespace rule_A9_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(tagDecl(isUnion(), unless(isExpansionInSystemHeader()), unless(isImplicit())) @@ -56,7 +54,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Decl* u = result.Nodes.getNodeAs("union"); const auto langopts = result.Context->getLangOpts(); @@ -81,10 +79,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/autosar/rule_A9_5_1/libtooling/rule_A9_5_1.cc b/autosar/rule_A9_5_1/libtooling/rule_A9_5_1.cc index 009e172d55..522325b3be 100644 --- a/autosar/rule_A9_5_1/libtooling/rule_A9_5_1.cc +++ b/autosar/rule_A9_5_1/libtooling/rule_A9_5_1.cc @@ -48,7 +48,7 @@ int rule_A9_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/coccinelle/find_alloca/_bad0001/expected.textproto b/coccinelle/find_alloca/_bad0001/expected.textproto new file mode 100644 index 0000000000..e431e75b86 --- /dev/null +++ b/coccinelle/find_alloca/_bad0001/expected.textproto @@ -0,0 +1,5 @@ +results { + path: "test.c" + line_number: 9 + error_message: "find_alloca.cocci: alloca() should not be used" +} diff --git a/coccinelle/find_alloca/_bad0001/test.c b/coccinelle/find_alloca/_bad0001/test.c new file mode 100644 index 0000000000..4c6afe9bee --- /dev/null +++ b/coccinelle/find_alloca/_bad0001/test.c @@ -0,0 +1,12 @@ +#include + +int main(int argc, char *argv[]) +{ + unsigned int bytes = 1024 * 1024; + char *buf; + + /* allocate memory */ + buf = alloca(bytes); + + return 0; +} diff --git a/coccinelle/find_alloca/_good0001/expected.textproto b/coccinelle/find_alloca/_good0001/expected.textproto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/coccinelle/find_alloca/_good0001/test.c b/coccinelle/find_alloca/_good0001/test.c new file mode 100644 index 0000000000..22c034d89b --- /dev/null +++ b/coccinelle/find_alloca/_good0001/test.c @@ -0,0 +1,12 @@ +#include + +int main(int argc, char *argv[]) +{ + unsigned int bytes = 1024 * 1024; + char *buf; + + /* allocate memory with malloc instead of alloca */ + buf = malloc(bytes); + + return 0; +} diff --git a/coccinelle/find_alloca/cocci_rules b/coccinelle/find_alloca/cocci_rules new file mode 100644 index 0000000000..436d2c7232 --- /dev/null +++ b/coccinelle/find_alloca/cocci_rules @@ -0,0 +1 @@ +find_alloca.cocci {"error-message": "alloca() should not be used"} diff --git a/coccinelle/find_alloca/find_alloca.cocci b/coccinelle/find_alloca/find_alloca.cocci new file mode 100644 index 0000000000..5b710ae4e6 --- /dev/null +++ b/coccinelle/find_alloca/find_alloca.cocci @@ -0,0 +1,4 @@ +@@ expression E; @@ + +-alloca(E) ++malloc(E) \ No newline at end of file diff --git a/toy_rules/rule_1/libtooling/lib.h b/coccinelle/find_alloca/find_alloca_test.go similarity index 57% rename from toy_rules/rule_1/libtooling/lib.h rename to coccinelle/find_alloca/find_alloca_test.go index 4dc041064f..6c11fc0da6 100644 --- a/toy_rules/rule_1/libtooling/lib.h +++ b/coccinelle/find_alloca/find_alloca_test.go @@ -16,17 +16,23 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_TOY_RULES_RULE_1_LIBTOOLING_LIB_H_ -#define ANALYZER_TOY_RULES_RULE_1_LIBTOOLING_LIB_H_ - -namespace toy_rules { -namespace rule_1 { -namespace libtooling { - -int rule_1(int argc, char** argv); - -} // namespace libtooling -} // namespace rule_1 -} // namespace toy_rules - -#endif // ANALYZER_TOY_RULES_RULE_1_LIBTOOLING_LIB_H_ +package find_alloca + +import ( + "path/filepath" + "testing" + + "naive.systems/analyzer/cruleslib/runner" + "naive.systems/analyzer/cruleslib/testlib" + "naive.systems/analyzer/sdk/testcase" +) + +func TestGood0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_good0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunCoccinelle(tc.Srcdir, filepath.Dir(tc.Srcdir)))) +} + +func TestBad0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_bad0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunCoccinelle(tc.Srcdir, filepath.Dir(tc.Srcdir)))) +} diff --git a/cruleslib/basic/basic.go b/cruleslib/basic/basic.go index 9dbf2505e5..78be4480f4 100644 --- a/cruleslib/basic/basic.go +++ b/cruleslib/basic/basic.go @@ -42,6 +42,7 @@ import ( "github.com/golang/glog" "golang.org/x/text/message" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) type combinedOutput struct { @@ -97,6 +98,7 @@ func NewCheckingProcessPrinter(totalTaskNum int) CheckingProcessPrinter { func (c *CheckingProcessPrinter) StartAnalyzeTask(ruleName string, printer *message.Printer) { c.mutex.Lock() c.startAnalyzeTaskNum++ + telemetry.Send("Start analyzing", "ruleName", ruleName, "startAnalyzeTaskNum", c.startAnalyzeTaskNum, "totalTaskNum", c.totalTaskNum) PrintfWithTimeStamp(printer.Sprintf("Start analyzing for %s (%v/%v)", ruleName, c.startAnalyzeTaskNum, c.totalTaskNum)) c.timeElapsed[ruleName] = time.Now() c.mutex.Unlock() @@ -111,6 +113,7 @@ func (c *CheckingProcessPrinter) FinishAnalyzeTask(ruleName string, printer *mes currentFinishedNumber := c.finishAnalyzeTaskNum totalRuleNumber := c.totalTaskNum timeUsed := FormatTimeDuration(elapsed) + telemetry.Send("Analysis completed", "ruleName", ruleName, "percent", percent, "currentFinishedNumber", currentFinishedNumber, "totalRuleNumber", totalRuleNumber, "start", c.timeElapsed[ruleName], "elapsed", elapsed, "timeUsed", timeUsed) PrintfWithTimeStamp(printer.Sprintf("Analysis of %s completed (%s, %v/%v) [%s]", ruleName, percent, currentFinishedNumber, totalRuleNumber, timeUsed)) c.mutex.Unlock() } diff --git a/cruleslib/filter/filter.go b/cruleslib/filter/filter.go index 56aa0c2eeb..d662314024 100644 --- a/cruleslib/filter/filter.go +++ b/cruleslib/filter/filter.go @@ -29,7 +29,6 @@ import ( "math/rand" "os" "path/filepath" - "regexp" "strings" "github.com/golang/glog" @@ -50,55 +49,6 @@ func IsCCFile(path string) bool { return false } -func GetRuleNameFromErrorMessage(msg string) (string, error) { - reg := regexp.MustCompile(`\[([a-zA-Z\_\d]*)\]\[([a-zA-Z\.\-\_\d]*)\].*`) - matches := reg.FindAllStringSubmatch(msg, -1) - - for _, match := range matches { - if len(match) < 3 { - continue - } - ruleInfo := strings.Split(match[2], "-") - if len(ruleInfo) == 4 { - if ruleInfo[0] == "misra" && ruleInfo[1] == "c2012" && ruleInfo[2] == "dir" { - ruleId := strings.ReplaceAll(ruleInfo[3], ".", "_") - return "misra_c_2012/dir_" + ruleId, nil - } - } - if len(ruleInfo) == 3 { - if ruleInfo[0] == "misra" && ruleInfo[1] == "c2012" { - ruleId := strings.ReplaceAll(ruleInfo[2], ".", "_") - return "misra_c_2012/rule_" + ruleId, nil - } - if ruleInfo[0] == "misra" && ruleInfo[1] == "cpp2008" { - ruleId := strings.ReplaceAll(ruleInfo[2], ".", "_") - return "misra_cpp_2008/rule_" + ruleId, nil - } - if ruleInfo[0] == "gjb" && ruleInfo[1] == "5369" { - ruleId := strings.ReplaceAll(ruleInfo[2], ".", "_") - return "gjb5369/rule_" + ruleId, nil - } - if ruleInfo[0] == "gjb" && ruleInfo[1] == "8114" { - ruleId := strings.ReplaceAll(ruleInfo[2], ".", "_") - return "gjb8114/rule_" + ruleId, nil - } - } - if len(ruleInfo) == 2 { - if ruleInfo[0] == "cwe" { - return "cwe/" + ruleInfo[1], nil - } - if ruleInfo[0] == "autosar" { - return "autosar/" + ruleInfo[1], nil - } - } - lastIndex := strings.LastIndex(match[2], "-") - if lastIndex != -1 { - return fmt.Sprintf("%s/%s", match[2][:lastIndex], match[2][lastIndex+1:]), nil - } - } - return "", fmt.Errorf("invalid error message %v", msg) -} - func DeleteExceedResults(allResults *pb.ResultsList, checkRules []checkrule.CheckRule) *pb.ResultsList { maxReportNumMap := make(map[string]int) for _, checkRule := range checkRules { @@ -109,12 +59,12 @@ func DeleteExceedResults(allResults *pb.ResultsList, checkRules []checkrule.Chec errHashMap := make(map[string]int) rtnResults := make([]*pb.Result, 0) for _, currentResult := range allResults.Results { - rule, err := GetRuleNameFromErrorMessage(currentResult.ErrorMessage) - if err != nil { - glog.Errorf("GetRuleNameFromErrorMessage: %v", err) + if currentResult.Ruleset == "" || currentResult.RuleId == "" { + glog.Errorf("unknown rule: %s/%s", currentResult.Ruleset, currentResult.RuleId) rtnResults = append(rtnResults, currentResult) continue } + rule := fmt.Sprintf("%s/%s", currentResult.Ruleset, currentResult.RuleId) if _, exist := maxReportNumMap[rule]; !exist { rtnResults = append(rtnResults, currentResult) continue diff --git a/cruleslib/filter/filter_test.go b/cruleslib/filter/filter_test.go index feea28caf6..3533402c93 100644 --- a/cruleslib/filter/filter_test.go +++ b/cruleslib/filter/filter_test.go @@ -20,50 +20,11 @@ package filter import ( "path/filepath" - "reflect" "testing" pb "naive.systems/analyzer/analyzer/proto" ) -func TestGetRuleNameFromErrorMessage(t *testing.T) { - for _, testCase := range [...]struct { - expectedRule string - msg string - }{ - { - expectedRule: "misra_c_2012/dir_4_11", - msg: "[C5519][misra-c2012-dir-4.11]: 不修改的变量必须使用const修饰", - }, { - expectedRule: "misra_c_2012/rule_13_2", - msg: "[C5519][misra-c2012-13.2]: 不修改的变量必须使用const修饰", - }, - { - expectedRule: "misra_cpp_2008/rule_7_1_1", - msg: "[CXX5548][misra-cpp2008-7.1.1]: 不修改的变量必须使用const修饰", - }, - { - expectedRule: "gjb5369/rule_13_2_1", - msg: "[C7819][gjb-5369-13.2.1]: 不修改的变量必须使用const修饰", - }, - { - expectedRule: "gjb8114/rule_13_2_1", - msg: "[C7819][gjb-8114-13.2.1]: 不修改的变量必须使用const修饰", - }, - { - expectedRule: "gjb8114/rule_A_13_2_1", - msg: "[C7819][gjb-8114-A.13.2.1]: 不修改的变量必须使用const修饰", - }, - } { - t.Run(testCase.expectedRule, func(t *testing.T) { - rule, _ := GetRuleNameFromErrorMessage(testCase.msg) - if !reflect.DeepEqual(rule, testCase.expectedRule) { - t.Errorf("unexpected result for %v. got: %v. expected: %v.", testCase.msg, rule, testCase.expectedRule) - } - }) - } -} - func TestDeleteResultsWithCertainSuffixs(t *testing.T) { var testCase pb.ResultsList var suffixs []string diff --git a/cruleslib/i18n/localize_misra_analyzer.go b/cruleslib/i18n/localize_misra_analyzer.go index 7047cba737..6d420ad5c5 100644 --- a/cruleslib/i18n/localize_misra_analyzer.go +++ b/cruleslib/i18n/localize_misra_analyzer.go @@ -31,7 +31,45 @@ var languageMap = map[string]language.Tag{"en": language.English, "zh": language func localizeErrorMessage(result *pb.Result, p *message.Printer) string { switch result.ErrorKind { case pb.Result_MISRA_C_2012_RULE_1_1_STRUCT_MEMBER: - return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n%s%s%s", result.Name, result.StructMemberCount, result.StructMemberLimit) + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER%s%s%s", result.Name, result.StructMemberCount, result.StructMemberLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_FUNCTION_PARM: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM%s%s%s", result.Name, result.FunctionParmCount, result.FunctionParmLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_FUNCTION_ARG: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG%s%s%s", result.Name, result.FunctionArgCount, result.FunctionArgLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_RECORD: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD%s%s%s", result.Name, result.NestedRecordCount, result.NestedRecordLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_EXPR: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR%s%s%s", result.Name, result.NestedExprCount, result.NestedExprLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_SWITCH_CASE: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE%s%s%s", result.Name, result.SwitchCaseCount, result.SwitchCaseLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_ENUM_CONSTANT: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT%s%s%s", result.Name, result.EnumConstantCount, result.EnumConstantLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_STRING_CHAR: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR%s%s%s", result.Name, result.StringCharCount, result.StringCharLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_EXTERN_ID: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID%s%s%s", result.Name, result.ExternIdCount, result.ExternIdLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_EXTERN_ID_CHAR: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n%s: %s\nFirst identifier location: %s\nDuplicated identifier '%s' location: %s", result.Kind, result.Name, result.Loc, result.ExternalMessage, result.OtherLoc) + case pb.Result_MISRA_C_2012_RULE_1_1_MACRO_ID: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID%s%s%s", result.Name, result.MacroIdCount, result.MacroIdLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_MACRO_PARM: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM%s%s%s", result.Name, result.MacroParmCount, result.MacroParmLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_MACRO_ARG: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG%s%s%s", result.Name, result.MacroArgCount, result.MacroArgLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_BLOCK: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK%s%s%s", result.Name, result.NestedBlockCount, result.NestedBlockLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_INCLUDE: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE%s%s%s", result.Name, result.NestedIncludeCount, result.NestedIncludeLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_IOM_ID_CHAR: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR%s%s%s", result.Name, result.IomIdCharCount, result.IomIdCharLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_COND_INCLU: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU%s%s%s", result.Name, result.NestedCondIncluCount, result.NestedCondIncluLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_BLOCK_ID: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID%s%s%s", result.Name, result.BlockIdCount, result.BlockIdLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_NESTED_DECL: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL%s%s%s", result.Name, result.NestedDeclCount, result.NestedDeclLimit) + case pb.Result_MISRA_C_2012_RULE_1_1_MODIFY_DECL: + return p.Sprintf("[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL%s%s%s", result.Name, result.ModifyDeclCount, result.ModifyDeclLimit) case pb.Result_MISRA_C_2012_RULE_1_3: return p.Sprintf("[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_1_4: @@ -86,6 +124,8 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0702][misra-c2012-6.1]: violation of misra-c2012-6.1") case pb.Result_MISRA_C_2012_RULE_6_2: return p.Sprintf("[C0701][misra-c2012-6.2]: violation of misra-c2012-6.2") + case pb.Result_MISRA_C_2012_RULE_6_3: + return p.Sprintf("[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3") case pb.Result_MISRA_C_2012_RULE_7_1: return p.Sprintf("[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1") case pb.Result_MISRA_C_2012_RULE_7_2: @@ -98,6 +138,8 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0901][misra-c2012-7.4]: Assignment violation of misra-c2012-7.4\ntry to assign string literal to object with improper type\nLocation: %s", result.Loc) case pb.Result_MISRA_C_2012_RULE_7_4_EXTERNAL: return p.Sprintf("[C0901][misra-c2012-7.4]: violation of misra-c2012-7.4\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_7_5: + return p.Sprintf("[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_8_1: return p.Sprintf("[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_8_2_FUNC_DECL_PARM_NOT_NAMED_ERROR: @@ -142,6 +184,12 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0503][misra-c2012-8.12]: violation of misra-c2012-8.12") case pb.Result_MISRA_C_2012_RULE_8_14: return p.Sprintf("[C0501][misra-c2012-8.14]: violation of misra-c2012-8.14") + case pb.Result_MISRA_C_2012_RULE_8_15: + return p.Sprintf("[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_8_16: + return p.Sprintf("[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16") + case pb.Result_MISRA_C_2012_RULE_8_17: + return p.Sprintf("[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17") case pb.Result_MISRA_C_2012_RULE_9_1: return p.Sprintf("[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_9_2: @@ -302,6 +350,14 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C1501][misra-c2012-17.8]: violation of misra-c2012-17.8") case pb.Result_MISRA_C_2012_RULE_17_8: return p.Sprintf("[C1501][misra-c2012-17.8]: parameters should not be modified") + case pb.Result_MISRA_C_2012_RULE_17_9: + return p.Sprintf("[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_17_10: + return p.Sprintf("[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10") + case pb.Result_MISRA_C_2012_RULE_17_12: + return p.Sprintf("[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12") + case pb.Result_MISRA_C_2012_RULE_17_13: + return p.Sprintf("[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_18_1: return p.Sprintf("[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_18_2: @@ -376,6 +432,8 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0410][misra-c2012-21.11]: violation of misra-c2012-21.11") case pb.Result_MISRA_C_2012_RULE_21_12: return p.Sprintf("[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12") + case pb.Result_MISRA_C_2012_RULE_21_12_AMD3: + return p.Sprintf("[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3") case pb.Result_MISRA_C_2012_RULE_21_13: return p.Sprintf("[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_21_14: @@ -398,6 +456,12 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0401][misra-c2012-21.20]: violation of misra-c2012-21.20\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_21_21: return p.Sprintf("[C0421][misra-c2012-21.21]: violation of misra-c2012-21.21") + case pb.Result_MISRA_C_2012_RULE_21_22: + return p.Sprintf("[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_21_23: + return p.Sprintf("[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23") + case pb.Result_MISRA_C_2012_RULE_21_24: + return p.Sprintf("[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24") case pb.Result_MISRA_C_2012_RULE_22_1: return p.Sprintf("[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_22_2: @@ -418,6 +482,16 @@ func localizeErrorMessage(result *pb.Result, p *message.Printer) string { return p.Sprintf("[C0202][misra-c2012-22.9]: violation of misra-c2012-22.9\n%s", result.ExternalMessage) case pb.Result_MISRA_C_2012_RULE_22_10: return p.Sprintf("[C0201][misra-c2012-22.10]: violation of misra-c2012-22.10\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_23_1: + return p.Sprintf("[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1") + case pb.Result_MISRA_C_2012_RULE_23_2: + return p.Sprintf("[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2") + case pb.Result_MISRA_C_2012_RULE_23_3: + return p.Sprintf("[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3") + case pb.Result_MISRA_C_2012_RULE_23_4: + return p.Sprintf("[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n%s", result.ExternalMessage) + case pb.Result_MISRA_C_2012_RULE_23_5: + return p.Sprintf("[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5") case pb.Result_MISRA_C_2012_DIR_4_3_ASM_SHOULD_BE_ISOLATED: return p.Sprintf("[C2306][misra-c2012-dir-4.3]: assembly code should be isolated") case pb.Result_MISRA_C_2012_DIR_4_3_ASM_SHOULD_BE_ENCAPSULATED: diff --git a/cruleslib/issuecode/issuecode.go b/cruleslib/issuecode/issuecode.go index 8627b84d24..8317b422da 100644 --- a/cruleslib/issuecode/issuecode.go +++ b/cruleslib/issuecode/issuecode.go @@ -565,6 +565,46 @@ var misraCppIssueCodeMap = map[string]string{ "rule_27_0_1": "CXX5671", } +var certIssueCodeMap = map[string]string{ + "cert_dcl21_cpp": "T0711", + "cert_dcl50_cpp": "T0713", + "cert_dcl58_cpp": "T0716", + "cert_env33_c": "T0718", + "cert_err33_c": "T0720", + "cert_err34_c": "T0721", + "cert_err52_cpp": "T0722", + "cert_err58_cpp": "T0723", + "cert_err60_cpp": "T0724", + "cert_flp30_c": "T0728", + "cert_mem57_cpp": "T0730", + "cert_msc50_cpp": "T0733", + "cert_msc30_c": "T0731", + "cert_msc51_cpp": "T0734", + "cert_msc32_c": "T0732", + "cert_oop57_cpp": "T0737", + "cert_oop58_cpp": "T0738", + "cert_con54_cpp": "T0708", + "cert_con36_c": "T0707", + "cert_dcl03_c": "T0709", + "cert_dcl16_c": "T0710", + "cert_dcl37_c": "T0712", + "cert_dcl51_cpp": "T0714", + "cert_dcl54_cpp": "T0715", + "cert_dcl59_cpp": "T0717", + "cert_err61_cpp": "T0725", + "cert_err09_cpp": "T0719", + "cert_exp42_c": "T0726", + "cert_flp37_c": "T0729", + "cert_fio38_c": "T0727", + "cert_sig30_c": "T0741", + "cert_msc54_cpp": "T0741", + "cert_oop11_cpp": "T0735", + "cert_oop54_cpp": "T0736", + "cert_pos44_c": "T0739", + "cert_pos47_c": "T0740", + "cert_str34_c": "T0742", +} + func GetIssueCode(edition string, ruleName string) string { switch edition { case "gjb5369": @@ -585,6 +625,12 @@ func GetIssueCode(edition string, ruleName string) string { } else { return "" } + case "cert": + if _, exist := certIssueCodeMap[ruleName]; exist { + return certIssueCodeMap[ruleName] + } else { + return "" + } default: return "" } diff --git a/cruleslib/options/optionparser.go b/cruleslib/options/optionparser.go index 9b73630223..8840a5381e 100644 --- a/cruleslib/options/optionparser.go +++ b/cruleslib/options/optionparser.go @@ -36,9 +36,10 @@ import ( "naive.systems/analyzer/cruleslib/i18n" "naive.systems/analyzer/cruleslib/stats" "naive.systems/analyzer/misra/analyzer/analyzerinterface" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) -var supportProjectType = map[string]analyzerinterface.ProjectType{"makefile": analyzerinterface.Make, "cmake": analyzerinterface.CMake, "keil": analyzerinterface.Keil, "qmake": analyzerinterface.QMake, "script": analyzerinterface.Script} +var supportProjectType = map[string]analyzerinterface.ProjectType{"makefile": analyzerinterface.Make, "cmake": analyzerinterface.CMake, "keil": analyzerinterface.Keil, "qmake": analyzerinterface.QMake, "script": analyzerinterface.Script, "none": analyzerinterface.None} var supportIncludeStddef = map[string]bool{"pure": true, "armgcc": true, "none": true} func ConcatStringField(concatString string, stringField *string) *string { @@ -63,9 +64,10 @@ func ParseProjectType(sharedOptions *SharedOptions) (analyzerinterface.ProjectTy func ProcessKeilProject(sharedOptions *SharedOptions) { // Process keil project convertCmd := exec.Command("python", "converter.py", "uvprojx", sharedOptions.GetSrcDir()) - convertCmd.Dir = "/ProjectConverter/" + convertCmd.Dir = "/opt/naivesystems/projectconverter/" glog.Info("executing: ", convertCmd.String()) if err := convertCmd.Run(); err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } @@ -76,6 +78,7 @@ func ProcessKeilProject(sharedOptions *SharedOptions) { cmd := exec.Command("cmake", cmd_arr...) tempDir, err := os.MkdirTemp("/tmp/", "") if err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } @@ -84,6 +87,7 @@ func ProcessKeilProject(sharedOptions *SharedOptions) { glog.Info("executing: ", cmd.String()) err = analyzerinterface.PrintCmdOutput(cmd) if err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } @@ -92,18 +96,21 @@ func ProcessKeilProject(sharedOptions *SharedOptions) { dst := filepath.Join(sharedOptions.GetSrcDir(), "compile_commands.json") fin, err := os.Open(src) if err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } defer fin.Close() fout, err := os.Create(dst) if err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } defer fout.Close() _, err = io.Copy(fout, fin) if err != nil { + telemetry.Wait() glog.Fatal(err) os.Exit(1) } @@ -235,6 +242,7 @@ func ParseCheckerConfig(sharedOptions *SharedOptions, numWorkers int32, cpplines parsedCheckerConfig := &pb.CheckerConfiguration{} err := protojson.Unmarshal([]byte(sharedOptions.GetCheckerConfig()), parsedCheckerConfig) if err != nil { + telemetry.Wait() glog.Fatal("parsing checker config: ", err) } // replace parsedCheckerConfig if some field set by standalone options @@ -250,9 +258,6 @@ func ParseCheckerConfig(sharedOptions *SharedOptions, numWorkers int32, cpplines if sharedOptions.GetClangtidyBin() != "" { parsedCheckerConfig.ClangtidyBin = sharedOptions.GetClangtidyBin() } - if sharedOptions.GetCodeCheckerBin() != "" { - parsedCheckerConfig.CodeCheckerBin = sharedOptions.GetCodeCheckerBin() - } if sharedOptions.GetCppcheckBin() != "" { parsedCheckerConfig.CppcheckBin = sharedOptions.GetCppcheckBin() } @@ -331,6 +336,9 @@ func CheckCodeLines(compileCommandsPath string, sharedOptions *SharedOptions, li if err != nil { return clines, cpplines, fmt.Errorf("failed to check header lines: %v", err) } + telemetry.Send("lines of C code", "clines", clines) + telemetry.Send("lines of C++ code", "cpplines", cpplines) + telemetry.Send("lines of headers", "headerlines", headerlines) if cpplines == 0 && clines == 0 && headerlines == 0 { basic.PrintfWithTimeStamp(printer.Sprintf("%d lines of C code", clines)) basic.PrintfWithTimeStamp(printer.Sprintf("%d lines of C++ code", cpplines)) diff --git a/cruleslib/options/options.go b/cruleslib/options/options.go index 035de002ac..85b571fcf6 100644 --- a/cruleslib/options/options.go +++ b/cruleslib/options/options.go @@ -39,27 +39,26 @@ type CheckOptions struct { } type EnvOptions struct { - ResultsDir string - BuildActions *[]csa.BuildAction - CheckerConfig *pb.CheckerConfiguration - IgnoreDirPatterns analyzerinterface.ArrayFlags - CheckProgress bool - EnableCodeChecker bool - DumpErrors map[string]string - Debug bool - AvailMemRatio float64 - LimitMemory bool - NumWorkers int32 - IsDev bool - TimeoutNormal int - TimeoutOom int - Lang string - OnlyCppcheck bool - DisableParallelismInChecker bool - - LogDir string - - CheckerPathsMap map[string]string + ResultsDir string `json:"resultsDir"` + BuildActions *[]csa.BuildAction `json:"buildActions,omitempty"` + CheckerConfig *pb.CheckerConfiguration `json:"checkerConfig,omitempty"` + IgnoreDirPatterns analyzerinterface.ArrayFlags `json:"ignoreDirPatterns,omitempty"` + CheckProgress bool `json:"checkProgress"` + DumpErrors map[string]string `json:"dumpErrors,omitempty"` + Debug bool `json:"debug"` + AvailMemRatio float64 `json:"availMemRatio"` + LimitMemory bool `json:"limitMemory"` + NumWorkers int32 `json:"numWorkers"` + IsDev bool `json:"isDev"` + TimeoutNormal int `json:"timeoutNormal"` + TimeoutOom int `json:"timeoutOom"` + Lang string `json:"lang"` + OnlyCppcheck bool `json:"onlyCppcheck"` + DisableParallelismInChecker bool `json:"disableParallelismInChecker"` + + LogDir string `json:"logDir"` + + CheckerPathsMap map[string]string `json:"checkerPathsMap,omitempty"` } type RuleSpecificOptions struct { @@ -107,7 +106,6 @@ func NewEnvOptions( checkerConfig *pb.CheckerConfiguration, ignoreDirPatterns analyzerinterface.ArrayFlags, checkProgress bool, - enableCodeChecker bool, ignoreCpp bool, debug bool, limitMemory bool, @@ -125,7 +123,6 @@ func NewEnvOptions( envOptions.BuildActions = &[]csa.BuildAction{} envOptions.CheckerConfig = checkerConfig envOptions.CheckProgress = checkProgress - envOptions.EnableCodeChecker = enableCodeChecker envOptions.IgnoreDirPatterns = ignoreDirPatterns envOptions.Debug = debug envOptions.CheckerPathsMap = checkerPathsMap @@ -183,7 +180,6 @@ func NewEnvOptions( envOptions.ResultsDir, envOptions.CheckerConfig, envOptions.CheckProgress, - envOptions.EnableCodeChecker, envOptions.NumWorkers, envOptions.IgnoreDirPatterns, envOptions.Lang, @@ -217,7 +213,6 @@ func NewEnvOptionsFromShared( checkerConfig, sharedOptions.GetIgnoreDirPatterns(), sharedOptions.GetCheckProgress(), - sharedOptions.GetEnableCodeChecker(), ignoreCpp, sharedOptions.GetDebugMode(), sharedOptions.GetLimitMemory(), diff --git a/cruleslib/options/sharedoptions.go b/cruleslib/options/sharedoptions.go index db22aca3ce..d94fe7fec2 100644 --- a/cruleslib/options/sharedoptions.go +++ b/cruleslib/options/sharedoptions.go @@ -25,51 +25,50 @@ import ( ) type SharedOptions struct { - AddLineHash *bool - AllowBuildFail *bool - AvailMemRatio *float64 - CheckProgress *bool - CheckerConfig *string - CheckerPathRoot *string - ClangBin *string - ClangmappingBin *string - ClangqueryBin *string - ClangtidyBin *string - CmakeCXXCompiler *string - CmakeExportCompileCommands *bool - CodeCheckerBin *string - ConfigDir *string - CppcheckBin *string - CpplintScript *string - CsaSystemLibOptions *string - DebugMode *bool - EnableCodeChecker *bool - GccPredefinedMacros *string - IgnoreDirPatterns analyzerinterface.ArrayFlags - IncludeStddef *string - InferBin *string - InferExtraOptions *string - InferJobs *int64 - KeepBuildActionPercent *float64 - Lang *string - LimitMemory *bool - MisraCheckerPath *string - ProjectName *string - ProjectType *string - PythonBin *string - QmakeBin *string - QtProPath *string - ResultsDir *string - ScriptContents *string - ShowJsonResults *bool - ShowLineNumber *bool - ShowResults *bool - ShowResultsCount *bool - SkipBearMake *bool - SrcDir *string - TimeoutNormal *int - TimeoutOom *int - DisableParallelismInChecker *bool + AddLineHash *bool `json:"addLineHash,omitempty"` + AllowBuildFail *bool `json:"allowBuildFail,omitempty"` + AvailMemRatio *float64 `json:"availMemRatio,omitempty"` + CheckProgress *bool `json:"checkProgress,omitempty"` + CheckerConfig *string `json:"checkerConfig,omitempty"` + CheckerPathRoot *string `json:"checkerPathRoot,omitempty"` + ClangBin *string `json:"clangBin,omitempty"` + ClangmappingBin *string `json:"clangmappingBin,omitempty"` + ClangqueryBin *string `json:"clangqueryBin,omitempty"` + ClangtidyBin *string `json:"clangtidyBin,omitempty"` + CmakeCXXCompiler *string `json:"cmakeCXXCompiler,omitempty"` + CmakeExportCompileCommands *bool `json:"cmakeExportCompileCommands,omitempty"` + ConfigDir *string `json:"configDir,omitempty"` + CppcheckBin *string `json:"cppcheckBin,omitempty"` + CpplintScript *string `json:"cpplintScript,omitempty"` + CsaSystemLibOptions *string `json:"csaSystemLibOptions,omitempty"` + DebugMode *bool `json:"debugMode,omitempty"` + GccPredefinedMacros *string `json:"gccPredefinedMacros,omitempty"` + IgnoreDirPatterns analyzerinterface.ArrayFlags `json:"ignoreDirPatterns,omitempty"` + IncludeStddef *string `json:"includeStddef,omitempty"` + InferBin *string `json:"inferBin,omitempty"` + InferExtraOptions *string `json:"inferExtraOptions,omitempty"` + InferJobs *int64 `json:"inferJobs,omitempty"` + KeepBuildActionPercent *float64 `json:"keepBuildActionPercent,omitempty"` + Lang *string `json:"lang,omitempty"` + LimitMemory *bool `json:"limitMemory,omitempty"` + MisraCheckerPath *string `json:"misraCheckerPath,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + ProjectType *string `json:"projectType,omitempty"` + PythonBin *string `json:"pythonBin,omitempty"` + QmakeBin *string `json:"qmakeBin,omitempty"` + QtProPath *string `json:"qtProPath,omitempty"` + ResultsDir *string `json:"resultsDir,omitempty"` + ScriptContents *string `json:"scriptContents,omitempty"` + SemgrepBin *string `json:"semgrepBin,omitempty"` + ShowJsonResults *bool `json:"showJsonResults,omitempty"` + ShowLineNumber *bool `json:"showLineNumber,omitempty"` + ShowResults *bool `json:"showResults,omitempty"` + ShowResultsCount *bool `json:"showResultsCount,omitempty"` + SkipBearMake *bool `json:"skipBearMake,omitempty"` + SrcDir *string `json:"srcDir,omitempty"` + TimeoutNormal *int `json:"timeoutNormal,omitempty"` + TimeoutOom *int `json:"timeoutOom,omitempty"` + DisableParallelismInChecker *bool `json:"disableParallelismInChecker,omitempty"` } func (s SharedOptions) GetAddLineHash() bool { @@ -120,10 +119,6 @@ func (s SharedOptions) GetCmakeExportCompileCommands() bool { return *s.CmakeExportCompileCommands } -func (s SharedOptions) GetCodeCheckerBin() string { - return *s.CodeCheckerBin -} - func (s SharedOptions) GetConfigDir() string { return *s.ConfigDir } @@ -144,10 +139,6 @@ func (s SharedOptions) GetDebugMode() bool { return *s.DebugMode } -func (s SharedOptions) GetEnableCodeChecker() bool { - return *s.EnableCodeChecker -} - func (s SharedOptions) GetGccPredefinedMacros() string { return *s.GccPredefinedMacros } @@ -272,6 +263,10 @@ func (s SharedOptions) SetSrcDir(srcdir string) { *s.SrcDir = srcdir } +func (s SharedOptions) GetSemgrepBin() string { + return *s.SemgrepBin +} + type DefaultOptionValues struct { AddLineHash bool AllowBuildFail bool @@ -285,13 +280,11 @@ type DefaultOptionValues struct { ClangtidyBin string CmakeCXXCompiler string CmakeExportCompileCommands bool - CodeCheckerBin string ConfigDir string CppcheckBin string CpplintScript string CsaSystemLibOptions string DebugMode bool - EnableCodeChecker bool GccPredefinedMacros string IgnoreDirPatterns analyzerinterface.ArrayFlags IncludeStddef string @@ -309,6 +302,7 @@ type DefaultOptionValues struct { QtProPath string ResultsDir string ScriptContents string + SemgrepBin string ShowJsonResults bool ShowLineNumber bool ShowResults bool @@ -326,10 +320,9 @@ var Defaults = DefaultOptionValues{ AvailMemRatio: 0.9, CheckProgress: true, CheckerConfig: `{"csa_system_lib_options":"", - "infer_bin":"infer", + "infer_bin":"/opt/naivesystems/infer/bin/infer", "clang_bin":"/opt/naivesystems/clang", - "code_checker_bin":"CodeChecker", - "cppcheck_bin":"/cppcheck/cppcheck", + "cppcheck_bin":"/opt/naivesystems/cppcheck/cppcheck", "python_bin":"python3", "clangtidy_bin":"/opt/naivesystems/clang-tidy", "clangquery_bin":"/opt/naivesystems/clang-query", @@ -337,7 +330,8 @@ var Defaults = DefaultOptionValues{ "infer_extra_options":"--max-nesting=3 --bo-field-depth-limit=6", "clangmapping_bin":"/opt/naivesystems/clang-extdef-mapping", "infer_jobs":8, - "cpplint_script":"/opt/naivesystems/cpplint.py"}`, + "cpplint_script":"/opt/naivesystems/cpplint.py", + "semgrep_bin": "semgrep"}`, CheckerPathRoot: "/opt/naivesystems/", ClangBin: "", ClangmappingBin: "/opt/naivesystems/clang-extdef-mapping", @@ -345,13 +339,11 @@ var Defaults = DefaultOptionValues{ ClangtidyBin: "", CmakeCXXCompiler: "clang", CmakeExportCompileCommands: true, - CodeCheckerBin: "", ConfigDir: "/config", CppcheckBin: "", CpplintScript: "/opt/naivesystems/cpplint.py", CsaSystemLibOptions: "", DebugMode: false, - EnableCodeChecker: false, GccPredefinedMacros: "", IgnoreDirPatterns: []string{"/src/output/**"}, IncludeStddef: "pure", @@ -369,6 +361,7 @@ var Defaults = DefaultOptionValues{ QtProPath: "", ResultsDir: "/output", ScriptContents: "", + SemgrepBin: "semgrep", ShowJsonResults: true, ShowLineNumber: true, ShowResults: false, @@ -396,13 +389,11 @@ func NewSharedOptions() *SharedOptions { option.ClangtidyBin = flag.String("clangtidy_bin", Defaults.ClangtidyBin, "Clang-tidy binary location") option.CmakeCXXCompiler = flag.String("cmake_CXX_compiler", Defaults.CmakeCXXCompiler, "Path of a valid CXX compipler, default clang") option.CmakeExportCompileCommands = flag.Bool("cmake_export_cc", Defaults.CmakeExportCompileCommands, "Directly generate compile commands from CMakeLists.txt") - option.CodeCheckerBin = flag.String("code_checker_bin", Defaults.CodeCheckerBin, "CodeChecker binary location") option.ConfigDir = flag.String("config_dir", Defaults.ConfigDir, "Absolute path to a directory containing all configuration files") option.CppcheckBin = flag.String("cppcheck_bin", Defaults.CppcheckBin, "Cppcheck binary location") option.CpplintScript = flag.String("cpplint_script", Defaults.CpplintScript, "Cpplint script location") option.CsaSystemLibOptions = flag.String("csa_system_lib_options", Defaults.CsaSystemLibOptions, "Include path for clang") option.DebugMode = flag.Bool("debug_mode", Defaults.DebugMode, "Whether to display error information") - option.EnableCodeChecker = flag.Bool("enable_codechecker", Defaults.EnableCodeChecker, "Use CodeChecker to perform CTU pre-analysis for CSA") option.GccPredefinedMacros = flag.String("gcc_predefined_macros", Defaults.GccPredefinedMacros, "Gcc predefiend macro arguments") option.IncludeStddef = flag.String("include_stddef", Defaults.IncludeStddef, "How to include . Support pure(using -include), armgcc(including from arm-none-eabi) and none") option.InferBin = flag.String("infer_bin", Defaults.InferBin, "Infer binary location") @@ -419,12 +410,13 @@ func NewSharedOptions() *SharedOptions { option.QtProPath = flag.String("qt_pro_path", Defaults.QtProPath, "Path of the Qt project file relative to src_dir") option.ResultsDir = flag.String("results_dir", Defaults.ResultsDir, "Absolute path to the directory of results files") option.ScriptContents = flag.String("script_contents", Defaults.ScriptContents, "The contents of script to generate compile_commands.json") + option.SemgrepBin = flag.String("semgrep_bin", Defaults.SemgrepBin, "Semgrep binary location") option.ShowJsonResults = flag.Bool("json_results", Defaults.ShowJsonResults, "Whether to output results in protojson format") option.ShowLineNumber = flag.Bool("show_line_number", Defaults.ShowLineNumber, "Show line count infomation") option.ShowResults = flag.Bool("show_results", Defaults.ShowResults, "Show results after the analysis") option.ShowResultsCount = flag.Bool("show_results_count", Defaults.ShowResultsCount, "Show results count group by rules after the analysis") option.SkipBearMake = flag.Bool("skip_bear_make", Defaults.SkipBearMake, "Skip running `bear -- make` to generate compilation database before the analysis") - option.SrcDir = flag.String("src_dir", Defaults.SrcDir, "Absolute path to the directory of code files") + option.SrcDir = flag.String("src_dir", Defaults.SrcDir, "Path to the directory of code files in the working environment. If it is a relative path, it will be converted to an absolute one which is relative to the current directory") option.TimeoutNormal = flag.Int("timeout_normal", Defaults.TimeoutNormal, "Minutes of timeout for checking single rule. Default value is 90") option.TimeoutOom = flag.Int("timeout_oom", Defaults.TimeoutOom, "Minutes of timeout for specific checkers when limit memory enabled. Default value is 30") option.DisableParallelismInChecker = flag.Bool("disable_parallelism_in_checker", Defaults.DisableParallelismInChecker, "Disable the parallelism of checking multiple files") diff --git a/cruleslib/runner/runner.go b/cruleslib/runner/runner.go index 3f36bb8604..bc7f475bab 100644 --- a/cruleslib/runner/runner.go +++ b/cruleslib/runner/runner.go @@ -19,7 +19,9 @@ along with this program. If not, see . package runner import ( + "bufio" "container/list" + "encoding/json" "errors" "fmt" "os" @@ -38,6 +40,7 @@ import ( "github.com/golang/glog" "golang.org/x/text/message" "google.golang.org/protobuf/proto" + "gopkg.in/yaml.v2" pb "naive.systems/analyzer/analyzer/proto" "naive.systems/analyzer/cruleslib/basic" "naive.systems/analyzer/cruleslib/filter" @@ -46,10 +49,12 @@ import ( "naive.systems/analyzer/cruleslib/options" "naive.systems/analyzer/cruleslib/severity" "naive.systems/analyzer/cruleslib/stats" + "naive.systems/analyzer/diff" "naive.systems/analyzer/misra/analyzer" "naive.systems/analyzer/misra/analyzer/analyzerinterface" "naive.systems/analyzer/misra/checker_integration" "naive.systems/analyzer/misra/checker_integration/checkrule" + "naive.systems/analyzer/misra/checker_integration/clangformat" "naive.systems/analyzer/misra/checker_integration/clangsema" "naive.systems/analyzer/misra/checker_integration/cppcheck" "naive.systems/analyzer/misra/checker_integration/cpplint" @@ -58,6 +63,7 @@ import ( "naive.systems/analyzer/misra/checker_integration/infer" "naive.systems/analyzer/misra/checker_integration/libtooling" "naive.systems/analyzer/misra/checker_integration/misra" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) // The task for Runner to run in parallels @@ -104,12 +110,14 @@ func modifyResult(result *analyzerResult) { // autosar/rule_AX_X_X -> [AX_X_X][autosar-AX.X.X] // autosar/rule_MX_X_X -> [MX_X_X][autosar-MX.X.X] // cwe/cwe_401 -> [CWE_401][cwe-cwe_401] + // cert/cert_dcl21_cpp -> [T0711][cert_dcl21_cpp] edition := strings.Split(result.rule, "/")[0] ruleName := strings.Split(result.rule, "/")[1] ruleStr := strings.Join(strings.Split(ruleName, "_")[1:], ".") issueCode := issuecode.GetIssueCode(edition, ruleName) if issueCode == "" { - if edition == "misra_cpp_2008" || strings.HasPrefix(edition, "gjb") { + if edition == "misra_cpp_2008" || strings.HasPrefix(edition, "gjb") || + edition == "cert" { glog.Warning("There is no available issue code for ", result.rule) // mock for the issue code parsing of the vscode extension issueCode = "-" @@ -120,12 +128,13 @@ func modifyResult(result *analyzerResult) { r.ErrorMessage = fmt.Sprintf("[%s][%s-%s]: %s", strings.ToUpper(ruleName), edition, ruleName, r.ErrorMessage) } } - issueCode = "[" + issueCode + "]" if edition == "misra_cpp_2008" { - r.ErrorMessage = issueCode + "[misra-cpp2008-" + ruleStr + "]: " + r.ErrorMessage + r.ErrorMessage = fmt.Sprintf("[%s][misra-cpp2008-%s]: %s", issueCode, ruleStr, r.ErrorMessage) } else if strings.HasPrefix(edition, "gjb") { subEdition := strings.TrimPrefix(edition, "gjb") - r.ErrorMessage = issueCode + "[gjb-" + subEdition + "-" + ruleStr + "]: " + r.ErrorMessage + r.ErrorMessage = fmt.Sprintf("[%s][gjb-%s-%s]: %s", issueCode, subEdition, ruleStr, r.ErrorMessage) + } else if edition == "cert" { + r.ErrorMessage = fmt.Sprintf("[%s][%s]: %s", issueCode, ruleName, r.ErrorMessage) } r.Ruleset = edition r.RuleId = ruleName @@ -175,6 +184,7 @@ func NewParaTaskRunner(numWorkers int32, taskNums int, showProgress bool, lang s printer := i18n.GetPrinter(lang) if numWorkers == 0 { numWorkers = int32(runtime.NumCPU()) + telemetry.Send("Use CPU(s)", "numWorkers", numWorkers) if showProgress { basic.PrintfWithTimeStamp(printer.Sprintf("Use %d CPU(s)", numWorkers)) } @@ -204,6 +214,7 @@ func NewParaTaskRunner(numWorkers int32, taskNums int, showProgress bool, lang s select { case <-sigs: // if recived a SIGINT, stop collector and analyze rule loop + telemetry.Send("Ctrl C Pressed. Stop analysis") if paraRunner.showProgress { basic.PrintfWithTimeStamp("Ctrl C Pressed. Stop analysis") } @@ -321,6 +332,7 @@ func RunMisraAnalyze(srcdir string, misraCheckRules []checkrule.CheckRule, check } filteredCompileCommandsFolder, err := analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(compileCommandsPath) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(: %v", err) } defer os.RemoveAll(filteredCompileCommandsFolder) @@ -417,6 +429,7 @@ func RunInfer(srcdir string, inferPlugin string, checkOptions *options.CheckOpti } filteredCompileCommandsFolder, err := analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(compileCommandsPath) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile: %v", err) } defer os.RemoveAll(filteredCompileCommandsFolder) @@ -491,6 +504,7 @@ func RunLibtoolingWithExtraArgs(srcdir string, ruleName string, extraArgsStr str } filteredCompileCommandsFolder, err := analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(compileCommandsPath) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(: %v", err) } defer os.RemoveAll(filteredCompileCommandsFolder) @@ -616,6 +630,21 @@ func RunCpplint(srcdir, filter string, opts *options.CheckOptions) ([]cpplint.Re return runner.Run(srcdir, filter) } +func RunClangFormat(srcdir, style, compileCommandsPath string, opts *options.CheckOptions) ([]clangformat.Report, error) { + srcs, err := analyzer.ListSourceFiles(compileCommandsPath, opts.EnvOption.IgnoreDirPatterns) + if err != nil { + glog.Errorf("analyzer list source files error: %v", err) + return nil, err + } + runner := &clangformat.Runner{ + TaskName: filepath.Base(opts.EnvOption.ResultsDir), + LimitMemory: opts.EnvOption.LimitMemory, + TimeoutNormal: opts.EnvOption.TimeoutNormal, + TimeoutOom: opts.EnvOption.TimeoutOom, + } + return runner.Run(srcs, style) +} + func RunClangSema(srcdir, cmd_arg string, opts *options.CheckOptions) ([]clangsema.Diagnostic, error) { // TODO: pass compileCommandsPath as function arguments compileCommandsPath := options.GetCompileCommandsPath(srcdir) @@ -644,6 +673,7 @@ func RunClangTidy(srcdir string, cmd_arg []string, opts *options.CheckOptions) ( } filteredCompileCommandsFolder, err := analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(compileCommandsPath) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(: %v", err) } defer os.RemoveAll(filteredCompileCommandsFolder) @@ -775,6 +805,190 @@ func RunHeaderCompile(srcdir string, ruleName string, checkOptions *options.Chec return results, nil } +func checkSingleCoccinelleRule(srcDir, ruleName, rulePath string, JSONOptions checkrule.JSONOption) (*pb.ResultsList, error) { + cmd := exec.Command("spatch", "--sp-file", rulePath, "--dir", srcDir, "--include-headers", "-U", "0") + glog.Info("executing: ", cmd.String()) + out, err := cmd.CombinedOutput() + if err != nil { + return nil, fmt.Errorf("%s: %v\n%s", cmd.String(), err, string(out)) + } + p, err := diff.Parse(string(out)) + if err != nil { + return nil, fmt.Errorf("diff.Parse: %v\n%s", err, string(out)) + } + errorMessage := ruleName + if JSONOptions.ErrorMessage != nil && *JSONOptions.ErrorMessage != "" { + errorMessage = fmt.Sprintf("%s: %s", ruleName, *JSONOptions.ErrorMessage) + } + results := &pb.ResultsList{} + for _, file := range p.Files { + for _, hunk := range file.Hunks { + path := file.OldName + if !filepath.IsAbs(path) { + path = filepath.Join(srcDir, path) + } + result := &pb.Result{ + Path: path, + LineNumber: int32(hunk.OldPos), + ErrorMessage: errorMessage, + } + results.Results = append(results.Results, result) + } + } + return results, nil +} + +func readFileLines(filename, suffix string) ([]checkrule.CheckRule, error) { + _, err := os.Stat(filename) + if err != nil { + return nil, err + } + file, err := os.Open(filename) + if err != nil { + return nil, err + } + defer file.Close() + scanner := bufio.NewScanner(file) + checkRules := make([]checkrule.CheckRule, 0) + for scanner.Scan() { + line := scanner.Text() + rulePath, jsonOptionStr, exists := strings.Cut(line, suffix) + if !exists { + return nil, fmt.Errorf("%s does not contain a valid rule file with suffix %s", line, suffix) + } + ruleName := rulePath + suffix + jsonOptionStr = strings.TrimSpace(jsonOptionStr) + if jsonOptionStr == "" { + jsonOptionStr = "{}" + } + checkRule, err := checkrule.MakeCheckRule(ruleName, jsonOptionStr) + if err != nil { + return nil, err + } + checkRules = append(checkRules, *checkRule) + } + return checkRules, nil +} + +func RunCoccinelle(srcDir, configDir string) (*pb.ResultsList, error) { + results := &pb.ResultsList{} + rulesPath := filepath.Join(configDir, "cocci_rules") + // cocci_rules format: + // find_alloca.cocci {"error-message": "SOME MESSAGE"} + rules, err := readFileLines(rulesPath, ".cocci") + if err != nil { + return results, fmt.Errorf("failed to read file lines: %s: %v", rulesPath, err) + } + for _, rule := range rules { + rulePath := rule.Name + if !filepath.IsAbs(rulePath) { + rulePath = filepath.Join(configDir, rulePath) + } + _, err := os.Stat(rulePath) + if err != nil { + return results, fmt.Errorf("os.Stat: %s: %v", rulePath, err) + } + ruleName := filepath.Base(rulePath) + singleRuleResults, err := checkSingleCoccinelleRule(srcDir, ruleName, rulePath, rule.JSONOptions) + if err != nil { + glog.Errorf("check %s: %v", ruleName, err) + continue + } + results.Results = append(results.Results, singleRuleResults.Results...) + } + return results, nil +} + +type SemgrepResult struct { + // pick useful fields in output results + Results []struct { + CheckID string `json:"check_id"` + Extra struct { + Message string `json:"message"` + } `json:"extra"` + Path string `json:"path"` + Start struct { + Line int `json:"line"` + } `json:"start"` + } `json:"results"` +} + +func checkSingleSemgrepRule(semgrepBin, srcDir, ruleName, rulePath string) (*pb.ResultsList, error) { + cmd := exec.Command(semgrepBin, "--config", rulePath, srcDir, "--quiet", "--json") + glog.Info("executing: ", cmd.String()) + out, err := cmd.CombinedOutput() + if err != nil { + return nil, fmt.Errorf("%s: %v\n%s", cmd.String(), err, string(out)) + } + var semgrepResult SemgrepResult + err = json.Unmarshal(out, &semgrepResult) + if err != nil { + return nil, fmt.Errorf("json.Unmarshal: %v", err) + } + results := &pb.ResultsList{} + for _, r := range semgrepResult.Results { + path := r.Path + if !filepath.IsAbs(path) { + path = filepath.Join(srcDir, path) + } + result := &pb.Result{ + Path: path, + LineNumber: int32(r.Start.Line), + ErrorMessage: fmt.Sprintf("[%s]: %s", ruleName, r.Extra.Message), + } + results.Results = append(results.Results, result) + } + return results, nil +} + +type SemgrepRule struct { + ID string `yaml:"id"` + Message string `yaml:"message"` + Languages []string `yaml:"languages"` + Severity string `yaml:"severity"` +} + +type SemgrepRulesConfig struct { + Rules []SemgrepRule `yaml:"rules"` +} + +func RunSemgrep(srcDir, configDir, semgrepBin string) (*pb.ResultsList, error) { + results := &pb.ResultsList{} + rulesPath := filepath.Join(configDir, "semgrep_rules") + rules, err := readFileLines(rulesPath, ".semgrep") + if err != nil { + return results, fmt.Errorf("failed to read file lines: %s: %v", rulesPath, err) + } + for _, rule := range rules { + rulePath := rule.Name + if !filepath.IsAbs(rulePath) { + rulePath = filepath.Join(configDir, rulePath) + } + _, err := os.Stat(rulePath) + if err != nil { + return results, fmt.Errorf("os.Stat: %s: %v", rulePath, err) + } + contents, err := os.ReadFile(rulePath) + if err != nil { + return results, fmt.Errorf("os.ReadFile: %s: %v", rulePath, err) + } + var config SemgrepRulesConfig + err = yaml.Unmarshal(contents, &config) + if err != nil { + return results, fmt.Errorf("yaml.Unmarshal: %s: %v", rulePath, err) + } + // Suppose only one rule is specified in the Semgrep rule file + ruleName := config.Rules[0].ID + singleRuleResults, err := checkSingleSemgrepRule(semgrepBin, srcDir, ruleName, rulePath) + if err != nil { + glog.Errorf("check %s: %v", rulePath, err) + continue + } + results.Results = append(results.Results, singleRuleResults.Results...) + } + return results, nil +} + type empty struct{} type set map[string]empty @@ -988,7 +1202,7 @@ func KeepNeededErrorByFilterTargetMsgInCSAReports(reportJson *csa.CSAReport, tar func CSAReportsToPBResults(reportJson *csa.CSAReport) *pb.ResultsList { resultsList := &pb.ResultsList{} if reportJson == nil || len(reportJson.Runs) == 0 { - return nil + return resultsList } for _, run := range reportJson.Runs { results := run.Results @@ -1006,7 +1220,7 @@ func CSAReportsToPBResults(reportJson *csa.CSAReport) *pb.ResultsList { func KeepNeededErrorByFilteringRuleIdInCSAReports(reportJson *csa.CSAReport, matchingRuleIdPattern string, newErrorMessage string, errKind pb.Result_ErrorKind) *pb.ResultsList { resultsList := &pb.ResultsList{} if reportJson == nil || len(reportJson.Runs) == 0 { - return nil + return resultsList } reg := regexp.MustCompile(matchingRuleIdPattern) for _, run := range reportJson.Runs { diff --git a/cruleslib/severity/severity.go b/cruleslib/severity/severity.go index 10514ef7ad..e215aa03b9 100644 --- a/cruleslib/severity/severity.go +++ b/cruleslib/severity/severity.go @@ -220,6 +220,309 @@ var severityMap = map[string]int32{ "misra_c_2012/rule_22_8": High, "misra_c_2012/rule_22_9": High, "misra_c_2012/rule_22_10": Medium, + "gjb5369/rule_1_1_1": Medium, + "gjb5369/rule_1_1_2": High, + "gjb5369/rule_1_1_3": Medium, + "gjb5369/rule_1_1_4": Medium, + "gjb5369/rule_1_1_5": Medium, + "gjb5369/rule_1_1_6": Medium, + "gjb5369/rule_1_1_7": Medium, + "gjb5369/rule_1_1_8": Medium, + "gjb5369/rule_1_1_9": High, + "gjb5369/rule_1_1_10": Medium, + "gjb5369/rule_1_1_11": Medium, + "gjb5369/rule_1_1_12": Medium, + "gjb5369/rule_1_1_13": Medium, + "gjb5369/rule_1_1_14": High, + "gjb5369/rule_1_1_15": Medium, + "gjb5369/rule_1_1_16": Medium, + "gjb5369/rule_1_1_17": Medium, + "gjb5369/rule_1_1_18": Medium, + "gjb5369/rule_1_1_19": Medium, + "gjb5369/rule_1_1_20": Medium, + "gjb5369/rule_1_1_21": Medium, + "gjb5369/rule_1_1_22": Medium, + "gjb5369/rule_1_2_1": Low, + "gjb5369/rule_1_2_2": Low, + "gjb5369/rule_1_2_3": Low, + "gjb5369/rule_1_2_4": Low, + "gjb5369/rule_1_2_5": Low, + "gjb5369/rule_1_2_6": Low, + "gjb5369/rule_1_2_7": Low, + "gjb5369/rule_1_2_8": Low, + "gjb5369/rule_1_2_9": Low, + "gjb5369/rule_2_1_1": Medium, + "gjb5369/rule_2_1_2": Medium, + "gjb5369/rule_2_1_3": Medium, + "gjb5369/rule_2_1_4": Medium, + "gjb5369/rule_2_1_5": Medium, + "gjb5369/rule_2_1_6": Medium, + "gjb5369/rule_2_1_7": Medium, + "gjb5369/rule_2_1_8": Medium, + "gjb5369/rule_2_1_9": Medium, + "gjb5369/rule_2_1_10": Medium, + "gjb5369/rule_2_2_1": Low, + "gjb5369/rule_2_2_2": Low, + "gjb5369/rule_3_1_1": Medium, + "gjb5369/rule_3_1_2": Medium, + "gjb5369/rule_3_1_3": Medium, + "gjb5369/rule_3_1_4": Medium, + "gjb5369/rule_3_1_5": Medium, + "gjb5369/rule_3_1_6": Medium, + "gjb5369/rule_3_1_7": Medium, + "gjb5369/rule_3_1_8": Medium, + "gjb5369/rule_4_1_1": High, + "gjb5369/rule_4_1_2": Medium, + "gjb5369/rule_4_1_3": High, + "gjb5369/rule_4_2_1": Low, + "gjb5369/rule_4_2_2": Low, + "gjb5369/rule_5_1_1": Medium, + "gjb5369/rule_5_1_2": Medium, + "gjb5369/rule_5_2_1": Low, + "gjb5369/rule_6_1_1": High, + "gjb5369/rule_6_1_2": High, + "gjb5369/rule_6_1_3": High, + "gjb5369/rule_6_1_4": High, + "gjb5369/rule_6_1_5": High, + "gjb5369/rule_6_1_6": High, + "gjb5369/rule_6_1_7": High, + "gjb5369/rule_6_1_8": High, + "gjb5369/rule_6_1_9": High, + "gjb5369/rule_6_1_10": High, + "gjb5369/rule_6_1_11": Medium, + "gjb5369/rule_6_1_12": High, + "gjb5369/rule_6_1_13": High, + "gjb5369/rule_6_1_14": High, + "gjb5369/rule_6_1_15": High, + "gjb5369/rule_6_1_16": High, + "gjb5369/rule_6_1_17": High, + "gjb5369/rule_6_1_18": High, + "gjb5369/rule_6_2_1": Low, + "gjb5369/rule_6_2_2": Low, + "gjb5369/rule_6_2_3": Low, + "gjb5369/rule_6_2_4": Low, + "gjb5369/rule_7_1_1": Medium, + "gjb5369/rule_7_1_2": Medium, + "gjb5369/rule_7_1_3": Medium, + "gjb5369/rule_7_1_4": High, + "gjb5369/rule_7_1_5": Medium, + "gjb5369/rule_7_1_6": High, + "gjb5369/rule_7_1_7": High, + "gjb5369/rule_7_1_8": High, + "gjb5369/rule_7_1_9": Medium, + "gjb5369/rule_7_1_10": Medium, + "gjb5369/rule_7_2_1": Low, + "gjb5369/rule_7_2_2": Low, + "gjb5369/rule_7_2_3": Low, + "gjb5369/rule_8_1_1": Medium, + "gjb5369/rule_8_1_2": Medium, + "gjb5369/rule_8_1_3": Medium, + "gjb5369/rule_8_2_1": Low, + "gjb5369/rule_8_2_2": Low, + "gjb5369/rule_8_2_3": Low, + "gjb5369/rule_8_2_4": Low, + "gjb5369/rule_8_2_5": Low, + "gjb5369/rule_8_2_6": Low, + "gjb5369/rule_8_2_7": Low, + "gjb5369/rule_8_2_8": Low, + "gjb5369/rule_9_1_1": High, + "gjb5369/rule_9_1_2": Medium, + "gjb5369/rule_9_1_3": High, + "gjb5369/rule_9_1_4": High, + "gjb5369/rule_9_1_5": High, + "gjb5369/rule_10_1_1": Medium, + "gjb5369/rule_10_2_1": Low, + "gjb5369/rule_10_2_2": Low, + "gjb5369/rule_11_1_1": High, + "gjb5369/rule_11_1_2": Medium, + "gjb5369/rule_11_2_1": Low, + "gjb5369/rule_11_2_2": Low, + "gjb5369/rule_11_2_3": Low, + "gjb5369/rule_12_1_1": High, + "gjb5369/rule_12_2_1": Low, + "gjb5369/rule_12_2_2": Low, + "gjb5369/rule_12_2_3": Low, + "gjb5369/rule_13_1_1": Medium, + "gjb5369/rule_13_1_2": Medium, + "gjb5369/rule_13_1_3": Medium, + "gjb5369/rule_13_1_4": High, + "gjb5369/rule_14_1_1": Medium, + "gjb5369/rule_14_1_2": High, + "gjb5369/rule_14_1_3": High, + "gjb5369/rule_14_2_1": Low, + "gjb5369/rule_15_1_1": Medium, + "gjb5369/rule_15_1_2": Medium, + "gjb5369/rule_15_1_3": Medium, + "gjb5369/rule_15_1_4": Medium, + "gjb5369/rule_15_1_5": Medium, + "gjb5369/rule_15_1_6": Medium, + "gjb5369/rule_15_2_1": Low, + "gjb5369/rule_15_2_2": Low, + "gjb8114/rule_1_1_1": High, + "gjb8114/rule_1_1_2": High, + "gjb8114/rule_1_1_3": Medium, + "gjb8114/rule_1_1_4": High, + "gjb8114/rule_1_1_5": Medium, + "gjb8114/rule_1_1_6": Medium, + "gjb8114/rule_1_1_7": Medium, + "gjb8114/rule_1_1_8": Medium, + "gjb8114/rule_1_1_9": Medium, + "gjb8114/rule_1_1_10": High, + "gjb8114/rule_1_1_11": High, + "gjb8114/rule_1_1_12": High, + "gjb8114/rule_1_1_13": Medium, + "gjb8114/rule_1_1_14": Medium, + "gjb8114/rule_1_1_15": Medium, + "gjb8114/rule_1_1_16": Medium, + "gjb8114/rule_1_1_17": Medium, + "gjb8114/rule_1_1_18": Medium, + "gjb8114/rule_1_1_19": Medium, + "gjb8114/rule_1_1_20": Medium, + "gjb8114/rule_1_1_21": Medium, + "gjb8114/rule_1_1_22": Medium, + "gjb8114/rule_1_1_23": Medium, + "gjb8114/rule_A_1_1_1": Low, + "gjb8114/rule_A_1_1_2": Low, + "gjb8114/rule_A_1_1_3": Low, + "gjb8114/rule_A_1_1_4": Low, + "gjb8114/rule_A_1_1_5": Low, + "gjb8114/rule_A_1_1_6": Low, + "gjb8114/rule_1_2_1": Medium, + "gjb8114/rule_1_2_2": Medium, + "gjb8114/rule_1_2_3": Medium, + "gjb8114/rule_1_2_4": Medium, + "gjb8114/rule_1_2_5": Medium, + "gjb8114/rule_1_2_6": Medium, + "gjb8114/rule_A_1_2_1": Low, + "gjb8114/rule_A_1_2_2": Low, + "gjb8114/rule_A_1_2_3": Low, + "gjb8114/rule_1_3_1": Medium, + "gjb8114/rule_1_3_2": Medium, + "gjb8114/rule_1_3_3": High, + "gjb8114/rule_1_3_4": High, + "gjb8114/rule_1_3_5": High, + "gjb8114/rule_1_3_6": High, + "gjb8114/rule_1_3_7": High, + "gjb8114/rule_1_3_8": High, + "gjb8114/rule_1_3_9": High, + "gjb8114/rule_1_3_10": High, + "gjb8114/rule_A_1_3_1": Low, + "gjb8114/rule_A_1_3_2": Low, + "gjb8114/rule_A_1_3_3": Low, + "gjb8114/rule_1_4_1": Medium, + "gjb8114/rule_1_4_2": Medium, + "gjb8114/rule_1_4_3": Medium, + "gjb8114/rule_1_4_4": Medium, + "gjb8114/rule_1_4_5": Medium, + "gjb8114/rule_1_4_6": Medium, + "gjb8114/rule_1_4_7": Medium, + "gjb8114/rule_1_4_8": Medium, + "gjb8114/rule_A_1_4_1": Low, + "gjb8114/rule_1_5_1": Medium, + "gjb8114/rule_1_5_2": Medium, + "gjb8114/rule_A_1_5_1": Low, + "gjb8114/rule_1_6_1": High, + "gjb8114/rule_1_6_2": High, + "gjb8114/rule_1_6_3": High, + "gjb8114/rule_1_6_4": High, + "gjb8114/rule_1_6_5": Medium, + "gjb8114/rule_1_6_6": High, + "gjb8114/rule_1_6_7": High, + "gjb8114/rule_1_6_8": High, + "gjb8114/rule_1_6_9": High, + "gjb8114/rule_1_6_10": Medium, + "gjb8114/rule_1_6_11": High, + "gjb8114/rule_1_6_12": High, + "gjb8114/rule_1_6_13": Medium, + "gjb8114/rule_1_6_14": High, + "gjb8114/rule_1_6_15": High, + "gjb8114/rule_1_6_16": High, + "gjb8114/rule_1_6_17": High, + "gjb8114/rule_1_6_18": Medium, + "gjb8114/rule_1_6_19": High, + "gjb8114/rule_A_1_6_1": Low, + "gjb8114/rule_A_1_6_2": Low, + "gjb8114/rule_A_1_6_3": Low, + "gjb8114/rule_A_1_6_4": Low, + "gjb8114/rule_A_1_6_5": Low, + "gjb8114/rule_A_1_6_6": Low, + "gjb8114/rule_1_7_1": High, + "gjb8114/rule_1_7_2": Medium, + "gjb8114/rule_1_7_3": Medium, + "gjb8114/rule_1_7_4": Medium, + "gjb8114/rule_1_7_5": Medium, + "gjb8114/rule_1_7_6": High, + "gjb8114/rule_1_7_7": High, + "gjb8114/rule_1_7_8": High, + "gjb8114/rule_1_7_9": High, + "gjb8114/rule_1_7_10": Medium, + "gjb8114/rule_1_7_11": Medium, + "gjb8114/rule_1_7_12": Medium, + "gjb8114/rule_1_7_13": Medium, + "gjb8114/rule_1_7_14": High, + "gjb8114/rule_1_7_15": Medium, + "gjb8114/rule_1_7_16": Medium, + "gjb8114/rule_A_1_7_1": Low, + "gjb8114/rule_A_1_7_2": Low, + "gjb8114/rule_A_1_7_3": Low, + "gjb8114/rule_A_1_7_4": Low, + "gjb8114/rule_A_1_7_5": Low, + "gjb8114/rule_1_8_1": Medium, + "gjb8114/rule_1_8_2": Medium, + "gjb8114/rule_1_8_3": Medium, + "gjb8114/rule_1_8_4": Medium, + "gjb8114/rule_1_8_5": Medium, + "gjb8114/rule_A_1_8_1": Low, + "gjb8114/rule_A_1_8_2": Low, + "gjb8114/rule_A_1_8_3": Low, + "gjb8114/rule_A_1_8_4": Low, + "gjb8114/rule_1_9_1": Medium, + "gjb8114/rule_1_9_2": High, + "gjb8114/rule_1_9_3": Medium, + "gjb8114/rule_1_9_4": Medium, + "gjb8114/rule_A_1_9_1": Low, + "gjb8114/rule_A_1_9_2": Low, + "gjb8114/rule_A_1_9_3": Low, + "gjb8114/rule_1_10_1": High, + "gjb8114/rule_1_10_2": High, + "gjb8114/rule_1_10_3": High, + "gjb8114/rule_1_10_4": High, + "gjb8114/rule_1_10_5": High, + "gjb8114/rule_1_10_6": Medium, + "gjb8114/rule_A_1_10_1": Low, + "gjb8114/rule_A_1_10_2": Low, + "gjb8114/rule_A_1_10_3": Low, + "gjb8114/rule_A_1_10_4": Low, + "gjb8114/rule_1_11_1": High, + "gjb8114/rule_1_11_2": Medium, + "gjb8114/rule_1_11_3": Medium, + "gjb8114/rule_1_11_4": Medium, + "gjb8114/rule_A_1_11_1": Low, + "gjb8114/rule_A_1_11_2": Low, + "gjb8114/rule_1_12_1": Medium, + "gjb8114/rule_1_12_2": Medium, + "gjb8114/rule_1_12_3": Medium, + "gjb8114/rule_1_12_4": Medium, + "gjb8114/rule_1_12_5": Medium, + "gjb8114/rule_A_1_12_1": Low, + "gjb8114/rule_1_13_1": Medium, + "gjb8114/rule_1_13_2": Medium, + "gjb8114/rule_1_13_3": Medium, + "gjb8114/rule_1_13_4": Medium, + "gjb8114/rule_1_13_5": Medium, + "gjb8114/rule_1_13_6": Medium, + "gjb8114/rule_1_13_7": Medium, + "gjb8114/rule_1_13_8": Medium, + "gjb8114/rule_1_13_9": Medium, + "gjb8114/rule_1_13_10": Medium, + "gjb8114/rule_1_13_11": Medium, + "gjb8114/rule_1_13_12": Medium, + "gjb8114/rule_1_13_13": Medium, + "gjb8114/rule_1_13_14": Medium, + "gjb8114/rule_1_13_15": Medium, + "gjb8114/rule_1_13_16": Medium, + "gjb8114/rule_A_1_13_1": Low, + "gjb8114/rule_A_1_13_2": Low, "java/S1111": Medium, "java/S1114": High, "java/S1143": High, diff --git a/cruleslib/testlib/testlib.go b/cruleslib/testlib/testlib.go index 237935f3ff..e2c33e5f04 100644 --- a/cruleslib/testlib/testlib.go +++ b/cruleslib/testlib/testlib.go @@ -50,11 +50,26 @@ var checkingStandards = []string{ "toy_rules", } +func GetSemgrepBinPath() string { + homeDir, err := os.UserHomeDir() + if err != nil { + glog.Errorf("os.UserHomeDir: %v", err) + return "semgrep" + } + // suppose that semgrep has been installed in a virtual env called 'sandbox' + semgrepInSandbox := filepath.Join(homeDir, "sandbox", "bin", "semgrep") + _, err = os.Stat(semgrepInSandbox) + if err != nil { + glog.Errorf("%s: %v", semgrepInSandbox, err) + return "semgrep" + } + return semgrepInSandbox +} + func getCheckerConfig(projectBaseDir string) *proto.CheckerConfiguration { checkerConfig := proto.CheckerConfiguration{ InferBin: filepath.Join(projectBaseDir, "out", "bin", "infer"), ClangBin: filepath.Join(projectBaseDir, "bazel-bin", "external", "llvm-project", "clang", "clang"), - CodeCheckerBin: "CodeChecker", CppcheckBin: filepath.Join(projectBaseDir, "third_party", "cppcheck", "cppcheck"), PythonBin: "python3", ClangtidyBin: filepath.Join(projectBaseDir, "bazel-bin", "external", "llvm-project", "clang-tools-extra", "clang-tidy"), @@ -148,7 +163,6 @@ func NewOption(srcdir string, edition string, ignoreCpp bool, standard string) ( checkerConfig, ignoreDirPatterns, /*checkProgress=*/ true, - /*enableCodeChecker=*/ false, ignoreCpp, /*debug=*/ true, /*limitMemory=*/ false, @@ -173,7 +187,9 @@ func NewOption(srcdir string, edition string, ignoreCpp bool, standard string) ( } func selectCheckingStandard() string { - _, filename, _, ok := runtime.Caller(3) + // 4: The number of stack frames to ascend (the number of caller layers) + // should be changed if the location of the caller function is changed. + _, filename, _, ok := runtime.Caller(4) if !ok { glog.Fatal("can not get caller information") } @@ -182,15 +198,17 @@ func selectCheckingStandard() string { return e } } - // default gjb edition: 5369 + // default gjb edition: 5369 (which will skip cpp files) return checkingStandards[0] } +// Note that this function is location sensitive due to selectCheckingStandard(). func MakeTestOption(srcdir string) (*options.CheckOptions, error) { return MakeTestOptionRealAdvance(srcdir, "c99") } -// add this func to make sure every call to selectCheckingStandard() has 3 call layers +// Add this func to make sure every call to selectCheckingStandard() has the +// same call layers. func MakeTestOptionAdvance(srcdir string, standard string) (*options.CheckOptions, error) { return MakeTestOptionRealAdvance(srcdir, standard) } @@ -221,17 +239,6 @@ func ToTestResult(results *proto.ResultsList, err error) (*proto.ResultsList, er return results, err } -func ToRelPath(srcdir string, results *proto.ResultsList) error { - for _, result := range results.Results { - if rel, err := filepath.Rel(srcdir, result.Path); err != nil { - return err - } else { - result.Path = rel - } - } - return nil -} - func ConcatClangSystemHeader(options *string) { clangVersion := utils.GetCurrentClangVersion() *options = fmt.Sprintf("-isystem /usr/lib64/clang/%s/include %s", clangVersion, *options) diff --git a/diff/diff.go b/diff/diff.go new file mode 100644 index 0000000000..a4a976d7cc --- /dev/null +++ b/diff/diff.go @@ -0,0 +1,165 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package diff + +import ( + "fmt" + "regexp" + "strconv" + "strings" +) + +type Hunk struct { + OldPos, OldLines, NewPos, NewLines int +} + +type File struct { + NewName string + OldName string + Hunks []*Hunk +} + +type Patch struct { + Files []*File +} + +/* +Parse parses the diff into a patch struct. + +It goes over the lines in the diff and maintain an implicit state machine. It +only cares about lines that start with "--- ", "+++ ", or "@@ -", and ignores +everything else. + +For a particular file in the diff, there are three cases to consider: + +1. File modification + +It usually looks like this: + + diff --git a/docs/Makefile b/docs/Makefile + index 602565a30b39..9ff7b4d33b07 100644 + --- a/docs/Makefile + +++ b/docs/Makefile + @@ -2,12 +2,11 @@ all: + $(MAKE) -C weixin + + deploy: + - ssh staging-docs rm -f docs.tar.xz ... + - rsync -aP staging-docs:docs.tar.xz ... + + mv ../docs_website/docs_site/docs.tar.xz ... + rsync -aP docs.tar.xz docs.naivesystems.com: ... + ssh docs.naivesystems.com ... + +Lines starting with "diff" or "index" are ignored. + +2. File addition + +Example: + + diff --git a/docs_site/README.txt b/docs_site/README.txt + new file mode 100644 + index 000000000000..dad6695563d6 + --- /dev/null + +++ b/docs_site/README.txt + @@ -0,0 +1,27 @@ + +DO NOT BUILD DIRECTLY. OTHERWISE YOU WILL SEE ERRORS: + + + + Attempting to create page at XXX, but ... + + + +OldName is set to the empty string in this case. + +3. File deletion + +Example: + + diff --git a/.ruby-version b/.ruby-version + deleted file mode 100644 + index a603bb50a29e..000000000000 + --- a/.ruby-version + +++ /dev/null + @@ -1 +0,0 @@ + -2.7.5 + +NewName is set to the empty string in this case. +*/ +func Parse(diff string) (*Patch, error) { + re := regexp.MustCompile(`@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@`) + lines := strings.Split(diff, "\n") + var p Patch + var f *File + for i, line := range lines { + if strings.HasPrefix(line, "--- ") { + f = &File{} + if line == "--- /dev/null" { + // file addition + f.OldName = "" + } else if strings.HasPrefix(line, "--- a/") { + f.OldName = strings.TrimPrefix(line, "--- a/") + } else { + return nil, fmt.Errorf("invalid line %d '%s'", i, line) + } + p.Files = append(p.Files, f) + } else if strings.HasPrefix(line, "+++ ") { + if f == nil || len(f.Hunks) > 0 { + return nil, fmt.Errorf("unexpected line %d '%s'", i, line) + } + if line == "+++ /dev/null" { + // file deletion + f.NewName = "" + } else if strings.HasPrefix(line, "+++ b/") { + f.NewName = strings.TrimPrefix(line, "+++ b/") + } else { + return nil, fmt.Errorf("invalid line %d '%s'", i, line) + } + } else if strings.HasPrefix(line, "@@ -") { + match := re.FindStringSubmatch(line) + if match == nil { + return nil, fmt.Errorf("could not extract hunk info from line '%s'", line) + } + oldpos, err := strconv.Atoi(match[1]) + if err != nil { + return nil, fmt.Errorf("error converting oldpos to integer in '%s': %v", line, err) + } + oldlines := 1 + if match[2] != "" { + oldlines, err = strconv.Atoi(match[2]) + if err != nil { + return nil, fmt.Errorf("error converting oldlines to integer in '%s': %v", line, err) + } + } + newpos, err := strconv.Atoi(match[3]) + if err != nil { + return nil, fmt.Errorf("error converting newpos to integer in '%s': %v", line, err) + } + newlines := 1 + if match[4] != "" { + newlines, err = strconv.Atoi(match[4]) + if err != nil { + return nil, fmt.Errorf("error converting newlines to integer in '%s': %v", line, err) + } + } + if f == nil { + return nil, fmt.Errorf("f is nil but line %d is '%s'", i, line) + } + f.Hunks = append(f.Hunks, &Hunk{oldpos, oldlines, newpos, newlines}) + } + } + return &p, nil +} diff --git a/googlecpp/analyzer/run.go b/googlecpp/analyzer/run.go index 2cc4713849..31e7b92d45 100644 --- a/googlecpp/analyzer/run.go +++ b/googlecpp/analyzer/run.go @@ -1,7 +1,19 @@ /* -Copyright 2023 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ package analyzer diff --git a/googlecpp/g1149/libtooling/checker.cc b/googlecpp/g1149/libtooling/checker.cc index 4f75610a20..2da134b6e3 100644 --- a/googlecpp/g1149/libtooling/checker.cc +++ b/googlecpp/g1149/libtooling/checker.cc @@ -41,7 +41,7 @@ void ReportError(string path, int line_number, ResultsList* results_list) { } void CheckInMainFile(const Decl* decl, SourceManager* SM, - analyzer::proto::ResultsList* results_list_, + ResultsList* results_list_, const std::string& main_filename, const std::unordered_set header_files) { std::string filename = misra::libtooling_utils::GetFilename(decl, SM); @@ -54,7 +54,7 @@ void CheckInMainFile(const Decl* decl, SourceManager* SM, void CheckTransitivelyIncluded(const string& filename, int line, const Decl* decl, SourceManager* SM, - analyzer::proto::ResultsList* results_list_, + ResultsList* results_list_, const std::string& main_filename, unordered_set& header_files) { // Get the file path of the declaration to verify that the declaration is @@ -78,8 +78,7 @@ namespace libtooling { std::string main_filename{}; unordered_set header_files; -void PPCheck::Init(analyzer::proto::ResultsList* results_list, - SourceManager* source_manager) { +void PPCheck::Init(ResultsList* results_list, SourceManager* source_manager) { results_list_ = results_list; source_manager_ = source_manager; } @@ -137,8 +136,7 @@ AST_MATCHER(VarDecl, isExternalFirstDecl) { return Node.isFirstDecl() && Node.hasExternalStorage(); } -void Callback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void Callback::Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // There are two situations that should not occur in .cc files. @@ -192,7 +190,7 @@ void Callback::Init(analyzer::proto::ResultsList* results_list, finder->addMatcher(m1, this); } -void Callback::run(const ast_matchers::MatchFinder::MatchResult& result) { +void Callback::run(const MatchFinder::MatchResult& result) { auto context = result.Context; auto SM = result.SourceManager; if (const auto* external_first_var = @@ -254,7 +252,7 @@ void Callback::run(const ast_matchers::MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1149/libtooling/g1149.cc b/googlecpp/g1149/libtooling/g1149.cc index cf006f7606..bd5558584c 100644 --- a/googlecpp/g1149/libtooling/g1149.cc +++ b/googlecpp/g1149/libtooling/g1149.cc @@ -48,7 +48,7 @@ int g1149(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1150/libtooling/checker.cc b/googlecpp/g1150/libtooling/checker.cc index 41be51188c..24f6bba78b 100644 --- a/googlecpp/g1150/libtooling/checker.cc +++ b/googlecpp/g1150/libtooling/checker.cc @@ -54,8 +54,7 @@ namespace libtooling { Optional filename_prefix{}; -void PPCheck::Init(analyzer::proto::ResultsList* results_list, - SourceManager* source_manager) { +void PPCheck::Init(ResultsList* results_list, SourceManager* source_manager) { results_list_ = results_list; source_manager_ = source_manager; } @@ -105,10 +104,9 @@ AST_MATCHER(TranslationUnitDecl, hasJustOneDecl) { // pointers. bool hasTranslationUnitVisit{false}; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto matcher = translationUnitDecl(unless(translationUnitDecl( @@ -117,7 +115,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(matcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* TU = result.Nodes.getNodeAs("translationunit")) { if (hasTranslationUnitVisit) return; @@ -163,10 +161,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1150/libtooling/g1150.cc b/googlecpp/g1150/libtooling/g1150.cc index 6c3f59020c..42590f6947 100644 --- a/googlecpp/g1150/libtooling/g1150.cc +++ b/googlecpp/g1150/libtooling/g1150.cc @@ -48,7 +48,7 @@ int g1150(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1151/libtooling/checker.cc b/googlecpp/g1151/libtooling/checker.cc index 821293f966..d80267c4de 100644 --- a/googlecpp/g1151/libtooling/checker.cc +++ b/googlecpp/g1151/libtooling/checker.cc @@ -38,7 +38,7 @@ namespace libtooling { void Check::Init(analyzer::proto::ResultsList* results_list, SourceManager* source_manager, - const std::string& optional_info_file) { + const string& optional_info_file) { results_list_ = results_list; source_manager_ = source_manager; ofs.open(optional_info_file, std::ios::app); @@ -87,7 +87,7 @@ bool Action::BeginSourceFileAction(CompilerInstance& ci) { } void Checker::Init(analyzer::proto::ResultsList* results_list, - const std::string& optional_info_file) { + const string& optional_info_file) { results_list_ = results_list; optional_info_file_ = optional_info_file; } diff --git a/googlecpp/g1151/libtooling/g1151.cc b/googlecpp/g1151/libtooling/g1151.cc index 04c2d4b640..52d748a1de 100644 --- a/googlecpp/g1151/libtooling/g1151.cc +++ b/googlecpp/g1151/libtooling/g1151.cc @@ -58,7 +58,7 @@ int g1151(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1152/libtooling/checker.cc b/googlecpp/g1152/libtooling/checker.cc index 06c9a8c647..00c92a990f 100644 --- a/googlecpp/g1152/libtooling/checker.cc +++ b/googlecpp/g1152/libtooling/checker.cc @@ -47,16 +47,15 @@ namespace googlecpp { namespace g1152 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionTemplateDecl().bind("template_func"), this); finder->addMatcher(functionDecl(isInline()).bind("func"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto checkIncludeAndReport = [&result, this](const FunctionDecl* func) { if (misra::libtooling_utils::IsInSystemHeader(func, result.Context)) return; @@ -96,10 +95,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1152/libtooling/g1152.cc b/googlecpp/g1152/libtooling/g1152.cc index f3e70e2aa5..266c494fbd 100644 --- a/googlecpp/g1152/libtooling/g1152.cc +++ b/googlecpp/g1152/libtooling/g1152.cc @@ -48,7 +48,7 @@ int g1152(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1154/libtooling/checker.cc b/googlecpp/g1154/libtooling/checker.cc index 7dbaf17af1..a6afe40ffb 100644 --- a/googlecpp/g1154/libtooling/checker.cc +++ b/googlecpp/g1154/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1154 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // To catch every possible declaration without definition @@ -65,7 +64,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* decl = result.Nodes.getNodeAs("forwardDecl")) { if (misra::libtooling_utils::IsInSystemHeader(decl, result.Context)) return; @@ -85,10 +84,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1154/libtooling/g1154.cc b/googlecpp/g1154/libtooling/g1154.cc index db1cf18da9..f83683288f 100644 --- a/googlecpp/g1154/libtooling/g1154.cc +++ b/googlecpp/g1154/libtooling/g1154.cc @@ -48,7 +48,7 @@ int g1154(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1155/libtooling/checker.cc b/googlecpp/g1155/libtooling/checker.cc index d1d7fa9fd6..92d3769b70 100644 --- a/googlecpp/g1155/libtooling/checker.cc +++ b/googlecpp/g1155/libtooling/checker.cc @@ -47,19 +47,19 @@ namespace googlecpp { namespace g1155 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { int maximum_inline_func_line_; public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder, int maximum_inline_func_line) { + void Init(ResultsList* results_list, MatchFinder* finder, + int maximum_inline_func_line) { results_list_ = results_list; maximum_inline_func_line_ = maximum_inline_func_line; // It will also catch the inline member functions finder->addMatcher(functionDecl(isInline()).bind("inlineFunc"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const FunctionDecl* func = result.Nodes.getNodeAs("inlineFunc")) { if (misra::libtooling_utils::IsInSystemHeader(func, result.Context)) @@ -80,11 +80,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list, - int maximum_inline_func_line) { +void Checker::Init(ResultsList* results_list, int maximum_inline_func_line) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_, maximum_inline_func_line); diff --git a/googlecpp/g1155/libtooling/g1155.cc b/googlecpp/g1155/libtooling/g1155.cc index c52594a435..81c787520c 100644 --- a/googlecpp/g1155/libtooling/g1155.cc +++ b/googlecpp/g1155/libtooling/g1155.cc @@ -52,7 +52,7 @@ int g1155(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1156/g1156.go b/googlecpp/g1156/g1156.go index f0386c11d4..2f30625ad0 100644 --- a/googlecpp/g1156/g1156.go +++ b/googlecpp/g1156/g1156.go @@ -21,9 +21,66 @@ package g1156 import ( pb "naive.systems/analyzer/analyzer/proto" "naive.systems/analyzer/cruleslib/options" + "naive.systems/analyzer/cruleslib/runner" ) +var style = `{ + Language: Cpp, + IncludeBlocks: Regroup, + IncludeCategories: [ + { + Regex: "^", + Priority: 2, + SortPriority: 0, + CaseSensitive: false, + }, + { + Regex: "^<.*\\.h>", + Priority: 1, + SortPriority: 0, + CaseSensitive: false, + }, + { + Regex: "^<.*", + Priority: 2, + SortPriority: 0, + CaseSensitive: false, + }, + { + Regex: ".*", + Priority: 3, + SortPriority: 0, + CaseSensitive: false, + } + ], + SortIncludes: CaseSensitive, +}` + func Analyze(srcdir string, opts *options.CheckOptions) (*pb.ResultsList, error) { - results := &pb.ResultsList{} - return results, nil + compileCommandsPath := runner.GetCompileCommandsPath(srcdir, opts) + reports, err := runner.RunClangFormat(srcdir, style, compileCommandsPath, opts) + if err != nil { + return nil, err + } + type Loc struct { + string + int32 + } + results := make(map[Loc]struct{}) + resultsList := &pb.ResultsList{} + report := func(path string, line int32) { + loc := Loc{path, line} + if _, reported := results[loc]; !reported { + results[loc] = struct{}{} + resultsList.Results = append(resultsList.Results, &pb.Result{ + Path: path, + LineNumber: line, + ErrorMessage: "Include headers in the following order: Related header, C system headers, C++ standard library headers, other libraries' headers, your project's headers.", + }) + } + } + for _, r := range reports { + report(r.Filename, int32(r.LineNumber)) + } + return resultsList, nil } diff --git a/googlecpp/g1157/libtooling/g1157.cc b/googlecpp/g1157/libtooling/g1157.cc index 999bbbc7b2..62b21af67c 100644 --- a/googlecpp/g1157/libtooling/g1157.cc +++ b/googlecpp/g1157/libtooling/g1157.cc @@ -49,7 +49,7 @@ int g1157(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1158/libtooling/checker.cc b/googlecpp/g1158/libtooling/checker.cc index 61a1c4c493..22f4e73761 100644 --- a/googlecpp/g1158/libtooling/checker.cc +++ b/googlecpp/g1158/libtooling/checker.cc @@ -38,8 +38,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "Do not use using-directives (e.g., using namespace foo)"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1158/libtooling/g1158.cc b/googlecpp/g1158/libtooling/g1158.cc index 2791ad0d61..1b060e2d58 100644 --- a/googlecpp/g1158/libtooling/g1158.cc +++ b/googlecpp/g1158/libtooling/g1158.cc @@ -47,7 +47,7 @@ int g1158(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/googlecpp/g1159/libtooling/BUILD b/googlecpp/g1159/libtooling/BUILD index 6d23be8b1b..eb315bb4f0 100644 --- a/googlecpp/g1159/libtooling/BUILD +++ b/googlecpp/g1159/libtooling/BUILD @@ -1,39 +1,15 @@ -cc_library( - name = "checker", - srcs = ["checker.cc"], - hdrs = ["checker.h"], - deps = [ - "//analyzer/proto:analyzer_cc_proto", - "//misra:proto_util", - "//misra/libtooling_utils", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings", - "@llvm-project//clang:tooling", - ], -) - cc_library( name = "g1159_lib", - srcs = ["g1159.cc"], - hdrs = ["lib.h"], + srcs = ["checker.cc"], visibility = ["//visibility:public"], - deps = [ - ":checker", - "//libtooling_includes:cmd_options", - "//misra:proto_util", - "//misra/libtooling_utils", - "//podman_image/bigmain:suffix_rule", - "@com_github_google_glog//:glog", - "@llvm-project//clang:tooling", - ], + deps = ["//sdk/checker"], alwayslink = True, ) cc_binary( name = "g1159", - srcs = ["main.cc"], deps = [ ":g1159_lib", - "//libtooling_includes:cmd_options", + "//podman_image/bigmain", ], ) diff --git a/googlecpp/g1159/libtooling/checker.cc b/googlecpp/g1159/libtooling/checker.cc index c71645dcad..7cc66003ba 100644 --- a/googlecpp/g1159/libtooling/checker.cc +++ b/googlecpp/g1159/libtooling/checker.cc @@ -16,67 +16,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "googlecpp/g1159/libtooling/checker.h" +#include -#include +#include "sdk/checker/define_decl_checker.h" -#include - -#include "absl/strings/str_format.h" -#include "misra/libtooling_utils/libtooling_utils.h" - -using namespace clang; using namespace clang::ast_matchers; -using analyzer::proto::ResultsList; namespace { -void ReportError(string path, int line_number, ResultsList* results_list) { - string error_message = "Do not use inline namespaces"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); - LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, - line_number); -} +sdk::checker::DefineDeclChecker _( + "googlecpp/g1159", "Do not use inline namespaces", + namespaceDecl(isInline()).bind("inline_namespace"), "inline_namespace"); } // namespace - -namespace googlecpp { -namespace g1159 { -namespace libtooling { - -class Callback : public ast_matchers::MatchFinder::MatchCallback { - public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { - results_list_ = results_list; - finder->addMatcher(namespaceDecl(isInline()).bind("inline-namespace"), - this); - } - - void run(const ast_matchers::MatchFinder::MatchResult& result) override { - if (const auto* inlineNamespace = - result.Nodes.getNodeAs("inline-namespace")) { - if (misra::libtooling_utils::IsInSystemHeader(inlineNamespace, - result.Context)) - return; - ReportError(misra::libtooling_utils::GetFilename(inlineNamespace, - result.SourceManager), - misra::libtooling_utils::GetLine(inlineNamespace, - result.SourceManager), - results_list_); - } - } - - private: - analyzer::proto::ResultsList* results_list_; -}; - -void Checker::Init(analyzer::proto::ResultsList* results_list) { - results_list_ = results_list; - callback_ = new Callback; - callback_->Init(results_list, &finder_); -} -} // namespace libtooling -} // namespace g1159 -} // namespace googlecpp diff --git a/googlecpp/g1159/libtooling/main.cc b/googlecpp/g1159/libtooling/main.cc deleted file mode 100644 index 4662c2cae5..0000000000 --- a/googlecpp/g1159/libtooling/main.cc +++ /dev/null @@ -1,23 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#include "googlecpp/g1159/libtooling/lib.h" -#include "libtooling_includes/cmd_options.h" -int main(int argc, char** argv) { - return googlecpp::g1159::libtooling::g1159(argc, argv); -} diff --git a/googlecpp/g1160/libtooling/checker.cc b/googlecpp/g1160/libtooling/checker.cc index 47319015c3..adc13fb035 100644 --- a/googlecpp/g1160/libtooling/checker.cc +++ b/googlecpp/g1160/libtooling/checker.cc @@ -46,15 +46,14 @@ namespace googlecpp { namespace g1160 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(namespaceDecl().bind("namespace"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* namespace_ = result.Nodes.getNodeAs("namespace")) { if (misra::libtooling_utils::IsInSystemHeader(namespace_, result.Context)) @@ -70,10 +69,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1160/libtooling/g1160.cc b/googlecpp/g1160/libtooling/g1160.cc index 7f02d5b305..37cc365422 100644 --- a/googlecpp/g1160/libtooling/g1160.cc +++ b/googlecpp/g1160/libtooling/g1160.cc @@ -48,7 +48,7 @@ int g1160(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1161/libtooling/checker.cc b/googlecpp/g1161/libtooling/checker.cc index e18fc7ea36..6b76e33816 100644 --- a/googlecpp/g1161/libtooling/checker.cc +++ b/googlecpp/g1161/libtooling/checker.cc @@ -46,14 +46,13 @@ namespace googlecpp { namespace g1161 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { // Assume all global variables has distinct qualified name llvm::StringMap> qname_to_TU_map; llvm::StringMap> qname_to_first_decl_file_line_map; public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(tagDecl(unless(isImplicit())).bind("namedDecl"), this); finder->addMatcher(varDecl(unless(isImplicit())).bind("namedDecl"), this); @@ -61,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* decl = result.Nodes.getNodeAs("namedDecl")) { if (misra::libtooling_utils::IsInSystemHeader(decl, result.Context)) return; @@ -96,10 +95,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1161/libtooling/g1161.cc b/googlecpp/g1161/libtooling/g1161.cc index f999939d52..8e4fc1e7dc 100644 --- a/googlecpp/g1161/libtooling/g1161.cc +++ b/googlecpp/g1161/libtooling/g1161.cc @@ -48,13 +48,13 @@ int g1161(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/googlecpp/g1162/libtooling/checker.cc b/googlecpp/g1162/libtooling/checker.cc index 2cd882033a..b028665d34 100644 --- a/googlecpp/g1162/libtooling/checker.cc +++ b/googlecpp/g1162/libtooling/checker.cc @@ -46,16 +46,15 @@ namespace googlecpp { namespace g1162 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(namespaceDecl(isAnonymous()).bind("ns"), this); finder->addMatcher(functionDecl().bind("func"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto reportDeclInHeader = [&result, this](const Decl* decl) { // Check IsInSystemHeader does not filter out user defined "*.h" files if (misra::libtooling_utils::IsInSystemHeader(decl, result.Context)) @@ -86,10 +85,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1162/libtooling/g1162.cc b/googlecpp/g1162/libtooling/g1162.cc index a5035d63cf..e5849f2219 100644 --- a/googlecpp/g1162/libtooling/g1162.cc +++ b/googlecpp/g1162/libtooling/g1162.cc @@ -48,7 +48,7 @@ int g1162(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1163/libtooling/checker.cc b/googlecpp/g1163/libtooling/checker.cc index 2e74a535fd..5e4ad102d0 100644 --- a/googlecpp/g1163/libtooling/checker.cc +++ b/googlecpp/g1163/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1163 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Use isDefinition() to filter out class without body. // Use isClass() to filter out struct, union and enum. @@ -56,7 +55,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* classRecord = result.Nodes.getNodeAs("_class")) { if (misra::libtooling_utils::IsInSystemHeader(classRecord, @@ -90,10 +89,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1163/libtooling/g1163.cc b/googlecpp/g1163/libtooling/g1163.cc index b6be3d23e8..19bc99a0ee 100644 --- a/googlecpp/g1163/libtooling/g1163.cc +++ b/googlecpp/g1163/libtooling/g1163.cc @@ -48,7 +48,7 @@ int g1163(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1165/libtooling/checker.cc b/googlecpp/g1165/libtooling/checker.cc index e1b8c2d4f7..2da5133a92 100644 --- a/googlecpp/g1165/libtooling/checker.cc +++ b/googlecpp/g1165/libtooling/checker.cc @@ -46,17 +46,16 @@ namespace googlecpp { namespace g1165 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Find all variables with static storage duration finder->addMatcher(varDecl(hasStaticStorageDuration()).bind("staticvar"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* var = result.Nodes.getNodeAs("staticvar")) { if (misra::libtooling_utils::IsInSystemHeader(var, result.Context)) return; @@ -89,10 +88,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1165/libtooling/g1165.cc b/googlecpp/g1165/libtooling/g1165.cc index dd3b73201a..a658202559 100644 --- a/googlecpp/g1165/libtooling/g1165.cc +++ b/googlecpp/g1165/libtooling/g1165.cc @@ -48,7 +48,7 @@ int g1165(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1166/libtooling/checker.cc b/googlecpp/g1166/libtooling/checker.cc index 2fd23c973a..36bc60d36b 100644 --- a/googlecpp/g1166/libtooling/checker.cc +++ b/googlecpp/g1166/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1166 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Dynamic initialization of static local variables is allowed finder->addMatcher( @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* var = result.Nodes.getNodeAs("staticvar")) { if (misra::libtooling_utils::IsInSystemHeader(var, result.Context)) return; @@ -78,10 +77,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1166/libtooling/g1166.cc b/googlecpp/g1166/libtooling/g1166.cc index fcc2a3ae3f..8c644ced28 100644 --- a/googlecpp/g1166/libtooling/g1166.cc +++ b/googlecpp/g1166/libtooling/g1166.cc @@ -48,7 +48,7 @@ int g1166(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1167/libtooling/checker.cc b/googlecpp/g1167/libtooling/checker.cc index a37a704957..177e295f45 100644 --- a/googlecpp/g1167/libtooling/checker.cc +++ b/googlecpp/g1167/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1167 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxConstructorDecl( @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* call = result.Nodes.getNodeAs("call")) { if (misra::libtooling_utils::IsInSystemHeader(call, result.Context)) return; @@ -77,10 +76,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1167/libtooling/g1167.cc b/googlecpp/g1167/libtooling/g1167.cc index f66eb13c0e..1e3a2595dd 100644 --- a/googlecpp/g1167/libtooling/g1167.cc +++ b/googlecpp/g1167/libtooling/g1167.cc @@ -48,7 +48,7 @@ int g1167(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1169/libtooling/checker.cc b/googlecpp/g1169/libtooling/checker.cc index 5a92a5b84c..cec3d3beea 100644 --- a/googlecpp/g1169/libtooling/checker.cc +++ b/googlecpp/g1169/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1169 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl( @@ -69,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* copy_cons = result.Nodes.getNodeAs("copy_construct"); @@ -105,10 +104,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1169/libtooling/g1169.cc b/googlecpp/g1169/libtooling/g1169.cc index 7dfb29f931..c811b1eee0 100644 --- a/googlecpp/g1169/libtooling/g1169.cc +++ b/googlecpp/g1169/libtooling/g1169.cc @@ -48,7 +48,7 @@ int g1169(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1170/libtooling/checker.cc b/googlecpp/g1170/libtooling/checker.cc index d72b327b56..453b5b5bf6 100644 --- a/googlecpp/g1170/libtooling/checker.cc +++ b/googlecpp/g1170/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1170 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto pureClassMatcher = cxxRecordDecl(hasDefinition(), has(cxxMethodDecl(isPure()))); @@ -69,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(badDerivedClassMatcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* derived = result.Nodes.getNodeAs("drivedclass")) { ReportError( @@ -80,10 +79,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1170/libtooling/g1170.cc b/googlecpp/g1170/libtooling/g1170.cc index 49b640de04..b85f49b2f9 100644 --- a/googlecpp/g1170/libtooling/g1170.cc +++ b/googlecpp/g1170/libtooling/g1170.cc @@ -48,7 +48,7 @@ int g1170(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1171/libtooling/checker.cc b/googlecpp/g1171/libtooling/checker.cc index 6a7d6eba35..49e475aa54 100644 --- a/googlecpp/g1171/libtooling/checker.cc +++ b/googlecpp/g1171/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1171 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Use hasDefinition to avoid matching the new base declaration implicitly // inserted into the derived class. @@ -60,7 +59,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const CXXRecordDecl* derived = result.Nodes.getNodeAs("derivedclass")) { if (misra::libtooling_utils::IsInSystemHeader(derived, result.Context)) @@ -74,10 +73,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1171/libtooling/g1171.cc b/googlecpp/g1171/libtooling/g1171.cc index 38f434ec8c..d8bba62b79 100644 --- a/googlecpp/g1171/libtooling/g1171.cc +++ b/googlecpp/g1171/libtooling/g1171.cc @@ -48,7 +48,7 @@ int g1171(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1172/libtooling/checker.cc b/googlecpp/g1172/libtooling/checker.cc index 530f98e76d..ddfdcd5579 100644 --- a/googlecpp/g1172/libtooling/checker.cc +++ b/googlecpp/g1172/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1172 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto nonPublicMatcher = anyOf(isPrivate(), isProtected()); auto nonPublicFieldMatcher = recordDecl( @@ -73,7 +72,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(nonPublicRecordMatcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* nonPublic = result.Nodes.getNodeAs("nonpublic")) { if (misra::libtooling_utils::IsInSystemHeader(nonPublic, result.Context)) return; @@ -85,10 +84,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1172/libtooling/g1172.cc b/googlecpp/g1172/libtooling/g1172.cc index 5a67d3bfff..f51db5bb02 100644 --- a/googlecpp/g1172/libtooling/g1172.cc +++ b/googlecpp/g1172/libtooling/g1172.cc @@ -48,7 +48,7 @@ int g1172(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1173/libtooling/checker.cc b/googlecpp/g1173/libtooling/checker.cc index b49cbb5f03..a60c0976fb 100644 --- a/googlecpp/g1173/libtooling/checker.cc +++ b/googlecpp/g1173/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1173 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl(unless(isExpansionInSystemHeader()), @@ -57,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* nonPublic = result.Nodes.getNodeAs("nonPublicInheritance")) { ReportError( @@ -68,10 +67,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1173/libtooling/g1173.cc b/googlecpp/g1173/libtooling/g1173.cc index 09504fd0a0..aac7db3473 100644 --- a/googlecpp/g1173/libtooling/g1173.cc +++ b/googlecpp/g1173/libtooling/g1173.cc @@ -48,7 +48,7 @@ int g1173(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1174/libtooling/checker.cc b/googlecpp/g1174/libtooling/checker.cc index ae70e19167..5b0e940e7a 100644 --- a/googlecpp/g1174/libtooling/checker.cc +++ b/googlecpp/g1174/libtooling/checker.cc @@ -53,10 +53,9 @@ set> protected_use_set; // const CXXMethodDecl* unordered_map> protected_name_location; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto protectedFunctionDefinitionMatcher = cxxRecordDecl( @@ -74,7 +73,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(protectedFunctionUseMatcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* protected_decl = result.Nodes.getNodeAs("protecteddecl")) { const auto* class_decled = @@ -113,7 +112,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; void Checker::Run() const { @@ -130,7 +129,7 @@ void Checker::Run() const { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1174/libtooling/g1174.cc b/googlecpp/g1174/libtooling/g1174.cc index b068a9d6a9..aca12b17bc 100644 --- a/googlecpp/g1174/libtooling/g1174.cc +++ b/googlecpp/g1174/libtooling/g1174.cc @@ -48,13 +48,13 @@ int g1174(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/googlecpp/g1176/libtooling/checker.cc b/googlecpp/g1176/libtooling/checker.cc index 710cad28ca..4f39fcf514 100644 --- a/googlecpp/g1176/libtooling/checker.cc +++ b/googlecpp/g1176/libtooling/checker.cc @@ -46,15 +46,14 @@ namespace googlecpp { namespace g1176 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl().bind("functionDecl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* function_decl = result.Nodes.getNodeAs("functionDecl")) { if (misra::libtooling_utils::IsInSystemHeader(function_decl, @@ -73,10 +72,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1176/libtooling/g1176.cc b/googlecpp/g1176/libtooling/g1176.cc index e434e17951..9d305f0314 100644 --- a/googlecpp/g1176/libtooling/g1176.cc +++ b/googlecpp/g1176/libtooling/g1176.cc @@ -48,7 +48,7 @@ int g1176(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1177/libtooling/checker.cc b/googlecpp/g1177/libtooling/checker.cc index 34d227e8a4..4883276766 100644 --- a/googlecpp/g1177/libtooling/checker.cc +++ b/googlecpp/g1177/libtooling/checker.cc @@ -42,10 +42,9 @@ void ReportError(string path, int line_number, ResultsList* results_list) { namespace googlecpp { namespace g1177 { namespace libtooling { -class CastCallback : public ast_matchers::MatchFinder::MatchCallback { +class CastCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto namespace_decl = hasAncestor(namespaceDecl().bind("r_ns")); @@ -64,7 +63,7 @@ class CastCallback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(matcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* sm = result.SourceManager; const auto* func_decl = result.Nodes.getNodeAs("func"); const auto* cxx_record = result.Nodes.getNodeAs("record"); @@ -82,10 +81,10 @@ class CastCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new CastCallback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1177/libtooling/g1177.cc b/googlecpp/g1177/libtooling/g1177.cc index 4a5f5ba00c..7cb22fb743 100644 --- a/googlecpp/g1177/libtooling/g1177.cc +++ b/googlecpp/g1177/libtooling/g1177.cc @@ -48,7 +48,7 @@ int g1177(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1178/libtooling/checker.cc b/googlecpp/g1178/libtooling/checker.cc index d91cc63f9d..12abb1e464 100644 --- a/googlecpp/g1178/libtooling/checker.cc +++ b/googlecpp/g1178/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1178 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto operators = hasAnyName( "operator+", "operator-", "operator*", "operator/", "operator%", @@ -68,7 +67,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* op = result.Nodes.getNodeAs("op_decl"); ReportError(misra::libtooling_utils::GetFilename(op, source_manager), @@ -77,10 +76,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1178/libtooling/g1178.cc b/googlecpp/g1178/libtooling/g1178.cc index 53a26d1500..9e715b5b78 100644 --- a/googlecpp/g1178/libtooling/g1178.cc +++ b/googlecpp/g1178/libtooling/g1178.cc @@ -48,7 +48,7 @@ int g1178(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1179/libtooling/README.md b/googlecpp/g1179/libtooling/README.md deleted file mode 100644 index 042f31c255..0000000000 --- a/googlecpp/g1179/libtooling/README.md +++ /dev/null @@ -1,53 +0,0 @@ -每个checker大概思路是,我存了一个map: key为cxxRecordDecl id, value是opertor set。 -先遍历一遍AST,把遇到的opertor存到对应的map中, -在最后Checker::Run()这个函数中,遍历我存的map,看里面存的operator个数有没有达标。 - -每个checker 我参考了: -https://isocpp.org/wiki/faq/operator-overloading#overview-op-ov -https://en.cppreference.com/w/cpp/language/operators -https://github.com/google/googletest - -根据google test代码 我省去了一些operator overload: -1. stream<< 和 stream>>。因为在阅读代码时,我发现这两个operator可以单独被overload -2. Logical operator, 看代码时没有发现,cppreference 和 https://isocpp.org/wiki/faq/operator-overloading#overview-op-ov -都建议 避免overload这些。 - -### Binary arithmetic operators -在cppreference中提到+和+=是相关联的,所以就按照这个思路来,每一个binary arithmetic operator -对应的map所存下的operator数量应为2. - -### Comparison operators -根据cppreference 和 https://isocpp.org/wiki/faq/operator-overloading#overview-op-ov -```cpp -inline bool operator< (const X& lhs, const X& rhs) { /* do actual comparison */ } -inline bool operator> (const X& lhs, const X& rhs) { return rhs < lhs; } -inline bool operator<=(const X& lhs, const X& rhs) { return !(lhs > rhs); } -inline bool operator>=(const X& lhs, const X& rhs) { return !(lhs < rhs); } -``` - -```cpp -inline bool operator==(const X& lhs, const X& rhs) { /* do actual comparison */ } -inline bool operator!=(const X& lhs, const X& rhs) { return !(lhs == rhs); } -``` -应如此分类 - -### Array subscript operator -在参考https://isocpp.org/wiki/faq/operator-overloading#overview-op-ov中提到: -array subscript 通常成对出现: 一个用来读取,一个用来写入。所以这个map里, -我期望存下的operator个数是2 - -### Bitwise arithmetic operators -与 binary arithmetic相似: &和&=相关,以此类推。 - -### Boolean negation operator -根据 cppreference 和 googletest 的代码。需要同时重载 bool 和 !。 -(这一条有争议,暂时没做) - -I did not handle the case like: -```cpp -inline MyClass operator+(int lhs, MyClass rhs) { - rhs += lhs; - return rhs; -} -``` -if the lhs is a builtin type diff --git a/googlecpp/g1179/libtooling/checker.cc b/googlecpp/g1179/libtooling/checker.cc index b3a0855c45..337e3eef3b 100644 --- a/googlecpp/g1179/libtooling/checker.cc +++ b/googlecpp/g1179/libtooling/checker.cc @@ -61,7 +61,7 @@ void ReportError(string path, int line_number, ResultsList* results_list) { } void ReportGenral( unordered_map>& op_map, - int upper, analyzer::proto::ResultsList* results_list_) { + int upper, ResultsList* results_list_) { for (auto& op : op_map) { if (op.second.size() != 0 && op.second.size() != upper) { for (auto& ele : op.second) { @@ -125,10 +125,9 @@ namespace googlecpp { namespace g1179 { namespace libtooling { -class BitwiseCallback : public ast_matchers::MatchFinder::MatchCallback { +class BitwiseCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // we divide the operators into the following parts, based on // https://en.cppreference.com/w/cpp/language/operators @@ -205,7 +204,7 @@ class BitwiseCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* bitwise_fd1 = result.Nodes.getNodeAs("b1"); auto* bitwise_fd2 = result.Nodes.getNodeAs("b2"); @@ -233,13 +232,12 @@ class BitwiseCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -class ArraySubcriptCallback : public ast_matchers::MatchFinder::MatchCallback { +class ArraySubcriptCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // we divide the operators into the following parts, based on // https://en.cppreference.com/w/cpp/language/operators @@ -258,7 +256,7 @@ class ArraySubcriptCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* as_fd = result.Nodes.getNodeAs("as"); auto* record = result.Nodes.getNodeAs("record"); @@ -267,13 +265,12 @@ class ArraySubcriptCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -class CompareCallback : public ast_matchers::MatchFinder::MatchCallback { +class CompareCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // we divide the operators into the following parts, based on // https://en.cppreference.com/w/cpp/language/operators @@ -302,7 +299,7 @@ class CompareCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* compare_fd1 = result.Nodes.getNodeAs("c1"); auto* compare_fd2 = result.Nodes.getNodeAs("c2"); @@ -319,13 +316,12 @@ class CompareCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -class BinopArithCallback : public ast_matchers::MatchFinder::MatchCallback { +class BinopArithCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // we divide the operators into the following parts, based on // https://en.cppreference.com/w/cpp/language/operators @@ -380,7 +376,7 @@ class BinopArithCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* binary_fd1 = result.Nodes.getNodeAs("binary_fd1"); auto* binary_fd2 = result.Nodes.getNodeAs("binary_fd2"); @@ -416,7 +412,7 @@ class BinopArithCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; void Checker::Run() { @@ -435,7 +431,7 @@ void Checker::Run() { ReportGenral(bitwise_rshift_map_, rshift.size(), results_list_); } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; binop_callback_ = new BinopArithCallback; binop_callback_->Init(results_list_, &finder_); diff --git a/googlecpp/g1179/libtooling/g1179.cc b/googlecpp/g1179/libtooling/g1179.cc index c1d777ca46..aa23249abd 100644 --- a/googlecpp/g1179/libtooling/g1179.cc +++ b/googlecpp/g1179/libtooling/g1179.cc @@ -48,7 +48,7 @@ int g1179(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1180/libtooling/checker.cc b/googlecpp/g1180/libtooling/checker.cc index ab792f96b1..a37fac62b6 100644 --- a/googlecpp/g1180/libtooling/checker.cc +++ b/googlecpp/g1180/libtooling/checker.cc @@ -42,10 +42,9 @@ void ReportError(string path, int line_number, ResultsList* results_list) { namespace googlecpp { namespace g1180 { namespace libtooling { -class CastCallback : public ast_matchers::MatchFinder::MatchCallback { +class CastCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto matcher = cxxMethodDecl( @@ -58,7 +57,7 @@ class CastCallback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(matcher, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; const auto* method = result.Nodes.getNodeAs("method"); ReportError( @@ -68,10 +67,10 @@ class CastCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new CastCallback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1180/libtooling/g1180.cc b/googlecpp/g1180/libtooling/g1180.cc index 662a65b739..9d12ac8b90 100644 --- a/googlecpp/g1180/libtooling/g1180.cc +++ b/googlecpp/g1180/libtooling/g1180.cc @@ -48,7 +48,7 @@ int g1180(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1181/libtooling/checker.cc b/googlecpp/g1181/libtooling/checker.cc index c102b198ca..e2e03ee7db 100644 --- a/googlecpp/g1181/libtooling/checker.cc +++ b/googlecpp/g1181/libtooling/checker.cc @@ -37,8 +37,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "Do not overload &&, ||, , (comma), or unary &"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1181/libtooling/g1181.cc b/googlecpp/g1181/libtooling/g1181.cc index 66991f5216..116444e8b2 100644 --- a/googlecpp/g1181/libtooling/g1181.cc +++ b/googlecpp/g1181/libtooling/g1181.cc @@ -47,7 +47,7 @@ int g1181(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/googlecpp/g1182/libtooling/checker.cc b/googlecpp/g1182/libtooling/checker.cc index 1ccf7547ca..80cc748b58 100644 --- a/googlecpp/g1182/libtooling/checker.cc +++ b/googlecpp/g1182/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1182 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // for non-static class member variable finder->addMatcher( @@ -67,7 +66,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto const SM = result.SourceManager; auto const decl = result.Nodes.getNodeAs("decl"); ReportError(misra::libtooling_utils::GetFilename(decl, SM), @@ -75,10 +74,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1182/libtooling/g1182.cc b/googlecpp/g1182/libtooling/g1182.cc index a249737f05..c9a4628a54 100644 --- a/googlecpp/g1182/libtooling/g1182.cc +++ b/googlecpp/g1182/libtooling/g1182.cc @@ -48,7 +48,7 @@ int g1182(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1183/libtooling/checker.cc b/googlecpp/g1183/libtooling/checker.cc index cd9a8048ba..596cc677cc 100644 --- a/googlecpp/g1183/libtooling/checker.cc +++ b/googlecpp/g1183/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1183 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl(isClass(), unless(isExpansionInSystemHeader())) @@ -57,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto* SM = result.SourceManager; const auto* record_decl = result.Nodes.getNodeAs("record_decl"); unsigned int first_decl_line = 0; @@ -132,7 +131,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; struct ClassInfo { unsigned int public_line = 0; unsigned int protected_line = 0; @@ -141,7 +140,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { }; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1183/libtooling/g1183.cc b/googlecpp/g1183/libtooling/g1183.cc index 9b53f51190..12e21584ff 100644 --- a/googlecpp/g1183/libtooling/g1183.cc +++ b/googlecpp/g1183/libtooling/g1183.cc @@ -48,7 +48,7 @@ int g1183(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1184/libtooling/checker.cc b/googlecpp/g1184/libtooling/checker.cc index 0bf19e943b..930d9f4c9d 100644 --- a/googlecpp/g1184/libtooling/checker.cc +++ b/googlecpp/g1184/libtooling/checker.cc @@ -47,10 +47,9 @@ namespace googlecpp { namespace g1184 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxRecordDecl(unless(isExpansionInSystemHeader()), unless(isImplicit()), isClass()) @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const auto* record_decl = result.Nodes.getNodeAs("record_decl"); auto const SM = result.SourceManager; @@ -121,7 +120,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; enum Kind { TypesAndTypeAliases, StaticConstants, @@ -140,7 +139,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { decls_by_access_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1184/libtooling/g1184.cc b/googlecpp/g1184/libtooling/g1184.cc index 2db8d0fa6c..e50e44eca5 100644 --- a/googlecpp/g1184/libtooling/g1184.cc +++ b/googlecpp/g1184/libtooling/g1184.cc @@ -48,7 +48,7 @@ int g1184(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1185/libtooling/checker.cc b/googlecpp/g1185/libtooling/checker.cc index 17fbaec969..018829e3a3 100644 --- a/googlecpp/g1185/libtooling/checker.cc +++ b/googlecpp/g1185/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1185 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxMethodDecl(unless(isExpansionInSystemHeader()), anyOf(isInline(), isConstexpr())) @@ -57,7 +56,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const auto* func = result.Nodes.getNodeAs("func"); // Get the number of lines of a function auto* SM = result.SourceManager; @@ -71,10 +70,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1185/libtooling/g1185.cc b/googlecpp/g1185/libtooling/g1185.cc index bed5e6edaf..39cd19ba54 100644 --- a/googlecpp/g1185/libtooling/g1185.cc +++ b/googlecpp/g1185/libtooling/g1185.cc @@ -48,7 +48,7 @@ int g1185(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1186/libtooling/checker.cc b/googlecpp/g1186/libtooling/checker.cc index d3a91e7f19..7bc3720d6a 100644 --- a/googlecpp/g1186/libtooling/checker.cc +++ b/googlecpp/g1186/libtooling/checker.cc @@ -32,10 +32,9 @@ namespace googlecpp { namespace g1186 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // can not handle situations that the parameter is changed as parameter to // another function, e.g. @@ -98,7 +97,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { return param_infos; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { FunctionDecl const* const func = result.Nodes.getNodeAs("func"); DeclRefExpr const* const binary_lhs = diff --git a/googlecpp/g1186/libtooling/g1186.cc b/googlecpp/g1186/libtooling/g1186.cc index a74a618dde..fc3037eb19 100644 --- a/googlecpp/g1186/libtooling/g1186.cc +++ b/googlecpp/g1186/libtooling/g1186.cc @@ -66,13 +66,13 @@ int g1186(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); tooling::ClangTool tool(op.getCompilations(), op.getSourcePathList()); - analyzer::proto::ResultsList all_results; + ResultsList all_results; googlecpp::g1186::libtooling::Checker checker; checker.Init(&all_results); diff --git a/googlecpp/g1188/libtooling/checker.cc b/googlecpp/g1188/libtooling/checker.cc index 25297db58f..7251e11e9c 100644 --- a/googlecpp/g1188/libtooling/checker.cc +++ b/googlecpp/g1188/libtooling/checker.cc @@ -34,15 +34,14 @@ namespace g1188 { namespace libtooling { extern FuncInfo2ParamInfos func_info_2_param_infos; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; AddFuncOutputParamMatchers(finder, this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { FuncOutputParamCallback(result, func_info_2_param_infos); } diff --git a/googlecpp/g1188/libtooling/g1188.cc b/googlecpp/g1188/libtooling/g1188.cc index 4d8ad98a97..405d4108d6 100644 --- a/googlecpp/g1188/libtooling/g1188.cc +++ b/googlecpp/g1188/libtooling/g1188.cc @@ -67,13 +67,13 @@ int g1188(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); tooling::ClangTool tool(op.getCompilations(), op.getSourcePathList()); - analyzer::proto::ResultsList all_results; + ResultsList all_results; googlecpp::g1188::libtooling::Checker checker; checker.Init(&all_results); diff --git a/googlecpp/g1189/libtooling/checker.cc b/googlecpp/g1189/libtooling/checker.cc index a8406ce10a..2436c4f89f 100644 --- a/googlecpp/g1189/libtooling/checker.cc +++ b/googlecpp/g1189/libtooling/checker.cc @@ -46,16 +46,16 @@ namespace googlecpp { namespace g1189 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder, int maximum_allowed_func_line) { + void Init(ResultsList* results_list, MatchFinder* finder, + int maximum_allowed_func_line) { results_list_ = results_list; finder->addMatcher(functionDecl().bind("func"), this); maximum_allowed_func_line_ = maximum_allowed_func_line; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* func = result.Nodes.getNodeAs("func")) { if (misra::libtooling_utils::IsInSystemHeader(func, result.Context)) return; @@ -76,12 +76,11 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; int maximum_allowed_func_line_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list, - int maximum_allowed_func_line) { +void Checker::Init(ResultsList* results_list, int maximum_allowed_func_line) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_, maximum_allowed_func_line); diff --git a/googlecpp/g1189/libtooling/g1189.cc b/googlecpp/g1189/libtooling/g1189.cc index d27c41d778..9a2853babd 100644 --- a/googlecpp/g1189/libtooling/g1189.cc +++ b/googlecpp/g1189/libtooling/g1189.cc @@ -49,7 +49,7 @@ int g1189(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1190/libtooling/checker.cc b/googlecpp/g1190/libtooling/checker.cc index 3249879987..5c6d09f236 100644 --- a/googlecpp/g1190/libtooling/checker.cc +++ b/googlecpp/g1190/libtooling/checker.cc @@ -38,8 +38,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "Default arguments are banned on virtual functions, where they don't work properly, and in cases where the specified default might not evaluate to the same value depending on when it was evaluated"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1190/libtooling/g1190.cc b/googlecpp/g1190/libtooling/g1190.cc index e0d6a960ce..9441cd715d 100644 --- a/googlecpp/g1190/libtooling/g1190.cc +++ b/googlecpp/g1190/libtooling/g1190.cc @@ -47,7 +47,7 @@ int g1190(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/googlecpp/g1191/libtooling/checker.cc b/googlecpp/g1191/libtooling/checker.cc index 97c8f8835d..40df15638d 100644 --- a/googlecpp/g1191/libtooling/checker.cc +++ b/googlecpp/g1191/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1191 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; Matcher rref = hasUnqualifiedDesugaredType(rValueReferenceType()); @@ -88,7 +87,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto checkTypeAndReport = [&result, this](const Decl* decl) { ReportError( misra::libtooling_utils::GetFilename(decl, result.SourceManager), @@ -104,10 +103,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1191/libtooling/g1191.cc b/googlecpp/g1191/libtooling/g1191.cc index fed0aa002c..6c4011f641 100644 --- a/googlecpp/g1191/libtooling/g1191.cc +++ b/googlecpp/g1191/libtooling/g1191.cc @@ -48,7 +48,7 @@ int g1191(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1192/libtooling/checker.cc b/googlecpp/g1192/libtooling/checker.cc index 57ccae8824..5e4c92db9b 100644 --- a/googlecpp/g1192/libtooling/checker.cc +++ b/googlecpp/g1192/libtooling/checker.cc @@ -51,8 +51,7 @@ struct MethodInfo { int line_number; }; -class FriendInSameFileCallback - : public ast_matchers::MatchFinder::MatchCallback { +class FriendInSameFileCallback : public MatchFinder::MatchCallback { public: std::unordered_map friend_func_decl_locs_; // Store all friend function declaration @@ -63,8 +62,7 @@ class FriendInSameFileCallback std::unordered_map class_def_locs_; // Store all class definition - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Get all friend declaration(including class and function) finder->addMatcher( @@ -83,7 +81,7 @@ class FriendInSameFileCallback this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; SourceManager* source_manager = result.SourceManager; @@ -133,7 +131,7 @@ class FriendInSameFileCallback static constexpr int class_prefix_length = 6; // The i = 6 indicates the length of string "class " - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; // Subtract the class name from string like "class A" or "class A" std::string getClassName(std::string class_str) { @@ -178,7 +176,7 @@ void Checker::Run() const { } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new FriendInSameFileCallback; callback_->Init(result_list, &finder_); diff --git a/googlecpp/g1192/libtooling/g1192.cc b/googlecpp/g1192/libtooling/g1192.cc index abee0251da..5ef503dba0 100644 --- a/googlecpp/g1192/libtooling/g1192.cc +++ b/googlecpp/g1192/libtooling/g1192.cc @@ -48,7 +48,7 @@ int g1192(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1193/libtooling/checker.cc b/googlecpp/g1193/libtooling/checker.cc index 195f902884..ca267b639c 100644 --- a/googlecpp/g1193/libtooling/checker.cc +++ b/googlecpp/g1193/libtooling/checker.cc @@ -45,16 +45,15 @@ namespace googlecpp { namespace g1193 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(naivesystemsCxxTypeidExpr().bind("typeid"), this); finder->addMatcher(cxxDynamicCastExpr().bind("dynamic_cast"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto report = [&result, this](const Expr* expr) { if (misra::libtooling_utils::IsInSystemHeader(expr, result.Context)) return; @@ -73,10 +72,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1193/libtooling/g1193.cc b/googlecpp/g1193/libtooling/g1193.cc index f4ddd1c81b..153e1fc675 100644 --- a/googlecpp/g1193/libtooling/g1193.cc +++ b/googlecpp/g1193/libtooling/g1193.cc @@ -48,7 +48,7 @@ int g1193(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1194/libtooling/checker.cc b/googlecpp/g1194/libtooling/checker.cc index 90a366d30c..823c61ca99 100644 --- a/googlecpp/g1194/libtooling/checker.cc +++ b/googlecpp/g1194/libtooling/checker.cc @@ -45,15 +45,14 @@ namespace googlecpp { namespace g1194 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cStyleCastExpr().bind("cstylecast"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* cstylecast = result.Nodes.getNodeAs("cstylecast")) { if (misra::libtooling_utils::IsInSystemHeader(cstylecast, result.Context)) @@ -69,10 +68,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1194/libtooling/g1194.cc b/googlecpp/g1194/libtooling/g1194.cc index 9dff400fa2..918413bc08 100644 --- a/googlecpp/g1194/libtooling/g1194.cc +++ b/googlecpp/g1194/libtooling/g1194.cc @@ -48,7 +48,7 @@ int g1194(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1195/libtooling/checker.cc b/googlecpp/g1195/libtooling/checker.cc index 45fedbb5ef..6b34adfba3 100644 --- a/googlecpp/g1195/libtooling/checker.cc +++ b/googlecpp/g1195/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1195 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( unaryOperator( @@ -68,7 +67,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; SourceManager* source_manager = result.SourceManager; auto* uo1 = result.Nodes.getNodeAs("uo1"); @@ -93,10 +92,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1195/libtooling/g1195.cc b/googlecpp/g1195/libtooling/g1195.cc index e90b124576..2cf4a7c8f7 100644 --- a/googlecpp/g1195/libtooling/g1195.cc +++ b/googlecpp/g1195/libtooling/g1195.cc @@ -48,7 +48,7 @@ int g1195(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1196/libtooling/checker.cc b/googlecpp/g1196/libtooling/checker.cc index 08e668170b..5140a16faa 100644 --- a/googlecpp/g1196/libtooling/checker.cc +++ b/googlecpp/g1196/libtooling/checker.cc @@ -46,10 +46,9 @@ namespace googlecpp { namespace g1196 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Note: isConstQualified only matches the parameter where there is // a top-level const on its type, e.g., it does not match "const int *". @@ -60,7 +59,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); ReportError(misra::libtooling_utils::GetFilename(fd, result.SourceManager), misra::libtooling_utils::GetLine(fd, result.SourceManager), @@ -68,10 +67,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1196/libtooling/g1196.cc b/googlecpp/g1196/libtooling/g1196.cc index 96d592cc8f..63075f1381 100644 --- a/googlecpp/g1196/libtooling/g1196.cc +++ b/googlecpp/g1196/libtooling/g1196.cc @@ -48,7 +48,7 @@ int g1196(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1200/libtooling/g1200.cc b/googlecpp/g1200/libtooling/g1200.cc index 2b37bc0323..246de967b7 100644 --- a/googlecpp/g1200/libtooling/g1200.cc +++ b/googlecpp/g1200/libtooling/g1200.cc @@ -48,7 +48,7 @@ int g1200(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1201/libtooling/g1201.cc b/googlecpp/g1201/libtooling/g1201.cc index a653a565e8..9d70a78aea 100644 --- a/googlecpp/g1201/libtooling/g1201.cc +++ b/googlecpp/g1201/libtooling/g1201.cc @@ -51,7 +51,7 @@ int g1201(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1202/libtooling/checker.cc b/googlecpp/g1202/libtooling/checker.cc index 7d61205d28..0e9d079dcd 100644 --- a/googlecpp/g1202/libtooling/checker.cc +++ b/googlecpp/g1202/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1202 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // To catch every use of NULL @@ -77,7 +76,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto Report = [&](const Stmt* stmt) { if (misra::libtooling_utils::IsInSystemHeader(stmt, result.Context)) return; @@ -96,10 +95,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1202/libtooling/g1202.cc b/googlecpp/g1202/libtooling/g1202.cc index e04e424d97..f74d1c65f5 100644 --- a/googlecpp/g1202/libtooling/g1202.cc +++ b/googlecpp/g1202/libtooling/g1202.cc @@ -48,7 +48,7 @@ int g1202(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1203/libtooling/checker.cc b/googlecpp/g1203/libtooling/checker.cc index 6ea0553b49..f033227619 100644 --- a/googlecpp/g1203/libtooling/checker.cc +++ b/googlecpp/g1203/libtooling/checker.cc @@ -45,10 +45,9 @@ namespace googlecpp { namespace g1203 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Match all the sizeof() @@ -61,7 +60,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; auto* sizeof_expr = result.Nodes.getNodeAs("sizeof_expr"); @@ -76,10 +75,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1203/libtooling/g1203.cc b/googlecpp/g1203/libtooling/g1203.cc index 91717a9e96..41a670ca32 100644 --- a/googlecpp/g1203/libtooling/g1203.cc +++ b/googlecpp/g1203/libtooling/g1203.cc @@ -48,7 +48,7 @@ int g1203(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1204/libtooling/checker.cc b/googlecpp/g1204/libtooling/checker.cc index d2a251bf3c..b8687384f4 100644 --- a/googlecpp/g1204/libtooling/checker.cc +++ b/googlecpp/g1204/libtooling/checker.cc @@ -76,14 +76,13 @@ namespace googlecpp { namespace g1204 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { int maxAllowedReturnNum; int maxAllowedFuncLine; public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder, int maxAllowedReturnNum, - int maxAllowedFuncLine) { + void Init(ResultsList* results_list, MatchFinder* finder, + int maxAllowedReturnNum, int maxAllowedFuncLine) { results_list_ = results_list; // It will also catch lambda functions finder->addMatcher(functionDecl().bind("func"), this); @@ -91,7 +90,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this->maxAllowedFuncLine = maxAllowedFuncLine; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* func = result.Nodes.getNodeAs("func")) { if (misra::libtooling_utils::IsInSystemHeader(func, result.Context)) return; @@ -115,11 +114,11 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list, - int maxAllowedReturnNum, int maxAllowedFuncLine) { +void Checker::Init(ResultsList* results_list, int maxAllowedReturnNum, + int maxAllowedFuncLine) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_, maxAllowedReturnNum, diff --git a/googlecpp/g1204/libtooling/g1204.cc b/googlecpp/g1204/libtooling/g1204.cc index fa953eb70c..4a152c6f3d 100644 --- a/googlecpp/g1204/libtooling/g1204.cc +++ b/googlecpp/g1204/libtooling/g1204.cc @@ -53,7 +53,7 @@ int g1204(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1205/libtooling/checker.cc b/googlecpp/g1205/libtooling/checker.cc index 74fa71ef4a..16a5b0debd 100644 --- a/googlecpp/g1205/libtooling/checker.cc +++ b/googlecpp/g1205/libtooling/checker.cc @@ -46,17 +46,16 @@ namespace googlecpp { namespace g1205 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // We use this to catch any non-lambda functions... finder->addMatcher( functionDecl(unless(hasAncestor(lambdaExpr()))).bind("func"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { if (const auto* func = result.Nodes.getNodeAs("func")) { if (misra::libtooling_utils::IsInSystemHeader(func, result.Context)) return; @@ -72,10 +71,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/googlecpp/g1205/libtooling/g1205.cc b/googlecpp/g1205/libtooling/g1205.cc index ef6a36811d..3356896f7b 100644 --- a/googlecpp/g1205/libtooling/g1205.cc +++ b/googlecpp/g1205/libtooling/g1205.cc @@ -48,7 +48,7 @@ int g1205(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1209/libtooling/checker.cc b/googlecpp/g1209/libtooling/checker.cc index e9ba26ef9b..1fb5043cd5 100644 --- a/googlecpp/g1209/libtooling/checker.cc +++ b/googlecpp/g1209/libtooling/checker.cc @@ -35,8 +35,7 @@ void ReportError(string path, int line_number, analyzer::proto::ResultsList* results_list) { string error_message = "Use default capture by value ([=]) only as a means of binding a few variables for a short lambda, where the set of captured variables is obvious at a glance"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1209/libtooling/g1209.cc b/googlecpp/g1209/libtooling/g1209.cc index e872766be9..cc21aa1c73 100644 --- a/googlecpp/g1209/libtooling/g1209.cc +++ b/googlecpp/g1209/libtooling/g1209.cc @@ -48,7 +48,7 @@ int g1209(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1210/libtooling/checker.cc b/googlecpp/g1210/libtooling/checker.cc index 00e99f5680..03534cf434 100644 --- a/googlecpp/g1210/libtooling/checker.cc +++ b/googlecpp/g1210/libtooling/checker.cc @@ -35,8 +35,7 @@ void ReportError(string path, int line_number, analyzer::proto::ResultsList* results_list) { string error_message = "Use capture by value explicitly or capture by reference for non-static class members in non-static member functions"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1210/libtooling/g1210.cc b/googlecpp/g1210/libtooling/g1210.cc index eedff5abfd..44f43a9038 100644 --- a/googlecpp/g1210/libtooling/g1210.cc +++ b/googlecpp/g1210/libtooling/g1210.cc @@ -48,7 +48,7 @@ int g1210(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1211/libtooling/checker.cc b/googlecpp/g1211/libtooling/checker.cc index cf76e6a2d3..9f95bfa154 100644 --- a/googlecpp/g1211/libtooling/checker.cc +++ b/googlecpp/g1211/libtooling/checker.cc @@ -34,8 +34,7 @@ namespace { void ReportError(string path, int line_number, analyzer::proto::ResultsList* results_list) { string error_message = "Don't introduce new names in captures"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } diff --git a/googlecpp/g1211/libtooling/g1211.cc b/googlecpp/g1211/libtooling/g1211.cc index 7af81968da..bacad83aa4 100644 --- a/googlecpp/g1211/libtooling/g1211.cc +++ b/googlecpp/g1211/libtooling/g1211.cc @@ -48,7 +48,7 @@ int g1211(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/googlecpp/g1216/libtooling/checker.cc b/googlecpp/g1216/libtooling/checker.cc index 02cc6a5ba6..4a6b2d3ab7 100644 --- a/googlecpp/g1216/libtooling/checker.cc +++ b/googlecpp/g1216/libtooling/checker.cc @@ -37,8 +37,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "Don't use nonstandard extensions"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, line_number); } @@ -120,7 +119,7 @@ void DeclCallback::run(const MatchFinder::MatchResult& result) { } } -void ASTChecker::Init(analyzer::proto::ResultsList* results_list) { +void ASTChecker::Init(ResultsList* results_list) { results_list_ = results_list; DeclarationMatcher attr_matcher = decl(unless(isExpansionInSystemHeader())).bind("decl"); diff --git a/googlecpp/g1216/libtooling/g1216.cc b/googlecpp/g1216/libtooling/g1216.cc index 029851e8cf..de1d76496f 100644 --- a/googlecpp/g1216/libtooling/g1216.cc +++ b/googlecpp/g1216/libtooling/g1216.cc @@ -47,7 +47,7 @@ int g1216(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/googlecpp/g1269/libtooling/checker.cc b/googlecpp/g1269/libtooling/checker.cc index c7a542d9ff..25bcb08556 100644 --- a/googlecpp/g1269/libtooling/checker.cc +++ b/googlecpp/g1269/libtooling/checker.cc @@ -48,11 +48,9 @@ namespace libtooling { set record_decl_set; -class FriendInSameFileCallback - : public ast_matchers::MatchFinder::MatchCallback { +class FriendInSameFileCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxRecordDecl(unless(isExpansionInSystemHeader()), @@ -61,7 +59,7 @@ class FriendInSameFileCallback this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { SourceManager* source_manager = result.SourceManager; auto* record_decl = result.Nodes.getNodeAs("record"); @@ -91,10 +89,10 @@ class FriendInSameFileCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new FriendInSameFileCallback; callback_->Init(result_list, &finder_); } diff --git a/googlecpp/g1269/libtooling/g1269.cc b/googlecpp/g1269/libtooling/g1269.cc index 7a049e6225..b54df01a1e 100644 --- a/googlecpp/g1269/libtooling/g1269.cc +++ b/googlecpp/g1269/libtooling/g1269.cc @@ -48,7 +48,7 @@ int g1269(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra/C7966/checker.cc b/misra/C7966/checker.cc index 01c1a0f6c4..05fcff0634 100644 --- a/misra/C7966/checker.cc +++ b/misra/C7966/checker.cc @@ -38,7 +38,7 @@ struct Loc { string begin_loc; }; void ReportError(string filename, int line, ResultsList* results_list) { - std::string error_message = "[C7966][NAIVESYSTEMS_C7966]: violation of C7966"; + string error_message = "[C7966][NAIVESYSTEMS_C7966]: violation of C7966"; analyzer::proto::Result* pb_result = AddResultToResultsList(results_list, filename, line, error_message); pb_result->set_error_kind( @@ -94,7 +94,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra/C7966/main.cc b/misra/C7966/main.cc index b58535f344..42d777a072 100644 --- a/misra/C7966/main.cc +++ b/misra/C7966/main.cc @@ -48,7 +48,7 @@ int C7966(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/analyzer/analyzerinterface/analyzerinterface.go b/misra/analyzer/analyzerinterface/analyzerinterface.go index 5890afe592..34cafb9e78 100644 --- a/misra/analyzer/analyzerinterface/analyzerinterface.go +++ b/misra/analyzer/analyzerinterface/analyzerinterface.go @@ -41,11 +41,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" pb "naive.systems/analyzer/analyzer/proto" - "naive.systems/analyzer/cruleslib/filter" "naive.systems/analyzer/misra/checker_integration/checkrule" "naive.systems/analyzer/misra/checker_integration/compilecommand" "naive.systems/analyzer/misra/utils" - "naive.systems/analyzer/rulesets" rs "naive.systems/analyzer/rulesets" ) @@ -66,12 +64,13 @@ func (i *ArrayFlags) Set(value string) error { type ProjectType int const ( - Other ProjectType = 0 - CMake ProjectType = 1 - Make ProjectType = 2 - Keil ProjectType = 3 - QMake ProjectType = 4 - Script ProjectType = 5 + Other ProjectType = iota + CMake + Make + Keil + QMake + Script + None ) func PrintCmdOutput(cmd *exec.Cmd) error { @@ -85,35 +84,27 @@ func PrintCmdOutput(cmd *exec.Cmd) error { } func createFakeCCJson(srcdir, compileCommandsPath string) { - var cppFiles []string - err := filepath.Walk(srcdir, func(path string, info os.FileInfo, err error) error { - // Check for errors during traversal. - if err != nil { - return err - } - // Ignore directories. - if info.IsDir() { - return nil - } - // Check if file has cpp extension. - if filter.IsCCFile(path) { - if !strings.HasPrefix(path, "/src/") { - cppFiles = append(cppFiles, filepath.Join(srcdir, path)) - } else { - cppFiles = append(cppFiles, path) - } + countLangs := []string{"C", "C++"} + clocOpts := gocloc.NewClocOptions() + languages := gocloc.NewDefinedLanguages() + for _, lang := range countLangs { + if _, exists := languages.Langs[lang]; exists { + clocOpts.IncludeLangs[lang] = struct{}{} } - return nil - }) + } + clocOpts.SkipDuplicated = true // skip duplicated check + processor := gocloc.NewProcessor(languages, clocOpts) + result, err := processor.Analyze([]string{srcdir}) if err != nil { - glog.Fatalf("createFakeCCJson: Failed to walk src dir %v", err) + glog.Errorf("gocloc fail: %v", err) } var commands []compilecommand.CompileCommand - for _, file := range cppFiles { + for _, file := range result.Files { var command compilecommand.CompileCommand - command.File = file + command.File = file.Name command.Directory = srcdir + command.Command = "clang -c " + file.Name commands = append(commands, command) } content, err := json.Marshal(&commands) @@ -163,6 +154,8 @@ func CheckCompilationDatabase( err, cc_exist = CreateCompilationDatabaseByQMake(compileCommandsPath, dir, qmakeBin, qtProPath) case Script: err = CreateCompilationDatabaseByScript(dir, scriptContents) + case None: + createFakeCCJson(dir, compileCommandsPath) case Other: glog.Fatalf("no viable builder found in %s. Stop", dir) } @@ -174,8 +167,9 @@ func CheckCompilationDatabase( } if !cc_exist || isEmptyFileContent(compileCommandsPath) { createFakeCCJson(dir, compileCommandsPath) + } else { + buildFailed = true } - buildFailed = true } } @@ -574,6 +568,11 @@ func FormatResultPath(allResults *pb.ResultsList, srcDir string) *pb.ResultsList if !filepath.IsAbs(result.Path) { result.Path = filepath.Join(srcDir, result.Path) } + _, err := os.Stat(result.Path) + if err != nil { + glog.Errorf("invalid path %s from %s/%s: %v", result.Path, result.Ruleset, result.RuleId, err) + continue + } for _, location := range result.Locations { if !filepath.IsAbs(location.Path) { location.Path = filepath.Join(srcDir, location.Path) @@ -818,7 +817,7 @@ func GenerateReport(allResults *pb.ResultsList, srcDir, reportPath, lang string) var errorMessage string errorMessage, externalMessage, _ = strings.Cut(result.ErrorMessage, "\n") var displayGuideline string - for n, guideline := range rulesets.GUIDELINES { + for n, guideline := range rs.GUIDELINES { if strings.Contains(errorMessage, guideline) { displayGuideline = n break @@ -828,7 +827,7 @@ func GenerateReport(allResults *pb.ResultsList, srcDir, reportPath, lang string) glog.Errorf("cannot match rule set for %s", errorMessage) continue } - fullRuleName = rulesets.GetRuleFullName(displayGuideline, errorMessage) + fullRuleName = rs.GetRuleFullName(displayGuideline, errorMessage) if fullRuleName == "" { glog.Errorf("cannot match rule name for %s", errorMessage) continue diff --git a/misra/analyzer/cmd/.gitignore b/misra/analyzer/cmd/.gitignore index 270c881a3f..8185262fa0 100644 --- a/misra/analyzer/cmd/.gitignore +++ b/misra/analyzer/cmd/.gitignore @@ -1,3 +1,2 @@ /misra_analyzer -catalog.go locales/**/out.gotext.json diff --git a/misra/analyzer/cmd/Makefile b/misra/analyzer/cmd/Makefile index b03ec33030..35a8c26b6a 100644 --- a/misra/analyzer/cmd/Makefile +++ b/misra/analyzer/cmd/Makefile @@ -2,5 +2,4 @@ LIMIT=0 NUM_WORKERS=0 LANG="zh" all: - go generate naive.systems/analyzer/misra/... - go build -tags static -o misra_analyzer -ldflags "-X main.linesLimitStr=$(LIMIT) -X main.numWorkersStr=$(NUM_WORKERS) -X main.lang=$(LANG)" + go build -tags static -o misra_analyzer -ldflags "-X main.linesLimitStr=$(LIMIT) -X main.numWorkersStr=$(NUM_WORKERS) -X main.lang=$(LANG)" -trimpath diff --git a/misra/analyzer/cmd/catalog.go b/misra/analyzer/cmd/catalog.go new file mode 100644 index 0000000000..aeadac784e --- /dev/null +++ b/misra/analyzer/cmd/catalog.go @@ -0,0 +1,2210 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package main + +import ( + "golang.org/x/text/language" + "golang.org/x/text/message" + "golang.org/x/text/message/catalog" +) + +type dictionary struct { + index []uint32 + data string +} + +func (d *dictionary) Lookup(key string) (data string, ok bool) { + p, ok := messageKeyToIndex[key] + if !ok { + return "", false + } + start, end := d.index[p], d.index[p+1] + if start == end { + return "", false + } + return d.data[start:end], true +} + +func init() { + dict := map[string]catalog.Dictionary{ + "en": &dictionary{index: enIndex, data: enData}, + "zh": &dictionary{index: zhIndex, data: zhData}, + } + fallback := language.MustParse("en") + cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback)) + if err != nil { + panic(err) + } + message.DefaultCatalog = cat +} + +var messageKeyToIndex = map[string]int{ + "%d lines of C code": 477, + "%d lines of C++ code": 478, + "%d lines of headers": 479, + "%s BuildAction preparation completed (%v/%v)": 487, + "%s CTU information generated (%v/%v)": 490, + "%s STU information preparation completed (%v/%v)": 484, + "Analysis completed [%s]": 486, + "Analysis of %s completed (%s, %v/%v) [%s]": 8, + "Analyzing C/C++ files completed [%s]": 6, + "BuildAction preparation completed [%s]": 488, + "CTU information generated successfully [%s]": 491, + "CTU information preparation completed [%s]": 482, + "Preprocessing C/C++ files completed [%s]": 3, + "STU information preparation completed [%s]": 485, + "Start analyzing C/C++ files": 5, + "Start analyzing for %s (%v/%v)": 7, + "Start parsing compilation database": 1, + "Start preparing CTU information": 481, + "Start preparing STU information": 483, + "Start preprocessing C/C++ files": 2, + "Start to generate compilation database": 0, + "Starting generating CTU information": 489, + "Starting writing CTU information": 492, + "Total time for analysis: %s": 4, + "Use %d CPU(s)": 480, + "Violation of MISRA C++:2008 Rule 0-1-10: Every defined function shall be called at least once.": 258, + "Violation of MISRA C++:2008 Rule 0-1-11: There shall be no unused parameters (named or unnamed) in non-virtual functions.": 259, + "Violation of MISRA C++:2008 Rule 0-1-12: There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.": 260, + "Violation of MISRA C++:2008 Rule 0-1-1: A project shall not contain unreachable code.": 249, + "Violation of MISRA C++:2008 Rule 0-1-2: A project shall not contain infeasible paths.": 250, + "Violation of MISRA C++:2008 Rule 0-1-3: A project shall not contain unused variables.": 251, + "Violation of MISRA C++:2008 Rule 0-1-4: A project shall not contain non-volatile POD variables having only one use.": 252, + "Violation of MISRA C++:2008 Rule 0-1-5: A project shall not contain unused type declarations.": 253, + "Violation of MISRA C++:2008 Rule 0-1-6: A project shall not contain instances of non-volatile variables being given values that are never subsequently used.": 254, + "Violation of MISRA C++:2008 Rule 0-1-7: The value returned by a function having a non-void return type that is not an overloaded operator shall always be used.": 255, + "Violation of MISRA C++:2008 Rule 0-1-8: All functions with void return type shall have external side effect(s).": 256, + "Violation of MISRA C++:2008 Rule 0-1-9: There shall be no dead code.": 257, + "Violation of MISRA C++:2008 Rule 0-2-1: An object shall not be assigned to an overlapping object.": 261, + "Violation of MISRA C++:2008 Rule 0-3-1: Minimization of run-time failures shall be ensured by the use of at least one of: (a) static analysis tools/techniques; (b) dynamic tools/techniques; (c) explicit coding of checks to handle run-time faults.": 262, + "Violation of MISRA C++:2008 Rule 0-3-2: If a function generates error information, then that error information shall be tested.": 263, + "Violation of MISRA C++:2008 Rule 0-4-1: Use of scaled-integer or fixed-point arithmetic shall be documented.": 264, + "Violation of MISRA C++:2008 Rule 0-4-2: Use of floating-point arithmetic shall be documented.": 265, + "Violation of MISRA C++:2008 Rule 0-4-3: Floating-point implementations shall comply with a defined floating-point standard.": 266, + "Violation of MISRA C++:2008 Rule 1-0-1: All code shall conform to ISO/IEC 14882:2003 \"The C++ Standard Incorporating Technical Corrigendum 1\".": 267, + "Violation of MISRA C++:2008 Rule 1-0-2: Multiple compilers shall only be used if they have a common, defined interface.": 268, + "Violation of MISRA C++:2008 Rule 1-0-3: The implementation of integer division in the chosen compiler shall be determined and documented.": 269, + "Violation of MISRA C++:2008 Rule 10-1-1: Classes should not be derived from virtual bases.": 403, + "Violation of MISRA C++:2008 Rule 10-1-2: A base class shall only be declared virtual if it is used in a diamond hierarchy.": 404, + "Violation of MISRA C++:2008 Rule 10-1-3: An accessible base class shall not be both virtual and non-virtual in the same hierarchy.": 405, + "Violation of MISRA C++:2008 Rule 10-2-1: All accessible entity names within a multiple inheritance hierarchy should be unique.": 406, + "Violation of MISRA C++:2008 Rule 10-3-1: There shall be no more than one definition of each virtual function on each path through the inheritance hierarchy.": 407, + "Violation of MISRA C++:2008 Rule 10-3-2: Each overriding virtual function shall be declared with the virtual keyword.": 408, + "Violation of MISRA C++:2008 Rule 10-3-3: A virtual function shall only be overridden by a pure virtual function if it is itself declared as pure virtual.": 409, + "Violation of MISRA C++:2008 Rule 11-0-1: Member data in non-POD class types shall be private.": 410, + "Violation of MISRA C++:2008 Rule 12-1-1: An object's dynamic type shall not be used from the body of its constructor or destructor.": 411, + "Violation of MISRA C++:2008 Rule 12-1-2: AlI constructors of a class should explicitly call a constructor for all of its immediate base classes and all virtual base classes.": 412, + "Violation of MISRA C++:2008 Rule 12-1-3: All constructors that are callable with a single argument of fundamental type shall be declared explicit.": 413, + "Violation of MISRA C++:2008 Rule 12-8-1: A copy constructor shall only initialize its base classes and the non-static members of the class of which it is a member.": 414, + "Violation of MISRA C++:2008 Rule 12-8-2: The copy assignment operator shall be declared protected or private in an abstract class.": 415, + "Violation of MISRA C++:2008 Rule 14-5-1: A non-member genericfunction shall only be declared in a namespace that is not an associated namespace.": 416, + "Violation of MISRA C++:2008 Rule 14-5-2: A copy constructor shall be declared when there is a template constuctor with a single parameter that is a generic parameter.": 417, + "Violation of MISRA C++:2008 Rule 14-5-3: A copy assignment operator shall be declared when there is a template assignment operator with a parameter that is a generic parameter:": 418, + "Violation of MISRA C++:2008 Rule 14-6-1: In a class template with a dependent base, any name that may be found in that dependent base shall be referred to using a qualified-id or this->.": 419, + "Violation of MISRA C++:2008 Rule 14-6-2: The function chosen by overload resolution shall resolve to a function declared previously in the translation unit.": 420, + "Violation of MISRA C++:2008 Rule 14-7-1: All class templates, function templates, class template member functions and class template static members shall be instantiated at least once.": 421, + "Violation of MISRA C++:2008 Rule 14-7-2: For any given template specialization, an explicit instantiation of the template with the template arguments used in the specializaion shall not render the program ill-formed": 422, + "Violation of MISRA C++:2008 Rule 14-7-3: All partial and explicit specializations for a template shall be declared in the same file as the declaration of their primary template.": 423, + "Violation of MISRA C++:2008 Rule 14-8-1: Overloaded function templates shall not be explicitly specialized.": 424, + "Violation of MISRA C++:2008 Rule 14-8-2: The viable function set for a function call should either contain no function specializaions, or only contain function specializations.": 425, + "Violation of MISRA C++:2008 Rule 15-0-1: Exceptions shall only be used for error handling.": 426, + "Violation of MISRA C++:2008 Rule 15-0-2: An exception object should not have pointer type.": 427, + "Violation of MISRA C++:2008 Rule 15-0-3: Control shall not be transferred into a try or catch block using a goto or a switch statement.": 428, + "Violation of MISRA C++:2008 Rule 15-1-1: The assignment-expression of a throw statement shall not itself cause an exception to be thrown.": 429, + "Violation of MISRA C++:2008 Rule 15-1-2: NULL shall not be thrown explicitly.": 430, + "Violation of MISRA C++:2008 Rule 15-1-3: An empty throw (throw;) shall only be used in the compound-statement of a catch handler.": 431, + "Violation of MISRA C++:2008 Rule 15-3-1: Exceptions shall be raised only after start-up and before termination of the program.": 432, + "Violation of MISRA C++:2008 Rule 15-3-2: There should be at least one exception handler to catch all otherwise unhandled exceptions.": 433, + "Violation of MISRA C++:2008 Rule 15-3-3: Handlers of a function-try-block implementation of a class constructor or destructor shall not reference non-static members from this class or its bases.": 434, + "Violation of MISRA C++:2008 Rule 15-3-4: Each exception explicitly thrown in the code shall have a handler of a compatible type in all calll paths that could lead to that point.": 435, + "Violation of MISRA C++:2008 Rule 15-3-5: A class type exception shall always be caught by reference.": 436, + "Violation of MISRA C++:2008 Rule 15-3-6: Where multiple handlers are provided in a single try-catch statement or, fuction-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class.": 437, + "Violation of MISRA C++:2008 Rule 15-3-7: Where multiple handlers are provided in a single try-catch statement or function-try-block, any elipsis (catch-all) handler shall occur last.": 438, + "Violation of MISRA C++:2008 Rule 15-4-1: If a function is declared with an exception-specification, then all declarations of the same function (in other translaion units) shall be declared with the same set of type -ids.": 439, + "Violation of MISRA C++:2008 Rule 15-5-1: A class destructor shall not exit with an exception.": 440, + "Violation of MISRA C++:2008 Rule 15-5-2: Where a function's declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s).": 441, + "Violation of MISRA C++:2008 Rule 15-5-3: The terminate() function shall not be called implicitly.": 442, + "Violation of MISRA C++:2008 Rule 16-0-1: #include directives in a file shall only be preceded by other preprocessor directives or comments.": 443, + "Violation of MISRA C++:2008 Rule 16-0-2: Macros shall only be #define’d or #undef'd in the global namespace.": 444, + "Violation of MISRA C++:2008 Rule 16-0-3: #undef shall not be used.": 445, + "Violation of MISRA C++:2008 Rule 16-0-4: Function-like macros shall not be defined.": 446, + "Violation of MISRA C++:2008 Rule 16-0-5: Arguments to a function-like macro shall not contain tokens that look like preprocessing directives.": 447, + "Violation of MISRA C++:2008 Rule 16-0-6: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##.": 448, + "Violation of MISRA C++:2008 Rule 16-0-7: Undefined macro identifiers shall not be used in #if or #elif preprocessor directives, except as operands to the defined operator.": 449, + "Violation of MISRA C++:2008 Rule 16-0-8: If the # token appears as the first token on a line, then it shall be immediately followed by a preprocessing token.": 450, + "Violation of MISRA C++:2008 Rule 16-1-1: The defined preprocessor operator shall only be used in one of the two standard forms.": 451, + "Violation of MISRA C++:2008 Rule 16-1-2: All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if or #ifdef directive to which they are related.": 452, + "Violation of MISRA C++:2008 Rule 16-2-1: The pre-processor shall only be used for file inclusion and include guards.": 453, + "Violation of MISRA C++:2008 Rule 16-2-2: C++ macros shall only be used for include guards, type qualifiers, or storage class specifiers.": 454, + "Violation of MISRA C++:2008 Rule 16-2-3: Include guards shall be provided.": 455, + "Violation of MISRA C++:2008 Rule 16-2-4: The ', \", /* or // characters shall not occur in a header file name.": 456, + "Violation of MISRA C++:2008 Rule 16-2-5: The \\ character should not occur in a header file name.": 457, + "Violation of MISRA C++:2008 Rule 16-2-6: The #include directive shall be followed by either a or \"filename\" sequence.": 458, + "Violation of MISRA C++:2008 Rule 16-3-1: There shall be at most one occurrence of the # or ## operators in a single macro definition.": 459, + "Violation of MISRA C++:2008 Rule 16-3-2: The # and ## operators should not be used.": 460, + "Violation of MISRA C++:2008 Rule 16-6-1: All uses of the #pragma directive shall be documented.": 461, + "Violation of MISRA C++:2008 Rule 17-0-1: Reserved identifiers, macros and functions in the standard library shall not be defined, redefined or undefined.": 462, + "Violation of MISRA C++:2008 Rule 17-0-2: The names of standard library macros and objects shall not be reused.": 463, + "Violation of MISRA C++:2008 Rule 17-0-3: The names of standard library functions shall not be overridden.": 464, + "Violation of MISRA C++:2008 Rule 17-0-4: All library code shall conform to MISRA C++.": 465, + "Violation of MISRA C++:2008 Rule 17-0-5: The setjmp macro and the longjmp function shall not be used.": 466, + "Violation of MISRA C++:2008 Rule 18-0-1: The C library shall not be used.": 467, + "Violation of MISRA C++:2008 Rule 18-0-2: The library functions atof, atoi and atol from library shall not be used.": 468, + "Violation of MISRA C++:2008 Rule 18-0-3: The library functions abort, exit, getenv and system from library shall not be used.": 469, + "Violation of MISRA C++:2008 Rule 18-0-4: The time handling functions of library shall not be used.": 470, + "Violation of MISRA C++:2008 Rule 18-0-5: The unbounded functions of library shall not be used.": 471, + "Violation of MISRA C++:2008 Rule 18-2-1: The macro offsetof shall not be used.": 472, + "Violation of MISRA C++:2008 Rule 18-4-1: Dynamic heap memory allocation shall not be used.": 473, + "Violation of MISRA C++:2008 Rule 18-7-1: The signal handling facilities of shall not be used.": 474, + "Violation of MISRA C++:2008 Rule 19-3-1: The error indicator errno shall not be used.": 475, + "Violation of MISRA C++:2008 Rule 2-10-1: Different identifiers shall be typographically unambiguous.": 276, + "Violation of MISRA C++:2008 Rule 2-10-2: Identifiers declared in an inner scope shall not hide an identifier declared in an outer scope.": 277, + "Violation of MISRA C++:2008 Rule 2-10-3: A typedef name (including qualification, if any) shall be a unique identifier.": 278, + "Violation of MISRA C++:2008 Rule 2-10-4: A class, union or enum name (including qualification, if any) shall be a unique identifier.": 279, + "Violation of MISRA C++:2008 Rule 2-10-5: The identifier name of a non-member object or function with static storage duration should not be reused.": 280, + "Violation of MISRA C++:2008 Rule 2-10-6: If an identifier refers to a type, it shall not also refer to an object or a function in the same scope.": 281, + "Violation of MISRA C++:2008 Rule 2-13-1: Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used.": 282, + "Violation of MISRA C++:2008 Rule 2-13-2: Octal constants (other than zero) and octal escape sequences (other than \"\\0\") shall not be used.": 283, + "Violation of MISRA C++:2008 Rule 2-13-3: A \"U\" suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.": 284, + "Violation of MISRA C++:2008 Rule 2-13-4: Literal suffixes shall be upper case.": 285, + "Violation of MISRA C++:2008 Rule 2-13-5: Narrow and wide string literals shall not be concatenated.": 286, + "Violation of MISRA C++:2008 Rule 2-2-1: The character set and the corresponding encoding shall be documented.": 270, + "Violation of MISRA C++:2008 Rule 2-3-1: Trigraphs shall not be used.": 271, + "Violation of MISRA C++:2008 Rule 2-5-1: Digraphs should not be used.": 272, + "Violation of MISRA C++:2008 Rule 2-7-1: The character sequence /* shall not be used within a C-style comment.": 273, + "Violation of MISRA C++:2008 Rule 2-7-2: Sections of code shall not be \"commented out\" using C-style comments.": 274, + "Violation of MISRA C++:2008 Rule 2-7-3: Sections of code should not be \"commented out\" using C++ comments.": 275, + "Violation of MISRA C++:2008 Rule 27-0-1: The stream input/output library shall not be used.": 476, + "Violation of MISRA C++:2008 Rule 3-1-1: It shall be possible to include any header file in multiple translation units without violaing the One Definition Rule.": 287, + "Violation of MISRA C++:2008 Rule 3-1-2: Functions shall not be declared at block scope.": 288, + "Violation of MISRA C++:2008 Rule 3-1-3: When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.": 289, + "Violation of MISRA C++:2008 Rule 3-2-1: All declarations of an object or function shall have compatible types.": 290, + "Violation of MISRA C++:2008 Rule 3-2-2: The One Definition Rule shall not be violated.": 291, + "Violation of MISRA C++:2008 Rule 3-2-3: A type, object or function that is used in multiple translation units shall be declared in one and only one file.": 292, + "Violation of MISRA C++:2008 Rule 3-2-4: An identifier with external linkage shall have exactly one definition.": 293, + "Violation of MISRA C++:2008 Rule 3-3-1: Objects or functions with external linkage shall be declared in a header file.": 294, + "Violation of MISRA C++:2008 Rule 3-3-2: If a function has internal linkage then all re-declarations shall include the static storage class specifier.": 295, + "Violation of MISRA C++:2008 Rule 3-4-1: An identfier declared to be an object or type shall be defined in a block that minimizes its visibility.": 296, + "Violation of MISRA C++:2008 Rule 3-9-1: The types used for an object, a function return type, or a function parameter shalll be token-for-token identical in all declarations and re-declarations.": 297, + "Violation of MISRA C++:2008 Rule 3-9-2: typedefs that indicate size and signedness should be used in place of the basic numerical types.": 298, + "Violation of MISRA C++:2008 Rule 3-9-3: The underlying bit representations of floating-point values shall not be used .": 299, + "Violation of MISRA C++:2008 Rule 4-10-1: NULL shall not be used as an integer value.": 303, + "Violation of MISRA C++:2008 Rule 4-10-2: Literal zero (0) shall not be used as the null-pointer-constant": 304, + "Violation of MISRA C++:2008 Rule 4-5-1: Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and !=, the unary & operator, and the conditional operator.": 300, + "Violation of MISRA C++:2008 Rule 4-5-2: Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=.": 301, + "Violation of MISRA C++:2008 Rule 4-5-3: Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator =, the equality operators == and !=, and the unary & operator.": 302, + "Violation of MISRA C++:2008 Rule 5-0-10: If the bitwise operators ~ and << are applied to an operand with an underlying type of unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand.": 314, + "Violation of MISRA C++:2008 Rule 5-0-11: The plain char type shall only be used for the storage and use of character values.": 315, + "Violation of MISRA C++:2008 Rule 5-0-12: signed char and unsigned char type shall only be used for the storage and use of numeric values.": 316, + "Violation of MISRA C++:2008 Rule 5-0-13: The condition of an if-statement and the condition of an iteration-statement shall have type bool.": 317, + "Violation of MISRA C++:2008 Rule 5-0-14: The first operand of a conditional-operator shall have type bool.": 318, + "Violation of MISRA C++:2008 Rule 5-0-15: Array indexing shall be the only form of pointer arithmetic.": 319, + "Violation of MISRA C++:2008 Rule 5-0-16: A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements of the same array.": 320, + "Violation of MISRA C++:2008 Rule 5-0-17: Subtraction between pointers shall only be applied to pointers that address elements of the same array.": 321, + "Violation of MISRA C++:2008 Rule 5-0-18: >, >=, <, <= shall not be applied to objects of pointer type, except where they point to the same array.": 322, + "Violation of MISRA C++:2008 Rule 5-0-19: The declaration of objects shall contain no more than two levels of pointer indirection.": 323, + "Violation of MISRA C++:2008 Rule 5-0-1: The value of an expression shall be the same under any order of evaluation that the standard permits.": 305, + "Violation of MISRA C++:2008 Rule 5-0-20: Non-constant operands to a binary bitwise operator shall have the same underlying type.": 324, + "Violation of MISRA C++:2008 Rule 5-0-21: Bitwise operators shall only be applied to operands of unsigned underlying type.": 325, + "Violation of MISRA C++:2008 Rule 5-0-2: Limited dependence should be placed on C++ operator precedence rules in expressions.": 306, + "Violation of MISRA C++:2008 Rule 5-0-3: A cvalue expression shall not be implicitly converted to a different underlying type.": 307, + "Violation of MISRA C++:2008 Rule 5-0-4: An implicit integral conversion shall not change the signedness of the underlying type.": 308, + "Violation of MISRA C++:2008 Rule 5-0-5: There shall be no implicit floating-integral conversions.": 309, + "Violation of MISRA C++:2008 Rule 5-0-6: An implicit integral or floating-point conversion shall not reduce the size of the underlying type.": 310, + "Violation of MISRA C++:2008 Rule 5-0-7: There shall be no explicit floating-integral conversions of a cvalue expression.": 311, + "Violation of MISRA C++:2008 Rule 5-0-8: An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression.": 312, + "Violation of MISRA C++:2008 Rule 5-0-9: An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression.": 313, + "Violation of MISRA C++:2008 Rule 5-14-1: The right hand operand of a logical && or || operator shall not contain side effects.": 343, + "Violation of MISRA C++:2008 Rule 5-17-1: The semantic equivalence between a binary operator and its asignment operator form shall be preserved.": 344, + "Violation of MISRA C++:2008 Rule 5-18-1: The comma operator shall not be used.": 345, + "Violation of MISRA C++:2008 Rule 5-19-1: Evaluation of constant unsigned integer expressions should not lead to wrap-around.": 346, + "Violation of MISRA C++:2008 Rule 5-2-10: The increment (++) and decrement (--) operators should not be mixed with other operators in an exression.": 335, + "Violation of MISRA C++:2008 Rule 5-2-11: The comma operator, && operator and the || operator shall not be overloaded.": 336, + "Violation of MISRA C++:2008 Rule 5-2-12: An identifier with array type passed as a function argument shall not decay to a pointer.": 337, + "Violation of MISRA C++:2008 Rule 5-2-1: Each operand of a logical && or | | shall be a postfix-expression.": 326, + "Violation of MISRA C++:2008 Rule 5-2-2: A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic_cast.": 327, + "Violation of MISRA C++:2008 Rule 5-2-3: Casts from a base class to a derived class should not be performed on polymorphic types.": 328, + "Violation of MISRA C++:2008 Rule 5-2-4: C-style casts (other than void casts) and functional notation casts (other than explicit constructor call) shall not be used.": 329, + "Violation of MISRA C++:2008 Rule 5-2-5: A cast shall not remove any const or volatile qualification from the type of a pointer or reference.": 330, + "Violation of MISRA C++:2008 Rule 5-2-6: A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type.": 331, + "Violation of MISRA C++:2008 Rule 5-2-7: An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly.": 332, + "Violation of MISRA C++:2008 Rule 5-2-8: An object with integer type or pointer to void type shall not be converted to an object with poiner type.": 333, + "Violation of MISRA C++:2008 Rule 5-2-9: A cast should not convert a pointer type to an integral type.": 334, + "Violation of MISRA C++:2008 Rule 5-3-1: Each operand of the ! operator, the logical && or the logical operators shall have type bool.": 338, + "Violation of MISRA C++:2008 Rule 5-3-2: The unary minus operator shall not be applied to an expression whose underlying type is unsigned.": 339, + "Violation of MISRA C++:2008 Rule 5-3-3: The unary & operator shall not be overloaded.": 340, + "Violation of MISRA C++:2008 Rule 5-3-4: Evaluation of the operand to the sizeof operator shall not contain side effects.": 341, + "Violation of MISRA C++:2008 Rule 5-8-1: The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.": 342, + "Violation of MISRA C++:2008 Rule 6-2-1: Assignment operators shall not be used in sub-expressions.": 347, + "Violation of MISRA C++:2008 Rule 6-2-2: Floating-point expressions shall not be directly or indirectly tested for equality or inequality.": 348, + "Violation of MISRA C++:2008 Rule 6-2-3: Before preprocessing, a null statement shall only occur on a line by itself; it may be followed by a comment, provided that the first character following the null statement is a white-space character.": 349, + "Violation of MISRA C++:2008 Rule 6-3-1: The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement.": 350, + "Violation of MISRA C++:2008 Rule 6-4-1: An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement.": 351, + "Violation of MISRA C++:2008 Rule 6-4-2: All if ... else if constructs shall be terminated with an else clause.": 352, + "Violation of MISRA C++:2008 Rule 6-4-3: A switch statement shall be a well-formed switch statement.": 353, + "Violation of MISRA C++:2008 Rule 6-4-4: A switch-label shall only be used when the most closely-enclosing compound statement is the body of a switch statement.": 354, + "Violation of MISRA C++:2008 Rule 6-4-5: An unconditional throw or break statement shall terminate every non-empty switch-clause.": 355, + "Violation of MISRA C++:2008 Rule 6-4-6: The final clause of a switch statement shall be the default-clause.": 356, + "Violation of MISRA C++:2008 Rule 6-4-7: The condition of a switch statement shall not have bool type.": 357, + "Violation of MISRA C++:2008 Rule 6-4-8: Every switch statement shall have at least one case-clause,": 358, + "Violation of MISRA C++:2008 Rule 6-5-1: A for loop shall contain a single loop-counter which shall not have floating type.": 359, + "Violation of MISRA C++:2008 Rule 6-5-2: If loop-counter is not modified by -- or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=.": 360, + "Violation of MISRA C++:2008 Rule 6-5-3: The loop-counter shall not be modified within statement.": 361, + "Violation of MISRA C++:2008 Rule 6-5-4: The loop-counter shall be modified by one of: --, ++,-=n, or +=n; where n remains constant for the duration of the loop.": 362, + "Violation of MISRA C++:2008 Rule 6-5-5: A loop-control-variable other than the loop-counter shall not be modified within condition or expression.": 363, + "Violation of MISRA C++:2008 Rule 6-5-6: A loop-control-variable other than the loop-counter which is modified in statement shall have type bool.": 364, + "Violation of MISRA C++:2008 Rule 6-6-1: Any label referenced by a goto statement shall be declared in the same block, or in a block enclosing the goto statement.": 365, + "Violation of MISRA C++:2008 Rule 6-6-2: The goto statement shall jump to a label declared later in the same function body.": 366, + "Violation of MISRA C++:2008 Rule 6-6-3: The continue statement shall only be used within a well-formed for loop.": 367, + "Violation of MISRA C++:2008 Rule 6-6-4: For any iteration statement there shall be no more than one break or goto statement used for loop termination.": 368, + "Violation of MISRA C++:2008 Rule 6-6-5: A function shall have a single point of exit at the end of the function.": 369, + "Violation of MISRA C++:2008 Rule 7-1-1: A variable which is not modified shall be const qualified.": 370, + "Violation of MISRA C++:2008 Rule 7-1-2: A pointer or reference parameter in a function shall be declared as pointer to const or reference to const if the corresponding object is not modified.": 371, + "Violation of MISRA C++:2008 Rule 7-2-1: An expression with enum underlying type shall only have values corresponding to the enumerators of the enumeration.": 372, + "Violation of MISRA C++:2008 Rule 7-3-1: The global namespace shall only contain main, namespace declarations and extern \"C\" declarations.": 373, + "Violation of MISRA C++:2008 Rule 7-3-2: The identifier main shall not be used for a function other than the global function main.": 374, + "Violation of MISRA C++:2008 Rule 7-3-3: There shall be no unnamed namespaces in header files.": 375, + "Violation of MISRA C++:2008 Rule 7-3-4: using-directives shall not be used.": 376, + "Violation of MISRA C++:2008 Rule 7-3-5: Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that idenifier.": 377, + "Violation of MISRA C++:2008 Rule 7-3-6: using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files.": 378, + "Violation of MISRA C++:2008 Rule 7-4-1: All usage of assembler shall be documented.": 379, + "Violation of MISRA C++:2008 Rule 7-4-2: Assembler instructions shall only be introduced using the asm declaration.": 380, + "Violation of MISRA C++:2008 Rule 7-4-3: Assembly language shall be encapsulated and isolated.": 381, + "Violation of MISRA C++:2008 Rule 7-5-1: A function shall not return a reference or a pointer to an automatic variable (including parameters) defined within the function.": 382, + "Violation of MISRA C++:2008 Rule 7-5-2: The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist.": 383, + "Violation of MISRA C++:2008 Rule 7-5-3: A function shall not return a reference or a pointer to a parameter that is passed by reference or const reference.": 384, + "Violation of MISRA C++:2008 Rule 7-5-4: Functions should not call themselves, either directly or indirectly.": 385, + "Violation of MISRA C++:2008 Rule 8-0-1: An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or member-declarator respectively.": 386, + "Violation of MISRA C++:2008 Rule 8-3-1: Parameters in an overriding virtual function shall either use the same default arguments as the function they ovrride, or else shall not specify any default arguments.": 387, + "Violation of MISRA C++:2008 Rule 8-4-1: Functions shall not be defined using the ellipsis notation.": 388, + "Violation of MISRA C++:2008 Rule 8-4-2: The identifiers used for the parameters in a re-declaration of a function shall be identical to those in the declaration.": 389, + "Violation of MISRA C++:2008 Rule 8-4-3: All exit paths from a function with non-void return type shall have an explicit return statement with an expression.": 390, + "Violation of MISRA C++:2008 Rule 8-4-4: A function identifier shall either be used to call the function or it shall be preceded by &.": 391, + "Violation of MISRA C++:2008 Rule 8-5-1: All variables shall have a defined value before they are used.": 392, + "Violation of MISRA C++:2008 Rule 8-5-2: Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures.": 393, + "Violation of MISRA C++:2008 Rule 8-5-3: In an enumerator list, the = construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized.": 394, + "Violation of MISRA C++:2008 Rule 9-3-1: const member functions shall not return non-const pointers or references to class-data.": 395, + "Violation of MISRA C++:2008 Rule 9-3-2: Member functions shall not return non-const handles to class-data.": 396, + "Violation of MISRA C++:2008 Rule 9-3-3: If a member function can be made static then it shall be made static, otherwise if it can be made const then it shall be made const.": 397, + "Violation of MISRA C++:2008 Rule 9-5-1: Unions shall not be used.": 398, + "Violation of MISRA C++:2008 Rule 9-6-1: When the absolute positioning of bits representing a bit-field is required, then the behaviour and packing of bit-fields shall be documented.": 399, + "Violation of MISRA C++:2008 Rule 9-6-2: Bit-fields shall be either bool type or an explicitly unsigned or signed integral type.": 400, + "Violation of MISRA C++:2008 Rule 9-6-3: Bit-fields shall not have enum type.": 401, + "Violation of MISRA C++:2008 Rule 9-6-4: Named bit-fields with signed integer type shall have a length of more than one bit.": 402, + "Writing CTU information completed [%s]": 493, + "[C0101][misra-c2012-20.14]: violation of misra-c2012-20.14": 197, + "[C0102][misra-c2012-20.13]: violation of misra-c2012-20.13": 196, + "[C0103][misra-c2012-20.12]: violation of misra-c2012-20.12": 195, + "[C0104][misra-c2012-20.11]: violation of misra-c2012-20.11": 194, + "[C0105][misra-c2012-20.10]: violation of misra-c2012-20.10": 193, + "[C0106][misra-c2012-20.9]: violation of misra-c2012-20.9": 192, + "[C0107][misra-c2012-20.8]: violation of misra-c2012-20.8": 191, + "[C0108][misra-c2012-20.7]: violation of misra-c2012-20.7": 190, + "[C0109][misra-c2012-20.6]: violation of misra-c2012-20.6": 189, + "[C0110][misra-c2012-20.5]: violation of misra-c2012-20.5": 188, + "[C0111][misra-c2012-20.4]: violation of misra-c2012-20.4": 187, + "[C0112][misra-c2012-20.3]: violation of misra-c2012-20.3": 186, + "[C0113][misra-c2012-20.2]: violation of misra-c2012-20.2": 185, + "[C0114][misra-c2012-20.1]: violation of misra-c2012-20.1": 184, + "[C0201][misra-c2012-22.10]: violation of misra-c2012-22.10\n%s": 234, + "[C0202][misra-c2012-22.9]: violation of misra-c2012-22.9\n%s": 233, + "[C0203][misra-c2012-22.8]: violation of misra-c2012-22.8\n%s": 232, + "[C0204][misra-c2012-22.7]: violation of misra-c2012-22.7\n%s": 231, + "[C0205][misra-c2012-22.6]: violation of misra-c2012-22.6\n%s": 230, + "[C0206][misra-c2012-22.5]: violation of misra-c2012-22.5\n%s": 229, + "[C0207][misra-c2012-22.4]: violation of misra-c2012-22.4\n%s": 228, + "[C0208][misra-c2012-22.3]: violation of misra-c2012-22.3\n%s": 227, + "[C0209][misra-c2012-22.2]: violation of misra-c2012-22.2\n%s": 226, + "[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n%s": 225, + "[C0301][misra-c2012-19.2]: violation of misra-c2012-19.2": 183, + "[C0302][misra-c2012-19.1]: violation of misra-c2012-19.1, assign or copy is overlapped\n": 181, + "[C0302][misra-c2012-19.1]: violation of misra-c2012-19.1, assign or copy is overlapped\n%s": 182, + "[C0401][misra-c2012-21.20]: violation of misra-c2012-21.20\n%s": 220, + "[C0402][misra-c2012-21.19]: the return value of function is assigned to non-const qualified type\nsource pointer object type: %s\ndestination object type: %s\nLocation: %s": 218, + "[C0402][misra-c2012-21.19]: violation of misra-c2012-21.19\n%s": 219, + "[C0403][misra-c2012-21.18]: size_t value invalid as function argument.\nsource pointer object type: %s\ndestination object type: %s\nLocation: %s": 216, + "[C0403][misra-c2012-21.18]: violation of misra-c2012-21.18\n%s": 217, + "[C0404][misra-c2012-21.17]: The cstring function call may cause read or write out of bound.\n%s": 215, + "[C0405][misra-c2012-21.16]: violation of misra-c2012-21.16": 214, + "[C0406][misra-c2012-21.15]: violation of misra-c2012-21.15": 213, + "[C0407][misra-c2012-21.14]: violation of misra-c2012-21.14\n%s": 212, + "[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n%s": 211, + "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12": 209, + "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3": 210, + "[C0410][misra-c2012-21.11]: violation of misra-c2012-21.11": 208, + "[C0411][misra-c2012-21.10]: violation of misra-c2012-21.10": 207, + "[C0412][misra-c2012-21.9]: violation of misra-c2012-21.9": 206, + "[C0413][misra-c2012-21.8]: violation of misra-c2012-21.8": 205, + "[C0414][misra-c2012-21.7]: violation of misra-c2012-21.7": 204, + "[C0415][misra-c2012-21.6]: violation of misra-c2012-21.6": 203, + "[C0416][misra-c2012-21.5]: violation of misra-c2012-21.5": 202, + "[C0417][misra-c2012-21.4]: violation of misra-c2012-21.4": 201, + "[C0418][misra-c2012-21.3]: violation of misra-c2012-21.3": 200, + "[C0419][misra-c2012-21.2]: violation of misra-c2012-21.2": 199, + "[C0420][misra-c2012-21.1]: violation of misra-c2012-21.1": 198, + "[C0421][misra-c2012-21.21]: violation of misra-c2012-21.21": 221, + "[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n%s": 222, + "[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23": 223, + "[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24": 224, + "[C0501][misra-c2012-8.14]: violation of misra-c2012-8.14": 85, + "[C0503][misra-c2012-8.12]: violation of misra-c2012-8.12": 84, + "[C0504][misra-c2012-8.11]: violation of misra-c2012-8.11": 83, + "[C0505][misra-c2012-8.10]: violation of misra-c2012-8.10": 82, + "[C0506][misra-c2012-8.9]: violation of misra-c2012-8.9": 81, + "[C0507][misra-c2012-8.8]: violation of misra-c2012-8.8": 80, + "[C0508][misra-c2012-8.7]: violation of misra-c2012-8.7\nExtern function or variable is only called at one translation unit\nfunction name: %s\nused location: %s\ndeclared location: %s": 79, + "[C0509][misra-c2012-8.6]: error duplicated definition\nduplicated variable name: %s\nfirst definition location: %s\nduplicated definition location: %s": 78, + "[C0510][misra-c2012-8.5]: External function shall be declared in one header file.\nName: %s\nLocation: %s": 75, + "[C0510][misra-c2012-8.5]: External function shall be declared once in one and only one file.\nName: %s\nLocation: %s\nOther Location: %s": 77, + "[C0510][misra-c2012-8.5]: External object shall be declared in one header file.\n, Name: %s\n, Location: %s": 74, + "[C0510][misra-c2012-8.5]: External object shall be declared once in one and only one file.\nName: %s\nLocation: %s\nOther Location: %s": 76, + "[C0511][misra-c2012-8.4]: violation of misra-c2012-8.4\nFunction declaration and definition type do not match\nfunction name: %s\ndefinition location: %s": 73, + "[C0511][misra-c2012-8.4]: violation of misra-c2012-8.4\nMissing function declaration\nfunction name: %s\nlocation: %s": 71, + "[C0511][misra-c2012-8.4]: violation of misra-c2012-8.4\nMissing variable declaration\nvariable name: %s\nlocation: %s": 72, + "[C0512][misra-c2012-8.3]: violation of misra-c2012-8.3\nName: %s": 69, + "[C0512][misra-c2012-8.3]: violation of misra-c2012-8.3\nName: %s\nLocation: %s\nOther location: %s": 70, + "[C0513][misra-c2012-8.2]: function types shall be in prototype form with named parameters\nK&R style is fobidden.\nfunction name: %s": 67, + "[C0513][misra-c2012-8.2]: function types shall be in prototype form with named parameters\nMissing 'void'.\nfunction name: %s": 68, + "[C0513][misra-c2012-8.2]: function types shall be in prototype form with named parameters\nfunction pointer with unnamed parameter.": 66, + "[C0513][misra-c2012-8.2]: function types shall be in prototype form with named parameters\nunnamed parameter.\nfunction name: %s": 65, + "[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n%s": 64, + "[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n%s": 86, + "[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16": 87, + "[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17": 88, + "[C0601][misra-c2012-12.5]: violation of misra-c2012-12.5": 121, + "[C0602][misra-c2012-12.4]: violation of misra-c2012-12.4": 120, + "[C0603][misra-c2012-12.3]: violation of misra-comma operator should not be used": 119, + "[C0604][misra-c2012-12.2]: violation of misra-c2012-12.2\n%s": 118, + "[C0605][misra-c2012-12.1]: violation of misra-c2012-12.1": 117, + "[C0701][misra-c2012-6.2]: violation of misra-c2012-6.2": 55, + "[C0702][misra-c2012-6.1]: violation of misra-c2012-6.1": 54, + "[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3": 56, + "[C0801][misra-c2012-10.8]: violation of misra-c2012-10.8": 101, + "[C0802][misra-c2012-10.7]: violation of misra-c2012-10.7": 100, + "[C0803][misra-c2012-10.6]: violation of misra-c2012-10.6": 99, + "[C0804][misra-c2012-10.5]: violation of misra-c2012-10.5": 98, + "[C0805][misra-c2012-10.4]: violation of misra-c2012-10.4": 97, + "[C0806][misra-c2012-10.3]: violation of misra-c2012-10.3": 96, + "[C0807][misra-c2012-10.2]: violation of misra-c2012-10.2": 95, + "[C0808][misra-c2012-10.1]: violation of misra-c2012-10.1\n%s": 94, + "[C0901][misra-c2012-7.4]: Assignment violation of misra-c2012-7.4\ntry to assign string literal to object with improper type\nLocation: %s": 61, + "[C0901][misra-c2012-7.4]: violation of misra-c2012-7.4": 60, + "[C0901][misra-c2012-7.4]: violation of misra-c2012-7.4\n%s": 62, + "[C0902][misra-c2012-7.3]: violation of misra-c2012-7.3": 59, + "[C0903][misra-c2012-7.2]: violation of misra-c2012-7.2": 58, + "[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1": 57, + "[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n%s": 63, + "[C1001][misra-c2012-4.2]: violation of misra-c2012-4.2": 42, + "[C1002][misra-c2012-4.1]: violation of misra-c2012-4.1": 41, + "[C1101][misra-c2012-5.9]: %s with internal linkage shall be unique\nName: %s\nLocation: %s\nOther location: %s": 53, + "[C1102][misra-c2012-5.8]: %s with external linkage shall be unique\nName: %s\nLocation: %s\nOther location: %s": 52, + "[C1103][misra-c2012-5.7]: error tag name is not unique\nDuplicated tag name: %s\nFirst identifier location: %s\nDuplicated identifier location: %s": 50, + "[C1103][misra-c2012-5.7]: error tag name is not unique\nInvalid declaration: at %s": 51, + "[C1104][misra-c2012-5.6]: violation of misra-c2012-5.6\nTypedef: %s\nFirst typedef location: %s\nDuplicated typedef location: %s": 49, + "[C1105][misra-c2012-5.5]: violation of misra-c2012-5.5": 48, + "[C1106][misra-c2012-5.4]: violation of misra-c2012-5.4": 47, + "[C1107][misra-c2012-5.3]: violation of misra-c2012-5.3": 46, + "[C1108][misra-c2012-5.2]: violation of misra-c2012-5.2": 45, + "[C1109][misra-c2012-5.1]: violation of misra-c2012-5.1\n%s: %s\nFirst identifier location: %s\nDuplicated identifier '%s' location: %s": 44, + "[C1109][misra-c2012-5.1]: violation of misra-contain non-ASCII characters\n%s: %s": 43, + "[C1201][misra-c2012-9.5]: violation of misra-c2012-9.5": 93, + "[C1202][misra-c2012-9.4]: violation of misra-c2012-9.4": 92, + "[C1203][misra-c2012-9.3]: violation of misra-c2012-9.3": 91, + "[C1204][misra-c2012-9.2]: violation of misra-c2012-9.2": 90, + "[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n%s": 89, + "[C1301][misra-c2012-18.8]: violation of misra-c2012-18.8": 180, + "[C1302][misra-c2012-18.7]: violation of misra-c2012-18.7": 179, + "[C1303][misra-c2012-18.6]: violation of misra-c2012-18.6\n%s": 178, + "[C1304][misra-c2012-18.5]: violation of misra-c2012-18.5": 177, + "[C1305][misra-c2012-18.4]: violation of misra-c2012-18.4": 176, + "[C1306][misra-c2012-18.3]: violation of misra-c2012-18.3\n%s": 175, + "[C1307][misra-c2012-18.2]: violation of misra-c2012-18.2\n%s": 174, + "[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n%s": 173, + "[C1401][misra-c2012-11.9]: violation of misra-c2012-11.9": 116, + "[C1402][misra-c2012-11.8]: violation of misra-conversions violation of misra-c2012-11.8\nobject name: %s\nsource pointer object type: %s\ndestination pointer object type: %s": 115, + "[C1403][misra-c2012-11.7]: violation of misra-conversions violation of misra-c2012-11.7\n%s": 114, + "[C1403][misra-c2012-11.7]: violation of misra-conversions violation of misra-c2012-11.7\nobject name: %s\nsource type: %s\ndestination type: %s\nLocation: %s": 113, + "[C1404][misra-c2012-11.6]: violation of misra-conversions violation of misra-c2012-11.6\n%s": 112, + "[C1404][misra-c2012-11.6]: violation of misra-conversions violation of misra-c2012-11.6\nobject name: %s\nsource object type: %s\ndestination object type: %s\nLocation: %s": 111, + "[C1405][misra-c2012-11.5]: violation of misra-c2012-11.5": 109, + "[C1405][misra-c2012-11.5]: violation of misra-conversions violation of misra-c2012-11.5\nobject name: %s\nsource pointer object type: %s\ndestination pointer object type: %s\nLocation: %s": 110, + "[C1406][misra-c2012-11.4]: violation of misra-c2012-11.4": 106, + "[C1406][misra-c2012-11.4]: violation of misra-conversions violation of misra-c2012-11.4\nobject name: %s\nsource pointer object type: %s\ndestination type: %s\nLocation: %s": 108, + "[C1406][misra-c2012-11.4]: violation of misra-conversions violation of misra-c2012-11.4\nobject name: %s\nsource type: %s\ndestination pointer object type: %s\nLocation: %s": 107, + "[C1407][misra-c2012-11.3]: violation of misra-conversions violation of misra-c2012-11.3\nobject name: %s\nsource pointer object type: %s\ndestination pointer object type: %s\nLocation: %s": 105, + "[C1408][misra-c2012-11.2]: violation of misra-conversions violation of misra-c2012-11.2\nobject name: %s\nsource pointer object type: %s\ndestination pointer object type: %s\nLocation: %s": 104, + "[C1409][misra-c2012-11.1]: violation of misra-conversions violation of misra-c2012-11.1\n%s": 103, + "[C1409][misra-c2012-11.1]: violation of misra-conversions violation of misra-c2012-11.1\nobject name: %s\nsource type: %s\ndestination type: %s\nLocation: %s": 102, + "[C1501][misra-c2012-17.8]: parameters should not be modified": 168, + "[C1501][misra-c2012-17.8]: violation of misra-c2012-17.8": 167, + "[C1502][misra-c2012-17.7]: violation of misra-c2012-17.7": 166, + "[C1503][misra-c2012-17.6]: violation of misra-c2012-17.6": 165, + "[C1504][misra-c2012-17.5]: argument with improper array size used for parameter with array type": 163, + "[C1504][misra-c2012-17.5]: null pointer argument used for parameter with array type": 162, + "[C1504][misra-c2012-17.5]: violation of misra-c2012-17.5\n%s": 164, + "[C1505][misra-c2012-17.4]: violation of misra-c2012-17.4": 160, + "[C1505][misra-c2012-17.4]: violation of rule_17_4\n%s": 161, + "[C1506][misra-c2012-17.3]: implicit declaration of function\n%s": 159, + "[C1507][misra-c2012-17.2]: violation of misra-c2012-17.2\n%s": 158, + "[C1507][misra-c2012-17.2]: violation of misra-c2012-17.2\nfound a recursive chain %s": 157, + "[C1508][misra-c2012-17.1]: violation of misra-c2012-17.1": 156, + "[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n%s": 169, + "[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10": 170, + "[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12": 171, + "[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n%s": 172, + "[C1601][misra-c2012-13.6]: violation of misra-c2012-13.6": 130, + "[C1602][misra-c2012-13.5]: Right hand operand may have persistent side effect, Location: %s": 128, + "[C1602][misra-c2012-13.5]: violation of misra-c2012-13.5\nFunction %s may have persistent side effect": 129, + "[C1603][misra-c2012-13.4]: Result of assignment operator should not be used": 126, + "[C1603][misra-c2012-13.4]: violation of rule_13_4\n%s": 127, + "[C1604][misra-c2012-13.3]: expression has more than one side effects": 125, + "[C1605][misra-c2012-13.2]: multiple related functions should not be called in the same expression": 123, + "[C1605][misra-c2012-13.2]: violation of misra-c2012-13.2\n%s": 124, + "[C1606][misra-c2012-13.1]: Init list has volatile referenced member": 122, + "[C1701][misra-c2012-14.4]: violation of misra-c2012-14.4": 141, + "[C1702][misra-c2012-14.3]: violation of misra-c2012-14.3": 139, + "[C1702][misra-c2012-14.3]: violation of misra-c2012-14.3\n%s": 140, + "[C1703][misra-c2012-14.2]: %s clause in for loop may have persistent side effect": 133, + "[C1703][misra-c2012-14.2]: %s clause should set and only set the value of loop counter": 137, + "[C1703][misra-c2012-14.2]: %s clause uses reference '%s' modified in loop body": 136, + "[C1703][misra-c2012-14.2]: loop counter '%s' is modified in loop body": 135, + "[C1703][misra-c2012-14.2]: loop counter '%s' is not used in %s clause": 134, + "[C1703][misra-c2012-14.2]: second clause uses non-boolean control flag": 138, + "[C1704][misra-c2012-14.1]: loop counter cannot be float": 131, + "[C1704][misra-c2012-14.1]: violation of misra-c2012-14.1\n%s": 132, + "[C1801][misra-c2012-15.7]: violation of misra-c2012-15.7": 148, + "[C1802][misra-c2012-15.6]: violation of misra-c2012-15.6": 147, + "[C1803][misra-c2012-15.5]: violation of misra-c2012-15.5": 146, + "[C1804][misra-c2012-15.4]: violation of misra-c2012-15.4": 145, + "[C1805][misra-c2012-15.3]: violation of misra-c2012-15.3": 144, + "[C1806][misra-c2012-15.2]: violation of misra-c2012-15.2": 143, + "[C1807][misra-c2012-15.1]: violation of misra-c2012-15.1": 142, + "[C1901][misra-c2012-16.7]: violation of misra-c2012-16.7": 155, + "[C1902][misra-c2012-16.6]: violation of misra-c2012-16.6": 154, + "[C1903][misra-c2012-16.5]: violation of misra-c2012-16.5": 153, + "[C1904][misra-c2012-16.4]: violation of misra-c2012-16.4": 152, + "[C1905][misra-c2012-16.3]: violation of misra-c2012-16.3": 151, + "[C1906][misra-c2012-16.2]: violation of misra-c2012-16.2": 150, + "[C1907][misra-c2012-16.1]: violation of misra-c2012-16.1": 149, + "[C2001][misra-c2012-2.7]: violation of misra-c2012-2.7": 38, + "[C2002][misra-c2012-2.6]: violation of misra-c2012-2.6": 37, + "[C2003][misra-c2012-2.5]: violation of misra-c2012-2.5": 36, + "[C2004][misra-c2012-2.4]: violation of misra-c2012-2.4": 35, + "[C2005][misra-c2012-2.3]: violation of misra-c2012-2.3\nunused typedef name: %s": 34, + "[C2006][misra-c2012-2.2]: A call to empty function is dead code": 32, + "[C2006][misra-c2012-2.2]: violation of misra-c2012-2.2\n%s": 33, + "[C2007][misra-c2012-2.1]: violation of misra-c2012-2.1\n%s": 31, + "[C2101][misra-c2012-3.2]: violation of misra-c2012-3.2": 40, + "[C2102][misra-c2012-3.1]: violation of misra-c2012-3.1": 39, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n%s: %s\nFirst identifier location: %s\nDuplicated identifier '%s' location: %s": 18, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID%s%s%s": 26, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT%s%s%s": 15, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID%s%s%s": 17, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG%s%s%s": 11, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM%s%s%s": 10, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR%s%s%s": 24, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG%s%s%s": 21, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID%s%s%s": 19, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM%s%s%s": 20, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL%s%s%s": 28, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK%s%s%s": 22, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU%s%s%s": 25, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL%s%s%s": 27, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR%s%s%s": 13, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE%s%s%s": 23, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD%s%s%s": 12, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR%s%s%s": 16, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER%s%s%s": 9, + "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE%s%s%s": 14, + "[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n%s": 29, + "[C2204][misra-c2012-1.4]: violation of misra-c2012-1.4": 30, + "[C2306][misra-c2012-dir-4.3]: assembly code should be encapsulated": 241, + "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated": 240, + "[C2310][misra-c2012-dir-4.7]: error should be tested": 242, + "[C2313][misra-c2012-dir-4.10]: %s and %s has same file identifier": 244, + "[C2313][misra-c2012-dir-4.10]: %s has no precaution": 243, + "[C2314][misra-c2012-dir-4.11]: violation of misra-c2012-dir-4.11\n%s": 245, + "[C2315][misra-c2012-dir-4.12]: dynamic allocation should not be used": 246, + "[C2317][misra-c2012-dir-4.14]: violation of misra-c2012-dir-4.14\n%s": 247, + "[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1": 235, + "[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2": 236, + "[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3": 237, + "[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n%s": 238, + "[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5": 239, + "[C7966][NAIVESYSTEMS_C7966]: violation of NAIVESYSTEMS_C7966\n%s": 248, +} + +var enIndex = []uint32{ // 495 elements + // Entry 0 - 1F + 0x00000000, 0x00000027, 0x0000004a, 0x0000006a, + 0x00000096, 0x000000b5, 0x000000d1, 0x000000f9, + 0x00000121, 0x0000015a, 0x0000026a, 0x00000387, + 0x0000049d, 0x000005ec, 0x0000072c, 0x0000084a, + 0x00000973, 0x00000a8d, 0x00000bb5, 0x00000ccc, + 0x00000e16, 0x00000f34, 0x00001051, 0x00001165, + 0x00001283, 0x000013c7, 0x000014ea, 0x00001618, + 0x00001758, 0x000018db, 0x0000196c, 0x000019d7, + // Entry 20 - 3F + 0x00001a49, 0x00001ace, 0x00001b2f, 0x00001bbc, + 0x00001c2f, 0x00001ca4, 0x00001d1a, 0x00001d8a, + 0x00001e0d, 0x00001e7a, 0x00001ef3, 0x00001f4e, + 0x00001fe1, 0x00002090, 0x00002116, 0x000021b5, + 0x00002217, 0x00002284, 0x00002328, 0x000023c8, + 0x0000244d, 0x00002518, 0x000025e4, 0x0000265d, + 0x000026d5, 0x0000274c, 0x000027ac, 0x00002851, + 0x000028d1, 0x00002981, 0x00002a45, 0x00002afc, + // Entry 40 - 5F + 0x00002b8a, 0x00002bf3, 0x00002ca1, 0x00002d1f, + 0x00002dcd, 0x00002e70, 0x00002f24, 0x00002ffd, + 0x000030e8, 0x000031d3, 0x000032c4, 0x0000338e, + 0x0000345a, 0x0000351b, 0x000035de, 0x000036b2, + 0x000037ae, 0x00003865, 0x00003902, 0x00003985, + 0x00003a1e, 0x00003ac3, 0x00003b31, 0x00003be0, + 0x00003c6f, 0x00003cff, 0x00003da4, 0x00003e28, + 0x00003e90, 0x00003f0e, 0x00003fc4, 0x00004043, + // Entry 60 - 7F + 0x000040f6, 0x000041bd, 0x0000427e, 0x0000430f, + 0x000043b0, 0x000044a3, 0x0000455a, 0x0000461b, + 0x000046b8, 0x00004797, 0x00004880, 0x00004915, + 0x000049e5, 0x00004ab0, 0x00004b41, 0x00004c08, + 0x00004cc0, 0x00004d54, 0x00004e19, 0x00004eba, + 0x00004f94, 0x00005025, 0x000050ac, 0x0000518b, + 0x000051f1, 0x00005284, 0x0000532c, 0x000053a8, + 0x0000545b, 0x00005515, 0x00005609, 0x00005681, + // Entry 80 - 9F + 0x00005700, 0x000057d8, 0x000058b0, 0x00005955, + 0x000059cd, 0x00005a4c, 0x00005aee, 0x00005b87, + 0x00005c1f, 0x00005cc9, 0x00005d70, 0x00005e04, + 0x00005e73, 0x00005ee9, 0x00005fb4, 0x0000601a, + 0x000060a7, 0x00006162, 0x00006205, 0x0000627e, + 0x00006318, 0x000063a1, 0x0000640c, 0x000064c3, + 0x00006548, 0x000065ba, 0x0000665a, 0x000066d8, + 0x00006754, 0x000067c1, 0x00006865, 0x000068ef, + // Entry A0 - BF + 0x00006962, 0x00006a16, 0x00006ad1, 0x00006bd2, + 0x00006ce0, 0x00006da6, 0x00006e41, 0x00006ecc, + 0x00006f38, 0x00006fa4, 0x00007041, 0x000070d7, + 0x00007185, 0x000071f9, 0x000072bc, 0x0000736a, + 0x00007437, 0x000074cc, 0x00007553, 0x00007629, + 0x00007696, 0x00007704, 0x00007766, 0x000077f0, + 0x00007855, 0x000078e8, 0x0000798c, 0x00007a23, + 0x00007aa0, 0x00007afa, 0x00007b92, 0x00007c30, + // Entry C0 - DF + 0x00007cce, 0x00007d8f, 0x00007e08, 0x00007eb2, + 0x00007f9d, 0x00008026, 0x000080fc, 0x00008191, + 0x00008214, 0x000082a5, 0x0000831b, 0x00008391, + 0x0000840f, 0x000084b3, 0x0000853e, 0x000085cf, + 0x0000867b, 0x000086f3, 0x00008774, 0x000087ea, + 0x0000889e, 0x00008941, 0x00008a21, 0x00008b39, + 0x00008c1c, 0x00008cf9, 0x00008d9b, 0x00008ec5, + 0x00008fb4, 0x000090c4, 0x0000914b, 0x00009205, + // Entry E0 - FF + 0x000092c0, 0x00009348, 0x000093f6, 0x0000949f, + 0x00009546, 0x000095df, 0x0000965b, 0x00009701, + 0x000097ca, 0x00009866, 0x00009905, 0x000099b8, + 0x00009a31, 0x00009aee, 0x00009b76, 0x00009bf2, + 0x00009c7c, 0x00009cf2, 0x00009d68, 0x00009dfe, + 0x00009ec6, 0x00009fa4, 0x0000a032, 0x0000a0a1, + 0x0000a132, 0x0000a1a3, 0x0000a1f9, 0x0000a24f, + 0x0000a2a5, 0x0000a319, 0x0000a377, 0x0000a414, + // Entry 100 - 11F + 0x0000a4b4, 0x0000a524, 0x0000a569, 0x0000a5c8, + 0x0000a642, 0x0000a6fa, 0x0000a75c, 0x0000a853, + 0x0000a8d3, 0x0000a940, 0x0000a99e, 0x0000aa1a, + 0x0000aaa9, 0x0000ab21, 0x0000abab, 0x0000ac19, + 0x0000ac5e, 0x0000aca3, 0x0000ad11, 0x0000ad7f, + 0x0000adea, 0x0000ae4f, 0x0000aed8, 0x0000af50, + 0x0000afd5, 0x0000b068, 0x0000b0fa, 0x0000b175, + 0x0000b200, 0x0000b286, 0x0000b2d5, 0x0000b339, + // Entry 120 - 13F + 0x0000b3d9, 0x0000b431, 0x0000b4c8, 0x0000b537, + 0x0000b58e, 0x0000b628, 0x0000b697, 0x0000b70e, + 0x0000b7a4, 0x0000b835, 0x0000b8f8, 0x0000b981, + 0x0000b9f9, 0x0000bb0d, 0x0000bc29, 0x0000bd16, + 0x0000bd6b, 0x0000bdd4, 0x0000be62, 0x0000bedf, + 0x0000bf5d, 0x0000bfdd, 0x0000c03f, 0x0000c0cb, + 0x0000c144, 0x0000c1e9, 0x0000c280, 0x0000c36d, + 0x0000c3ea, 0x0000c474, 0x0000c500, 0x0000c56b, + // Entry 140 - 15F + 0x0000c5d1, 0x0000c680, 0x0000c711, 0x0000c7a3, + 0x0000c825, 0x0000c8a6, 0x0000c920, 0x0000c98b, + 0x0000ca22, 0x0000caa3, 0x0000cb49, 0x0000cbd6, + 0x0000cc70, 0x0000cd08, 0x0000cd9a, 0x0000ce00, + 0x0000ce93, 0x0000cf09, 0x0000cf8c, 0x0000d012, + 0x0000d09c, 0x0000d0f2, 0x0000d16b, 0x0000d22a, + 0x0000d2a9, 0x0000d339, 0x0000d388, 0x0000d405, + 0x0000d468, 0x0000d4f2, 0x0000d5e3, 0x0000d67b, + // Entry 160 - 17F + 0x0000d746, 0x0000d7b5, 0x0000d819, 0x0000d8b9, + 0x0000d93a, 0x0000d9a6, 0x0000da0c, 0x0000da70, + 0x0000daeb, 0x0000db9d, 0x0000dbfe, 0x0000dc9f, + 0x0000dd31, 0x0000ddc2, 0x0000de64, 0x0000dedf, + 0x0000df50, 0x0000dfe7, 0x0000e058, 0x0000e0bb, + 0x0000e17b, 0x0000e217, 0x0000e2a1, 0x0000e323, + 0x0000e381, 0x0000e3cd, 0x0000e46e, 0x0000e51e, + 0x0000e572, 0x0000e5e5, 0x0000e643, 0x0000e6ed, + // Entry 180 - 19F + 0x0000e7aa, 0x0000e846, 0x0000e8b3, 0x0000e95c, + 0x0000ea2c, 0x0000ea90, 0x0000eb32, 0x0000ebcf, + 0x0000ec55, 0x0000ecbc, 0x0000ed56, 0x0000ee1b, + 0x0000ee9b, 0x0000ef06, 0x0000efb3, 0x0000eff5, + 0x0000f0ab, 0x0000f12b, 0x0000f178, 0x0000f1f4, + 0x0000f24f, 0x0000f2ca, 0x0000f34d, 0x0000f3cc, + 0x0000f469, 0x0000f4df, 0x0000f579, 0x0000f5d7, + 0x0000f65b, 0x0000f709, 0x0000f79c, 0x0000f840, + // Entry 1A0 - 1BF + 0x0000f8c3, 0x0000f954, 0x0000f9fb, 0x0000faac, + 0x0000fb67, 0x0000fc04, 0x0000fcbd, 0x0000fd95, + 0x0000fe47, 0x0000feb3, 0x0000ff64, 0x0000ffbf, + 0x0001001a, 0x000100a2, 0x0001012c, 0x0001017a, + 0x000101fc, 0x0001027b, 0x00010300, 0x000103c3, + 0x00010475, 0x000104da, 0x000105ca, 0x00010681, + 0x0001075e, 0x000107bc, 0x0001087d, 0x000108df, + 0x0001096b, 0x000109da, 0x00010a1d, 0x00010a71, + // Entry 1C0 - 1DF + 0x00010aff, 0x00010bc0, 0x00010c6c, 0x00010d0a, + 0x00010d8a, 0x00010e3f, 0x00010eb4, 0x00010f3d, + 0x00010f88, 0x00010ff6, 0x00011057, 0x000110d8, + 0x0001115e, 0x000111b2, 0x00011212, 0x000112ac, + 0x0001131b, 0x00011385, 0x000113db, 0x00011441, + 0x0001148b, 0x00011508, 0x00011590, 0x000115fb, + 0x00011664, 0x000116b3, 0x0001170e, 0x00011776, + 0x000117cc, 0x00011831, 0x00011847, 0x0001185f, + // Entry 1E0 - 1FF + 0x00011876, 0x00011887, 0x000118a7, 0x000118d5, + 0x000118f5, 0x0001192f, 0x0001195d, 0x00011978, + 0x000119ae, 0x000119d8, 0x000119fc, 0x00011a2a, + 0x00011a59, 0x00011a7a, 0x00011aa4, +} // Size: 2004 bytes + +const enData string = "" + // Size: 72356 bytes + "\x02Start to generate compilation database\x02Start parsing compilation " + + "database\x02Start preprocessing C/C++ files\x02Preprocessing C/C++ files" + + " completed [%[1]s]\x02Total time for analysis: %[1]s\x02Start analyzing " + + "C/C++ files\x02Analyzing C/C++ files completed [%[1]s]\x02Start analyzin" + + "g for %[1]s (%[2]v/%[3]v)\x02Analysis of %[1]s completed (%[2]s, %[3]v/%" + + "[4]v) [%[5]s]\x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rul" + + "e 1.1: The program shall contain no violations of the standard C syntax " + + "and constraints, and shall not exceed the implementation's translation l" + + "imits\x0aToo many members in structure '%[1]s': %[2]s. The limit is %[3]" + + "s. \x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The" + + " program shall contain no violations of the standard C syntax and constr" + + "aints, and shall not exceed the implementation's translation limits\x0aT" + + "oo many parameters in function definition '%[1]s': %[2]s. The limit is %" + + "[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: " + + "The program shall contain no violations of the standard C syntax and con" + + "straints, and shall not exceed the implementation's translation limits" + + "\x0aToo many arguments in function call '%[1]s': %[2]s. The limit is %[3" + + "]s. \x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: Th" + + "e program shall contain no violations of the standard C syntax and const" + + "raints, and shall not exceed the implementation's translation limits\x0a" + + "Too many levels of nested structure or union definitions in a single str" + + "uct-declaration-list '%[1]s': %[2]s. The limit is %[3]s. \x02[C2201][mis" + + "ra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall con" + + "tain no violations of the standard C syntax and constraints, and shall n" + + "ot exceed the implementation's translation limits\x0aToo many nesting le" + + "vels of parenthesized expressions within a full expression '%[1]s': %[2]" + + "s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MISRA " + + "C:2012 Rule 1.1: The program shall contain no violations of the standard" + + " C syntax and constraints, and shall not exceed the implementation's tra" + + "nslation limits\x0aToo many case labels for a switch statement '%[1]s': " + + "%[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MI" + + "SRA C:2012 Rule 1.1: The program shall contain no violations of the stan" + + "dard C syntax and constraints, and shall not exceed the implementation's" + + " translation limits\x0aToo many enumeration constants in a single enumer" + + "ation '%[1]s': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: " + + "Violation of MISRA C:2012 Rule 1.1: The program shall contain no violati" + + "ons of the standard C syntax and constraints, and shall not exceed the i" + + "mplementation's translation limits\x0aToo many characters in a string li" + + "teral '%[1]s': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: " + + "Violation of MISRA C:2012 Rule 1.1: The program shall contain no violati" + + "ons of the standard C syntax and constraints, and shall not exceed the i" + + "mplementation's translation limits\x0aToo many external identifiers in o" + + "ne translation unit '%[1]s': %[2]s. The limit is %[3]s. \x02[C2201][misr" + + "a-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall cont" + + "ain no violations of the standard C syntax and constraints, and shall no" + + "t exceed the implementation's translation limits (The identifiers '%[2]s" + + "' and '%[4]s' at %[3]s and %[5]s are not distinct)\x02[C2201][misra-c201" + + "2-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no" + + " violations of the standard C syntax and constraints, and shall not exce" + + "ed the implementation's translation limits\x0aToo many macro identifiers" + + " simultaneously defined in one preprocessing translation unit '%[1]s': %" + + "[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MIS" + + "RA C:2012 Rule 1.1: The program shall contain no violations of the stand" + + "ard C syntax and constraints, and shall not exceed the implementation's " + + "translation limits\x0aToo many parameters in one macro definition '%[1]s" + + "': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of" + + " MISRA C:2012 Rule 1.1: The program shall contain no violations of the s" + + "tandard C syntax and constraints, and shall not exceed the implementatio" + + "n's translation limits\x0aToo many arguments in one macro invocation '%[" + + "1]s': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation" + + " of MISRA C:2012 Rule 1.1: The program shall contain no violations of th" + + "e standard C syntax and constraints, and shall not exceed the implementa" + + "tion's translation limits\x0aToo many nesting levels of blocks '%[1]s': " + + "%[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MI" + + "SRA C:2012 Rule 1.1: The program shall contain no violations of the stan" + + "dard C syntax and constraints, and shall not exceed the implementation's" + + " translation limits\x0aToo many nesting levels for #included files '%[1]" + + "s': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation o" + + "f MISRA C:2012 Rule 1.1: The program shall contain no violations of the " + + "standard C syntax and constraints, and shall not exceed the implementati" + + "on's translation limits\x0aToo many significant initial characters in an" + + " internal identifier or a macro name '%[1]s': %[2]s. The limit is %[3]s." + + " \x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The p" + + "rogram shall contain no violations of the standard C syntax and constrai" + + "nts, and shall not exceed the implementation's translation limits\x0aToo" + + " many nesting levels of conditional inclusion '%[1]s': %[2]s. The limit " + + "is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1" + + ".1: The program shall contain no violations of the standard C syntax and" + + " constraints, and shall not exceed the implementation's translation limi" + + "ts\x0aToo many identifiers with block scope declared in one block '%[1]s" + + "': %[2]s. The limit is %[3]s. \x02[C2201][misra-c2012-1.1]: Violation of" + + " MISRA C:2012 Rule 1.1: The program shall contain no violations of the s" + + "tandard C syntax and constraints, and shall not exceed the implementatio" + + "n's translation limits\x0aToo many nesting levels of parenthesized decla" + + "rators within a full declarator '%[1]s': %[2]s. The limit is %[3]s. \x02" + + "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The progra" + + "m shall contain no violations of the standard C syntax and constraints, " + + "and shall not exceed the implementation's translation limits\x0aToo many" + + " pointer, array, and function declarators (in any combinations) modifyin" + + "g an arithmetic, structure, union, or void type in a declaration '%[1]s'" + + ": %[2]s. The limit is %[3]s. \x02[C2203][misra-c2012-1.3]: Violation of " + + "MISRA C:2012 Rule 1.3: There shall be no occurrence of undefined or crit" + + "ical unspecified behaviour: %[1]s\x02[C2204][misra-c2012-1.4]: Violation" + + " of MISRA C:2012 Rule 1.4: Emergent language features shall not be used" + + "\x02[C2007][misra-c2012-2.1]: Violation of MISRA C:2012 Rule 2.1: A proj" + + "ect shall not contain unreachable code: %[1]s\x02[C2006][misra-c2012-2.2" + + "]: Violation of MISRA C:2012 Rule 2.2: There shall be no dead code (A ca" + + "ll to an empty function is dead code)\x02[C2006][misra-c2012-2.2]: Viola" + + "tion of MISRA C:2012 Rule 2.2: There shall be no dead code: %[1]s\x02[C2" + + "005][misra-c2012-2.3]: Violation of MISRA C:2012 Rule 2.3: A project sho" + + "uld not contain unused type declarations (unused typedef \x22%[1]s\x22)" + + "\x02[C2004][misra-c2012-2.4]: Violation of MISRA C:2012 Rule 2.4: A proj" + + "ect should not contain unused tag declarations\x02[C2003][misra-c2012-2." + + "5]: Violation of MISRA C:2012 Rule 2.5: A project should not contain unu" + + "sed macro declarations\x02[C2002][misra-c2012-2.6]: Violation of MISRA C" + + ":2012 Rule 2.6: A function should not contain unused label declarations" + + "\x02[C2001][misra-c2012-2.7]: Violation of MISRA C:2012 Rule 2.7: There " + + "should be no unused parameters in functions\x02[C2102][misra-c2012-3.1]:" + + " Violation of MISRA C:2012 Rule 3.1: The character sequences /* and // s" + + "hall not be used within a comment\x02[C2101][misra-c2012-3.2]: Violation" + + " of MISRA C:2012 Rule 3.2: Line-splicing shall not be used in // comment" + + "s\x02[C1002][misra-c2012-4.1]: Violation of MISRA C:2012 Rule 4.1: Octal" + + " and hexadecimal escape sequences shall be terminated\x02[C1001][misra-c" + + "2012-4.2]: Violation of MISRA C:2012 Rule 4.2: Trigraphs should not be u" + + "sed\x02[C1109][misra-c2012-5.1]: Violation of MISRA C:2012 Rule 5.1: Ext" + + "ernal identifiers shall be distinct (%[1]s \x22%[2]s\x22 contains non-AS" + + "CII characters)\x02[C1109][misra-c2012-5.1]: Violation of MISRA C:2012 R" + + "ule 5.1: External identifiers shall be distinct (The identifiers '%[2]s'" + + " and '%[4]s' at %[3]s and %[5]s are not distinct)\x02[C1108][misra-c2012" + + "-5.2]: Violation of MISRA C:2012 Rule 5.2: Identifiers declared in the s" + + "ame scope and name space shall be distinct\x02[C1107][misra-c2012-5.3]: " + + "Violation of MISRA C:2012 Rule 5.3: An identifier declared in an inner s" + + "cope shall not hide an identifier declared in an outer scope\x02[C1106][" + + "misra-c2012-5.4]: Violation of MISRA C:2012 Rule 5.4: Macro identifiers " + + "shall be distinct\x02[C1105][misra-c2012-5.5]: Violation of MISRA C:2012" + + " Rule 5.5: Identifiers shall be distinct from macro names\x02[C1104][mis" + + "ra-c2012-5.6]: Violation of MISRA C:2012 Rule 5.6: A typedef name shall " + + "be a unique identifier (The identifiers \x22%[1]s\x22 at %[2]s and %[3]s" + + " are the same)\x02[C1103][misra-c2012-5.7]: Violation of MISRA C:2012 Ru" + + "le 5.7: A tag name shall be a unique identifier (The identifiers \x22%[1" + + "]s\x22 at %[2]s and %[3]s are the same)\x02[C1103][misra-c2012-5.7]: Vio" + + "lation of MISRA C:2012 Rule 5.7: A tag name shall be a unique identifier" + + " (invalid declaration at %[1]s)\x02[C1102][misra-c2012-5.8]: Violation o" + + "f MISRA C:2012 Rule 5.8: Identifiers that define objects or functions wi" + + "th external linkage shall be unique (The identifiers \x22%[2]s\x22 at %[" + + "3]s and %[4]s are the same)\x02[C1101][misra-c2012-5.9]: Violation of MI" + + "SRA C:2012 Rule 5.9: Identifiers that define objects or functions with i" + + "nternal linkage should be unique (The identifiers \x22%[2]s\x22 at %[3]s" + + " and %[4]s are the same)\x02[C0702][misra-c2012-6.1]: Violation of MISRA" + + " C:2012 Rule 6.1: Bit-fields shall only be declared with an appropriate " + + "type\x02[C0701][misra-c2012-6.2]: Violation of MISRA C:2012 Rule 6.2: Si" + + "ngle-bit named bit fields shall not be of a signed type\x02[C0703][misra" + + "-c2012-6.3]: Violation of MISRA C:2012 Rule 6.3: A bit field shall not b" + + "e declared as a member of a union\x02[C0904][misra-c2012-7.1]: Violation" + + " of MISRA C:2012 Rule 7.1: Octal constants shall not be used\x02[C0903][" + + "misra-c2012-7.2]: Violation of MISRA C:2012 Rule 7.2: A \x22u\x22 or " + + "\x22U\x22 suffix shall be applied to all integer constants that are repr" + + "esented in an unsigned type\x02[C0902][misra-c2012-7.3]: Violation of MI" + + "SRA C:2012 Rule 7.3: The lowercase character \x22l\x22 shall not be used" + + " in a literal suffix\x02[C0901][misra-c2012-7.4]: Violation of MISRA C:2" + + "012 Rule 7.4: A string literal shall not be assigned to an object unless" + + " the object's type is \x22pointer to const-qualified char\x22\x02[C0901]" + + "[misra-c2012-7.4]: Violation of MISRA C:2012 Rule 7.4: A string literal " + + "shall not be assigned to an object unless the object's type is \x22point" + + "er to const-qualified char\x22 (violated at %[1]s)\x02[C0901][misra-c201" + + "2-7.4]: Violation of MISRA C:2012 Rule 7.4: A string literal shall not b" + + "e assigned to an object unless the object's type is \x22pointer to const" + + "-qualified char\x22: %[1]s\x02[C0905][misra-c2012-7.5]: Violation of MIS" + + "RA C:2012 Rule 7.5: The argument of an integer constant macro shall have" + + " an appropriate form: %[1]s\x02[C0514][misra-c2012-8.1]: Violation of MI" + + "SRA C:2012 Rule 8.1: Types shall be explicitly specified: %[1]s\x02[C051" + + "3][misra-c2012-8.2]: Violation of MISRA C:2012 Rule 8.2: Function types " + + "shall be in prototype form with named parameters (The function \x22%[1]s" + + "\x22 has unnamed parameter(s))\x02[C0513][misra-c2012-8.2]: Violation of" + + " MISRA C:2012 Rule 8.2: Function types shall be in prototype form with n" + + "amed parameters\x02[C0513][misra-c2012-8.2]: Violation of MISRA C:2012 R" + + "ule 8.2: Function types shall be in prototype form with named parameters" + + " (The function \x22%[1]s\x22 uses forbidden K&R style)\x02[C0513][misra-" + + "c2012-8.2]: Violation of MISRA C:2012 Rule 8.2: Function types shall be " + + "in prototype form with named parameters (missing 'void' in function \x22" + + "%[1]s\x22)\x02[C0512][misra-c2012-8.3]: Violation of MISRA C:2012 Rule 8" + + ".3: All declarations of an object or function shall use the same names a" + + "nd type qualifiers (violated in function \x22%[1]s\x22)\x02[C0512][misra" + + "-c2012-8.3]: Violation of MISRA C:2012 Rule 8.3: All declarations of an " + + "object or function shall use the same names and type qualifiers (\x22%[1" + + "]s\x22 at %[2]s and %[3]s use different names or type qualifiers)\x02[C0" + + "511][misra-c2012-8.4]: Violation of MISRA C:2012 Rule 8.4: A compatible " + + "declaration shall be visible when an object or function with external li" + + "nkage is defined (The function \x22%[1]s\x22 at %[2]s is defined without" + + " visible declaration)\x02[C0511][misra-c2012-8.4]: Violation of MISRA C:" + + "2012 Rule 8.4: A compatible declaration shall be visible when an object " + + "or function with external linkage is defined (The variable \x22%[1]s\x22" + + " at %[2]s is defined without visible declaration)\x02[C0511][misra-c2012" + + "-8.4]: Violation of MISRA C:2012 Rule 8.4: A compatible declaration shal" + + "l be visible when an object or function with external linkage is defined" + + " (Declaration and definition types of function \x22%[1]s\x22 at %[2]s do" + + " not match)\x02[C0510][misra-c2012-8.5]: Violation of MISRA C:2012 Rule " + + "8.5: An external object or function shall be declared once in one and on" + + "ly one file (The object \x22%[1]s\x22 at %[2]s is declared in different " + + "files)\x02[C0510][misra-c2012-8.5]: Violation of MISRA C:2012 Rule 8.5: " + + "An external object or function shall be declared once in one and only on" + + "e file (The function \x22%[1]s\x22 at %[2]s is declared in different fil" + + "es)\x02[C0510][misra-c2012-8.5]: Violation of MISRA C:2012 Rule 8.5: An " + + "external object or function shall be declared once in one and only one f" + + "ile (The object \x22%[1]s\x22 is declared at %[2]s and %[3]s)\x02[C0510]" + + "[misra-c2012-8.5]: Violation of MISRA C:2012 Rule 8.5: An external objec" + + "t or function shall be declared once in one and only one file (The funct" + + "ion \x22%[1]s\x22 is declared at %[2]s and %[3]s)\x02[C0509][misra-c2012" + + "-8.6]: Violation of MISRA C:2012 Rule 8.6: An identifier with external l" + + "inkage shall have exactly one external definition (The variable \x22%[1]" + + "s\x22 has two external definitions at %[2]s and %[3]s)\x02[C0508][misra-" + + "c2012-8.7]: Violation of MISRA C:2012 Rule 8.7: Functions and objects sh" + + "ould not be defined with external linkage if they are referenced in only" + + " one translation unit (\x22%[1]s\x22 referenced at %[2]s is defined at %" + + "[3]s with external linkage)\x02[C0507][misra-c2012-8.8]: Violation of MI" + + "SRA C:2012 Rule 8.8: The static storage class specifier shall be used in" + + " all declarations of objects and functions that have internal linkage" + + "\x02[C0506][misra-c2012-8.9]: Violation of MISRA C:2012 Rule 8.9: An obj" + + "ect should be defined at block scope if its identifier only appears in a" + + " single function\x02[C0505][misra-c2012-8.10]: Violation of MISRA C:2012" + + " Rule 8.10: An inline function shall be declared with the static storage" + + " class\x02[C0504][misra-c2012-8.11]: Violation of MISRA C:2012 Rule 8.11" + + ": When an array with external linkage is declared, its size should be ex" + + "plicitly specified\x02[C0503][misra-c2012-8.12]: Violation of MISRA C:20" + + "12 Rule 8.12: Within an enumerator list, the value of an implicitly-spec" + + "ified enumeration constant shall be unique\x02[C0501][misra-c2012-8.14]:" + + " Violation of MISRA C:2012 Rule 8.14: The restrict type qualifier shall " + + "not be used\x02[C0515][misra-c2012-8.15]: Violation of MISRA C:2012 Rule" + + " 8.15: All declarations of an object with an explicit alignment specific" + + "ation shall specify the same alignment: %[1]s\x02[C0516][misra-c2012-8.1" + + "6]: Violation of MISRA C:2012 Rule 8.16: The alignment specification of " + + "zero should not appear in an object declaration\x02[C0517][misra-c2012-8" + + ".17]: Violation of MISRA C:2012 Rule 8.17: At most one explicit alignmen" + + "t specifier should appear in an object declaration\x02[C1205][misra-c201" + + "2-9.1]: Violation of MISRA C:2012 Rule 9.1: The value of an object with " + + "automatic storage duration shall not be read before it has been set: %[1" + + "]s\x02[C1204][misra-c2012-9.2]: Violation of MISRA C:2012 Rule 9.2: The " + + "initializer for an aggregate or union shall be enclosed in braces\x02[C1" + + "203][misra-c2012-9.3]: Violation of MISRA C:2012 Rule 9.3: Arrays shall " + + "not be partially initialized\x02[C1202][misra-c2012-9.4]: Violation of M" + + "ISRA C:2012 Rule 9.4: An element of an object shall not be initialized m" + + "ore than once\x02[C1201][misra-c2012-9.5]:Violation of MISRA C:2012 Rule" + + " 9.5: Where designated initializers are used to initialize an array obje" + + "ct the size of the array shall be specified explicitly\x02[C0808][misra-" + + "c2012-10.1]: Violation of MISRA C:2012 Rule 10.1: Operands shall not be " + + "of an inappropriate essential type\x0a%[1]s\x02[C0807][misra-c2012-10.2]" + + ": Violation of MISRA C:2012 Rule 10.2: Expressions of essentially charac" + + "ter type shall not be used inappropriately in addition and subtraction o" + + "perations\x02[C0806][misra-c2012-10.3]: Violation of MISRA C:2012 Rule 1" + + "0.3: The value of an expression shall not be assigned to an object with " + + "a narrower essential type or of a different essential type category\x02[" + + "C0805][misra-c2012-10.4]: Violation of MISRA C:2012 Rule 10.4: Both oper" + + "ands of an operator in which the usual arithmetic conversions are perfor" + + "med shall have the same essential type category\x02[C0804][misra-c2012-1" + + "0.5]: Violation of MISRA C:2012 Rule 10.5: The value of an expression sh" + + "ould not be cast to an inappropriate essential type\x02[C0803][misra-c20" + + "12-10.6]: Violation of MISRA C:2012 Rule 10.6: The value of a composite " + + "expression shall not be assigned to an object with wider essential type" + + "\x02[C0802][misra-c2012-10.7]: Violation of MISRA C:2012 Rule 10.7: If a" + + " composite expression is used as one operand of an operator in which the" + + " usual arithmetic conversions are performed then the other operand shall" + + " not have wider essential type\x02[C0801][misra-c2012-10.8]: Violation o" + + "f MISRA C:2012 Rule 10.8: The value of a composite expression shall not " + + "be cast to a different essential type category or a wider essential type" + + "\x02[C1409][misra-c2012-11.1]: Violation of MISRA C:2012 Rule 11.1: Conv" + + "ersions shall not be performed between a pointer to a function and any o" + + "ther type (\x22%[1]s\x22 from \x22%[2]s\x22 to \x22%[3]s\x22 at %[4]s)" + + "\x02[C1409][misra-c2012-11.1]: Violation of MISRA C:2012 Rule 11.1: Conv" + + "ersions shall not be performed between a pointer to a function and any o" + + "ther type: %[1]s\x02[C1408][misra-c2012-11.2]: Violation of MISRA C:2012" + + " Rule 11.2: Conversions shall not be performed between a pointer to an i" + + "ncomplete type and any other type (\x22%[1]s\x22 from \x22pointer to %[2" + + "]s\x22 to \x22pointer to %[3]s\x22 at %[4]s)\x02[C1407][misra-c2012-11.3" + + "]: Violation of MISRA C:2012 Rule 11.3: A cast shall not be performed be" + + "tween a pointer to object type and a pointer to a different object type " + + "(\x22%[1]s\x22 from \x22pointer to %[2]s\x22 to \x22pointer to %[3]s\x22" + + " at %[4]s)\x02[C1406][misra-c2012-11.4]: Violation of MISRA C:2012 Rule " + + "11.4: A conversion should not be performed between a pointer to object a" + + "nd an integer type\x02[C1406][misra-c2012-11.4]: Violation of MISRA C:20" + + "12 Rule 11.4: A conversion should not be performed between a pointer to " + + "object and an integer type (\x22%[1]s\x22 from \x22%[2]s\x22 to \x22poin" + + "ter to %[3]s type\x22 at %[4]s)\x02[C1406][misra-c2012-11.4]: Violation " + + "of MISRA C:2012 Rule 11.4: A conversion should not be performed between " + + "a pointer to object and an integer type (\x22%[1]s\x22 from \x22pointer " + + "to %[2]s\x22 to \x22%[3]s\x22 at %[4]s)\x02[C1405][misra-c2012-11.5]: Vi" + + "olation of MISRA C:2012 Rule 11.5: A conversion should not be performed " + + "from pointer to void into pointer to object\x02[C1405][misra-c2012-11.5]" + + ": Violation of MISRA C:2012 Rule 11.5: A conversion should not be perfor" + + "med from pointer to void into pointer to object (\x22%[1]s\x22 from \x22" + + "%[2]s\x22 to \x22pointer to %[3]s\x22 at %[4]s)\x02[C1404][misra-c2012-1" + + "1.6]: Violation of MISRA C:2012 Rule 11.6: A cast shall not be performed" + + " between pointer to void and an arithmetic type (\x22%[1]s\x22 from \x22" + + "%[2]s\x22 to \x22%[3]s\x22 at %[4]s)\x02[C1404][misra-c2012-11.6]: Viola" + + "tion of MISRA C:2012 Rule 11.6: A cast shall not be performed between po" + + "inter to void and an arithmetic type: %[1]s\x02[C1403][misra-c2012-11.7]" + + ": Violation of MISRA C:2012 Rule 11.7: A cast shall not be performed bet" + + "ween pointer to object and a non-integer arithmetic type (\x22%[1]s\x22 " + + "from \x22%[2]s\x22 to \x22%[3]s\x22 at %[4]s)\x02[C1403][misra-c2012-11." + + "7]: Violation of MISRA C:2012 Rule 11.7: A cast shall not be performed b" + + "etween pointer to object and a non-integer arithmetic type: %[1]s\x02[C1" + + "402][misra-c2012-11.8]: Violation of MISRA C:2012 Rule 11.8: A cast shal" + + "l not remove any const or volatile qualification from the type pointed t" + + "o by a pointer (\x22%[1]s\x22 from \x22pointer to %[2]s\x22 to \x22point" + + "er to %[3]s\x22)\x02[C1401][misra-c2012-11.9]: Violation of MISRA C:2012" + + " Rule 11.9: The macro NULL shall be the only permitted form of integer n" + + "ull pointer constant\x02[C0605][misra-c2012-12.1]: Violation of MISRA C:" + + "2012 Rule 12.1: The precedence of operators within expressions should be" + + " made explicit\x02[C0604][misra-c2012-12.2]:Violation of MISRA C:2012 Ru" + + "le 12.2: The right hand operand of a shift operator shall lie in the ran" + + "ge zero to one less than the width in bits of the essential type of the " + + "left hand operand: %[1]s\x02[C0603][misra-c2012-12.3]: Violation of MISR" + + "A C:2012 Rule 12.3: The comma operator should not be used\x02[C0602][mis" + + "ra-c2012-12.4]: Violation of MISRA C:2012 Rule 12.4: Evaluation of const" + + "ant expressions should not lead to unsigned integer wrap-around\x02[C060" + + "1][misra-c2012-12.5]: Violation of MISRA C:2012 Rule 12.5: The sizeof op" + + "erator shall not have an operand which is a function parameter declared " + + "as \x22array of type\x22\x02[C1606][misra-c2012-13.1]: Violation of MISR" + + "A C:2012 Rule 13.1: Initializer lists shall not contain persistent side " + + "effects\x02[C1605][misra-c2012-13.2]: Violation of MISRA C:2012 Rule 13." + + "2: The value of an expression and its persistent side effects shall be t" + + "he same under all permitted evaluation orders\x02[C1605][misra-c2012-13." + + "2]: Violation of MISRA C:2012 Rule 13.2: The value of an expression and " + + "its persistent side effects shall be the same under all permitted evalua" + + "tion orders: %[1]s\x02[C1604][misra-c2012-13.3]: Violation of MISRA C:20" + + "12 Rule 13.3: A full expression containing an increment (++) or decremen" + + "t (--) operator should have no other potential side effects other than t" + + "hat caused by the increment or decrement operator\x02[C1603][misra-c2012" + + "-13.4]: Violation of MISRA C:2012 Rule 13.4: The result of an assignment" + + " operator should not be used\x02[C1603][misra-c2012-13.4]: Violation of " + + "MISRA C:2012 Rule 13.4: The result of an assignment operator should not " + + "be used: %[1]s\x02[C1602][misra-c2012-13.5]: Violation of MISRA C:2012 R" + + "ule 13.5: The right hand operand of a logical && or || operator shall no" + + "t contain persistent side effects (The operand may have persistent side " + + "effects at %[1]s)\x02[C1602][misra-c2012-13.5]: Violation of MISRA C:201" + + "2 Rule 13.5: The right hand operand of a logical && or || operator shall" + + " not contain persistent side effects (The function \x22%[1]s\x22 may hav" + + "e persistent side effects)\x02[C1601][misra-c2012-13.6]: Violation of MI" + + "SRA C:2012 Rule 13.6: The operand of the sizeof operator shall not conta" + + "in any expression which has potential side effects\x02[C1704][misra-c201" + + "2-14.1]: Violation of MISRA C:2012 Rule 14.1: A loop counter shall not h" + + "ave essentially floating type\x02[C1704][misra-c2012-14.1]: Violation of" + + " MISRA C:2012 Rule 14.1: A loop counter shall not have essentially float" + + "ing type: %[1]s\x02[C1703][misra-c2012-14.2]: Violation of MISRA C:2012 " + + "Rule 14.2: A for loop shall be well-formed (\x22%[1]s\x22 clause in the " + + "for loop may have persistent side effects)\x02[C1703][misra-c2012-14.2]:" + + " Violation of MISRA C:2012 Rule 14.2: A for loop shall be well-formed (T" + + "he loop counter \x22%[1]s\x22 is not used in \x22%[2]s\x22 clause)\x02[C" + + "1703][misra-c2012-14.2]: Violation of MISRA C:2012 Rule 14.2: A for loop" + + " shall be well-formed (The loop counter \x22%[1]s\x22 is modified in the" + + " loop body)\x02[C1703][misra-c2012-14.2]: Violation of MISRA C:2012 Rule" + + " 14.2: A for loop shall be well-formed (The \x22%[1]s\x22 clause uses th" + + "e reference \x22%[2]s\x22 modified in the loop body)\x02[C1703][misra-c2" + + "012-14.2]: Violation of MISRA C:2012 Rule 14.2: A for loop shall be well" + + "-formed (The \x22%[1]s\x22 clause should set and only set the value of l" + + "oop counter)\x02[C1703][misra-c2012-14.2]: Violation of MISRA C:2012 Rul" + + "e 14.2: A for loop shall be well-formed (The second clause uses a non-bo" + + "olean control flag)\x02[C1702][misra-c2012-14.3]: Violation of MISRA C:2" + + "012 Rule 14.3: Controlling expressions shall not be invariant\x02[C1702]" + + "[misra-c2012-14.3]: Violation of MISRA C:2012 Rule 14.3: Controlling exp" + + "ressions shall not be invariant: %[1]s\x02[C1701][misra-c2012-14.4]: Vio" + + "lation of MISRA C:2012 Rule 14.4: The controlling expression of an if st" + + "atement and the controlling expression of an iteration-statement shall h" + + "ave essentially Boolean type\x02[C1807][misra-c2012-15.1]: Violation of " + + "MISRA C:2012 Rule 15.1: The goto statement should not be used\x02[C1806]" + + "[misra-c2012-15.2]: Violation of MISRA C:2012 Rule 15.2: The goto statem" + + "ent shall jump to a label declared later in the same function\x02[C1805]" + + "[misra-c2012-15.3]: Violation of MISRA C:2012 Rule 15.3: Any label refer" + + "enced by a goto statement shall be declared in the same block, or in any" + + " block enclosing the goto statement\x02[C1804][misra-c2012-15.4]: Violat" + + "ion of MISRA C:2012 Rule 15.4: There should be no more than one break or" + + " goto statement used to terminate any iteration statement\x02[C1803][mis" + + "ra-c2012-15.5]: Violation of MISRA C:2012 Rule 15.5: A function should h" + + "ave a single point of exit at the end\x02[C1802][misra-c2012-15.6]: Viol" + + "ation of MISRA C:2012 Rule 15.6: The body of an iteration-statement or a" + + " selection-statement shall be a compound-statement\x02[C1801][misra-c201" + + "2-15.7]: Violation of MISRA C:2012 Rule 15.7: All if ... else if constru" + + "cts shall be terminated with an else statement\x02[C1907][misra-c2012-16" + + ".1]: Violation of MISRA C:2012 Rule 16.1: All switch statements shall be" + + " well-formed\x02[C1906][misra-c2012-16.2]: Violation of MISRA C:2012 Rul" + + "e 16.2: A switch label shall only be used when the most closely-enclosin" + + "g compound statement is the body of a switch statement\x02[C1905][misra-" + + "c2012-16.3]: Violation of MISRA C:2012 Rule 16.3: An unconditional break" + + " statement shall terminate every switch-clause\x02[C1904][misra-c2012-16" + + ".4]: Violation of MISRA C:2012 Rule 16.4: Every switch statement shall h" + + "ave a default label\x02[C1903][misra-c2012-16.5]: Violation of MISRA C:2" + + "012 Rule 16.5: A default label shall appear as either the first or the l" + + "ast switch label of a switch statement\x02[C1902][misra-c2012-16.6]: Vio" + + "lation of MISRA C:2012 Rule 16.6: Every switch statement shall have at l" + + "east two switch-clauses\x02[C1901][misra-c2012-16.7]: Violation of MISRA" + + " C:2012 Rule 16.7: A switch-expression shall not have essentially Boolea" + + "n type\x02[C1508][misra-c2012-17.1]: Violation of MISRA C:2012 Rule 17.1" + + ": The features of shall not be used\x02[C1507][misra-c2012-17" + + ".2]: Violation of MISRA C:2012 Rule 17.2: Functions shall not call thems" + + "elves, either directly or indirectly (a recursive chain found: %[1]s)" + + "\x02[C1507][misra-c2012-17.2]: Violation of MISRA C:2012 Rule 17.2: Func" + + "tions shall not call themselves, either directly or indirectly: %[1]s" + + "\x02[C1506][misra-c2012-17.3]: Violation of MISRA C:2012 Rule 17.3: A fu" + + "nction shall not be declared implicitly: %[1]s\x02[C1505][misra-c2012-17" + + ".4]: Violation of MISRA C:2012 Rule 17.4: All exit paths from a function" + + " with non-void return type shall have an explicit return statement with " + + "an expression\x02[C1505][misra-c2012-17.4]: Violation of MISRA C:2012 Ru" + + "le 17.4: All exit paths from a function with non-void return type shall " + + "have an explicit return statement with an expression: %[1]s\x02[C1504][m" + + "isra-c2012-17.5]: Violation of MISRA C:2012 Rule 17.5: The function argu" + + "ment corresponding to a parameter declared to have an array type shall h" + + "ave an appropriate number of elements (A null pointer argument is used f" + + "or a parameter with array type)\x02[C1504][misra-c2012-17.5]: Violation " + + "of MISRA C:2012 Rule 17.5: The function argument corresponding to a para" + + "meter declared to have an array type shall have an appropriate number of" + + " elements (An argument with improper array size is used for a parameter " + + "with array type)\x02[C1504][misra-c2012-17.5]: Violation of MISRA C:2012" + + " Rule 17.5: The function argument corresponding to a parameter declared " + + "to have an array type shall have an appropriate number of elements: %[1]" + + "s\x02[C1503][misra-c2012-17.6]: Violation of MISRA C:2012 Rule 17.6: The" + + " declaration of an array parameter shall not contain the static keyword " + + "between the [ ]\x02[C1502][misra-c2012-17.7]: Violation of MISRA C:2012 " + + "Rule 17.7: The value returned by a function having non-void return type " + + "shall be used\x02[C1501][misra-c2012-17.8]: Violation of MISRA C:2012 Ru" + + "le 17.8: A function parameter should not be modified\x02[C1501][misra-c2" + + "012-17.8]: Violation of MISRA C:2012 Rule 17.8: A function parameter sho" + + "uld not be modified\x02[C1509][misra-c2012-17.9]: Violation of MISRA C:2" + + "012 Rule 17.9: A function declared with a _Noreturn function specifier s" + + "hall not return to its caller\x0a%[1]s\x02[C1510][misra-c2012-17.10]: Vi" + + "olation of MISRA C:2012 Rule 17.10: A function declared with a _Noreturn" + + " function specifier shall have void return type\x02[C1512][misra-c2012-1" + + "7.12]: Violation of MISRA C:2012 Rule 17.12: A function identifier shoul" + + "d only be used with either a preceding &, or with a parenthesized parame" + + "ter list\x02[C1513][misra-c2012-17.13]: Violation of MISRA C:2012 Rule 1" + + "7.13: A function type shall not be type qualified\x0a%[1]s\x02[C1308][mi" + + "sra-c2012-18.1]: Violation of MISRA C:2012 Rule 18.1: A pointer resultin" + + "g from arithmetic on a pointer operand shall address an element of the s" + + "ame array as that pointer operand: %[1]s\x02[C1307][misra-c2012-18.2]: V" + + "iolation of MISRA C:2012 Rule 18.2: Subtraction between pointers shall o" + + "nly be applied to pointers that address elements of the same array: %[1]" + + "s\x02[C1306][misra-c2012-18.3]: Violation of MISRA C:2012 Rule 18.3: The" + + " relational operators >, >=, < and <= shall not be applied to objects of" + + " pointer type except where they point into the same object: %[1]s\x02[C1" + + "305][misra-c2012-18.4]: Violation of MISRA C:2012 Rule 18.4: The +, -, +" + + "= and -= operators should not be applied to an expression of pointer typ" + + "e\x02[C1304][misra-c2012-18.5]: Violation of MISRA C:2012 Rule 18.5: Dec" + + "larations should contain no more than two levels of pointer nesting\x02[" + + "C1303][misra-c2012-18.6]: Violation of MISRA C:2012 Rule 18.6: The addre" + + "ss of an object with automatic storage shall not be copied to another ob" + + "ject that persists after the first object has ceased to exist: %[1]s\x02" + + "[C1302][misra-c2012-18.7]: Violation of MISRA C:2012 Rule 18.7: Flexible" + + " array members shall not be declared\x02[C1301][misra-c2012-18.8]: Viola" + + "tion of MISRA C:2012 Rule 18.8: Variable-length array types shall not be" + + " used\x04\x00\x01\x0a]\x02[C0302][misra-c2012-19.1]: Violation of MISRA " + + "C:2012 Rule 19.1, assign or copy is overlapped\x02[C0302][misra-c2012-19" + + ".1]: Violation of MISRA C:2012 Rule 19.1: An object shall not be assigne" + + "d or copied to an overlapping object: %[1]s\x02[C0301][misra-c2012-19.2]" + + ": Violation of MISRA C:2012 Rule 19.2: The union keyword should not be u" + + "sed\x02[C0114][misra-c2012-20.1]: Violation of MISRA C:2012 Rule 20.1: #" + + "include directives should only be preceded by preprocessor directives or" + + " comments\x02[C0113][misra-c2012-20.2]: Violation of MISRA C:2012 Rule 2" + + "0.2: The ', \x22 or \\ characters and the /* or // character sequences s" + + "hall not occur in a header file name\x02[C0112][misra-c2012-20.3]: Viola" + + "tion of MISRA C:2012 Rule 20.3: The #include directive shall be followed" + + " by either a or \x22filename\x22 sequence\x02[C0111][misra-c2" + + "012-20.4]: Violation of MISRA C:2012 Rule 20.4: A macro shall not be def" + + "ined with the same name as a keyword\x02[C0110][misra-c2012-20.5]: Viola" + + "tion of MISRA C:2012 Rule 20.5: #undef should not be used\x02[C0109][mis" + + "ra-c2012-20.6]: Violation of MISRA C:2012 Rule 20.6: Tokens that look li" + + "ke a preprocessing directive shall not occur within a macro argument\x02" + + "[C0108][misra-c2012-20.7]: Violation of MISRA C:2012 Rule 20.7: Expressi" + + "ons resulting from the expansion of macro parameters shall be enclosed i" + + "n parentheses\x02[C0107][misra-c2012-20.8]: Violation of MISRA C:2012 Ru" + + "le 20.8: The controlling expression of a #if or #elif preprocessing dire" + + "ctive shall evaluate to 0 or 1\x02[C0106][misra-c2012-20.9]: Violation o" + + "f MISRA C:2012 Rule 20.9: All identifiers used in the controlling expres" + + "sion of #if or #elif preprocessing directives shall be #define'd before " + + "evaluation\x02[C0105][misra-c2012-20.10]: Violation of MISRA C:2012 Rule" + + " 20.10: The # and ## preprocessor operators should not be used\x02[C0104" + + "][misra-c2012-20.11]: Violation of MISRA C:2012 Rule 20.11: A macro para" + + "meter immediately following a # operator shall not immediately be follow" + + "ed by a ## operator\x02[C0103][misra-c2012-20.12]: Violation of MISRA C:" + + "2012 Rule 20.12: A macro parameter used as an operand to the # or ## ope" + + "rators, which is itself subject to further macro replacement, shall only" + + " be used as an operand to these operators\x02[C0102][misra-c2012-20.13]:" + + " Violation of MISRA C:2012 Rule 20.13: A line whose first token is # sha" + + "ll be a valid preprocessing directive\x02[C0101][misra-c2012-20.14]: Vio" + + "lation of MISRA C:2012 Rule 20.14: All #else, #elif and #endif preproces" + + "sor directives shall reside in the same file as the #if, #ifdef or #ifnd" + + "ef directive to which they are related\x02[C0420][misra-c2012-21.1]: Vio" + + "lation of MISRA C:2012 Rule 21.1: #define and #undef shall not be used o" + + "n a reserved identifier or reserved macro name\x02[C0419][misra-c2012-21" + + ".2]: Violation of MISRA C:2012 Rule 21.2: A reserved identifier or reser" + + "ved macro name shall not be declared\x02[C0418][misra-c2012-21.3]: Viola" + + "tion of MISRA C:2012 Rule 21.3: The memory allocation and deallocation f" + + "unctions of shall not be used\x02[C0417][misra-c2012-21.4]: V" + + "iolation of MISRA C:2012 Rule 21.4: The standard header file " + + "shall not be used\x02[C0416][misra-c2012-21.5]: Violation of MISRA C:201" + + "2 Rule 21.5: The standard header file shall not be used\x02[C" + + "0415][misra-c2012-21.6]: Violation of MISRA C:2012 Rule 21.6: The Standa" + + "rd Library input/output functions shall not be used\x02[C0414][misra-c20" + + "12-21.7]: Violation of MISRA C:2012 Rule 21.7: The Standard Library func" + + "tions atof, atoi, atol and atoll functions of shall not be us" + + "ed\x02[C0413][misra-c2012-21.8]: Violation of MISRA C:2012 Rule 21.8: Th" + + "e Standard Library termination functions of shall not be used" + + "\x02[C0412][misra-c2012-21.9]: Violation of MISRA C:2012 Rule 21.9: The " + + "Standard Library functions bsearch and qsort of shall not be " + + "used\x02[C0411][misra-c2012-21.10]: Violation of MISRA C:2012 Rule 21.10" + + ": The value of errno shall only be tested when the last function to be c" + + "alled was an errno-setting-function\x02[C0410][misra-c2012-21.11]: Viola" + + "tion of MISRA C:2012 Rule 21.11: The standard header file sha" + + "ll not be used\x02[C0409][misra-c2012-21.12]: Violation of MISRA C:2012 " + + "Rule 21.12: The exception handling features of should not be us" + + "ed\x02[C0409][misra-c2012-21.12]: Violation of MISRA C:2012 Rule 21.12: " + + "The standard header file shall not be used\x02[C0408][misra-c20" + + "12-21.13]: Violation of MISRA C:2012 Rule 21.13: Any value passed to a f" + + "unction in shall be representable as an unsigned char or be th" + + "e value EOF: %[1]s\x02[C0407][misra-c2012-21.14]: Violation of MISRA C:2" + + "012 Rule 21.14: The Standard Library function memcmp shall not be used t" + + "o compare null terminated strings: %[1]s\x02[C0406][misra-c2012-21.15]: " + + "Violation of MISRA C:2012 Rule 21.15: The pointer arguments to the Stand" + + "ard Library functions memcpy, memmove and memcmp shall be pointers to qu" + + "alified or unqualified versions of compatible types\x02[C0405][misra-c20" + + "12-21.16]: Violation of MISRA C:2012 Rule 21.16: The pointer arguments t" + + "o the Standard Library function memcmp shall point to either a pointer t" + + "ype, an essentially signed type, an essentially unsigned type, an essent" + + "ially Boolean type or an essentially enum type\x02[C0404][misra-c2012-21" + + ".17]: Violation of MISRA C:2012 Rule 21.17: Use of the string handling f" + + "unctions from shall not result in accesses beyond the bounds " + + "of the objects referenced by their pointer parameters: %[1]s\x02[C0403][" + + "misra-c2012-21.18]: Violation of MISRA C:2012 Rule 21.18: The size_t arg" + + "ument passed to any function in shall have an appropriate val" + + "ue (implicit conversion from \x22pointer to %[1]s\x22 to \x22%[2]s\x22 a" + + "t %[3]s)\x02[C0403][misra-c2012-21.18]: Violation of MISRA C:2012 Rule 2" + + "1.18: The size_t argument passed to any function in shall hav" + + "e an appropriate value: %[1]s\x02[C0402][misra-c2012-21.19]: Violation o" + + "f MISRA C:2012 Rule 21.19: The pointers returned by the Standard Library" + + " functions localeconv, getenv, setlocale or, strerror shall only be used" + + " as if they have pointer to const-qualified type (implicit conversion fr" + + "om \x22pointer to %[1]s\x22 to \x22%[2]s\x22 at %[3]s)\x02[C0402][misra-" + + "c2012-21.19]: Violation of MISRA C:2012 Rule 21.19: The pointers returne" + + "d by the Standard Library functions localeconv, getenv, setlocale or, st" + + "rerror shall only be used as if they have pointer to const-qualified typ" + + "e: %[1]s\x02[C0401][misra-c2012-21.20]: Violation of MISRA C:2012 Rule 2" + + "1.20: The pointer returned by the Standard Library functions asctime, ct" + + "ime, gmtime, localtime, localeconv, getenv, setlocale or strerror shall " + + "not be used following a subsequent call to the same function: %[1]s\x02[" + + "C0421][misra-c2012-21.21]: Violation of MISRA C:2012 Rule 21.21: The Sta" + + "ndard Library function system of shall not be used\x02[C0422]" + + "[misra-c2012-21.22]: Violation of MISRA C:2012 Rule 21.22: All operand a" + + "rguments to any type-generic macros declared in , >=.\x02Violation of MISRA C++:2008 Rule 4-5-3: Expressions with " + + "type (plain) char and wchar_t shall not be used as operands to built-in " + + "operators other than the assignment operator =, the equality operators =" + + "= and !=, and the unary & operator.\x02Violation of MISRA C++:2008 Rule " + + "4-10-1: NULL shall not be used as an integer value.\x02Violation of MISR" + + "A C++:2008 Rule 4-10-2: Literal zero (0) shall not be used as the null-p" + + "ointer-constant\x02Violation of MISRA C++:2008 Rule 5-0-1: The value of " + + "an expression shall be the same under any order of evaluation that the s" + + "tandard permits.\x02Violation of MISRA C++:2008 Rule 5-0-2: Limited depe" + + "ndence should be placed on C++ operator precedence rules in expressions." + + "\x02Violation of MISRA C++:2008 Rule 5-0-3: A cvalue expression shall no" + + "t be implicitly converted to a different underlying type.\x02Violation o" + + "f MISRA C++:2008 Rule 5-0-4: An implicit integral conversion shall not c" + + "hange the signedness of the underlying type.\x02Violation of MISRA C++:2" + + "008 Rule 5-0-5: There shall be no implicit floating-integral conversions" + + ".\x02Violation of MISRA C++:2008 Rule 5-0-6: An implicit integral or flo" + + "ating-point conversion shall not reduce the size of the underlying type." + + "\x02Violation of MISRA C++:2008 Rule 5-0-7: There shall be no explicit f" + + "loating-integral conversions of a cvalue expression.\x02Violation of MIS" + + "RA C++:2008 Rule 5-0-8: An explicit integral or floating-point conversio" + + "n shall not increase the size of the underlying type of a cvalue express" + + "ion.\x02Violation of MISRA C++:2008 Rule 5-0-9: An explicit integral con" + + "version shall not change the signedness of the underlying type of a cval" + + "ue expression.\x02Violation of MISRA C++:2008 Rule 5-0-10: If the bitwis" + + "e operators ~ and << are applied to an operand with an underlying type o" + + "f unsigned char or unsigned short, the result shall be immediately cast " + + "to the underlying type of the operand.\x02Violation of MISRA C++:2008 Ru" + + "le 5-0-11: The plain char type shall only be used for the storage and us" + + "e of character values.\x02Violation of MISRA C++:2008 Rule 5-0-12: signe" + + "d char and unsigned char type shall only be used for the storage and use" + + " of numeric values.\x02Violation of MISRA C++:2008 Rule 5-0-13: The cond" + + "ition of an if-statement and the condition of an iteration-statement sha" + + "ll have type bool.\x02Violation of MISRA C++:2008 Rule 5-0-14: The first" + + " operand of a conditional-operator shall have type bool.\x02Violation of" + + " MISRA C++:2008 Rule 5-0-15: Array indexing shall be the only form of po" + + "inter arithmetic.\x02Violation of MISRA C++:2008 Rule 5-0-16: A pointer " + + "operand and any pointer resulting from pointer arithmetic using that ope" + + "rand shall both address elements of the same array.\x02Violation of MISR" + + "A C++:2008 Rule 5-0-17: Subtraction between pointers shall only be appli" + + "ed to pointers that address elements of the same array.\x02Violation of " + + "MISRA C++:2008 Rule 5-0-18: >, >=, <, <= shall not be applied to objects" + + " of pointer type, except where they point to the same array.\x02Violatio" + + "n of MISRA C++:2008 Rule 5-0-19: The declaration of objects shall contai" + + "n no more than two levels of pointer indirection.\x02Violation of MISRA " + + "C++:2008 Rule 5-0-20: Non-constant operands to a binary bitwise operator" + + " shall have the same underlying type.\x02Violation of MISRA C++:2008 Rul" + + "e 5-0-21: Bitwise operators shall only be applied to operands of unsigne" + + "d underlying type.\x02Violation of MISRA C++:2008 Rule 5-2-1: Each opera" + + "nd of a logical && or | | shall be a postfix-expression.\x02Violation of" + + " MISRA C++:2008 Rule 5-2-2: A pointer to a virtual base class shall only" + + " be cast to a pointer to a derived class by means of dynamic_cast.\x02Vi" + + "olation of MISRA C++:2008 Rule 5-2-3: Casts from a base class to a deriv" + + "ed class should not be performed on polymorphic types.\x02Violation of M" + + "ISRA C++:2008 Rule 5-2-4: C-style casts (other than void casts) and func" + + "tional notation casts (other than explicit constructor call) shall not b" + + "e used.\x02Violation of MISRA C++:2008 Rule 5-2-5: A cast shall not remo" + + "ve any const or volatile qualification from the type of a pointer or ref" + + "erence.\x02Violation of MISRA C++:2008 Rule 5-2-6: A cast shall not conv" + + "ert a pointer to a function to any other pointer type, including a point" + + "er to function type.\x02Violation of MISRA C++:2008 Rule 5-2-7: An objec" + + "t with pointer type shall not be converted to an unrelated pointer type," + + " either directly or indirectly.\x02Violation of MISRA C++:2008 Rule 5-2-" + + "8: An object with integer type or pointer to void type shall not be conv" + + "erted to an object with poiner type.\x02Violation of MISRA C++:2008 Rule" + + " 5-2-9: A cast should not convert a pointer type to an integral type." + + "\x02Violation of MISRA C++:2008 Rule 5-2-10: The increment (++) and decr" + + "ement (--) operators should not be mixed with other operators in an exre" + + "ssion.\x02Violation of MISRA C++:2008 Rule 5-2-11: The comma operator, &" + + "& operator and the || operator shall not be overloaded.\x02Violation of " + + "MISRA C++:2008 Rule 5-2-12: An identifier with array type passed as a fu" + + "nction argument shall not decay to a pointer.\x02Violation of MISRA C++:" + + "2008 Rule 5-3-1: Each operand of the ! operator, the logical && or the l" + + "ogical operators shall have type bool.\x02Violation of MISRA C++:2008 Ru" + + "le 5-3-2: The unary minus operator shall not be applied to an expression" + + " whose underlying type is unsigned.\x02Violation of MISRA C++:2008 Rule " + + "5-3-3: The unary & operator shall not be overloaded.\x02Violation of MIS" + + "RA C++:2008 Rule 5-3-4: Evaluation of the operand to the sizeof operator" + + " shall not contain side effects.\x02Violation of MISRA C++:2008 Rule 5-8" + + "-1: The right hand operand of a shift operator shall lie between zero an" + + "d one less than the width in bits of the underlying type of the left han" + + "d operand.\x02Violation of MISRA C++:2008 Rule 5-14-1: The right hand op" + + "erand of a logical && or || operator shall not contain side effects.\x02" + + "Violation of MISRA C++:2008 Rule 5-17-1: The semantic equivalence betwee" + + "n a binary operator and its asignment operator form shall be preserved." + + "\x02Violation of MISRA C++:2008 Rule 5-18-1: The comma operator shall no" + + "t be used.\x02Violation of MISRA C++:2008 Rule 5-19-1: Evaluation of con" + + "stant unsigned integer expressions should not lead to wrap-around.\x02Vi" + + "olation of MISRA C++:2008 Rule 6-2-1: Assignment operators shall not be " + + "used in sub-expressions.\x02Violation of MISRA C++:2008 Rule 6-2-2: Floa" + + "ting-point expressions shall not be directly or indirectly tested for eq" + + "uality or inequality.\x02Violation of MISRA C++:2008 Rule 6-2-3: Before " + + "preprocessing, a null statement shall only occur on a line by itself; it" + + " may be followed by a comment, provided that the first character followi" + + "ng the null statement is a white-space character.\x02Violation of MISRA " + + "C++:2008 Rule 6-3-1: The statement forming the body of a switch, while, " + + "do ... while or for statement shall be a compound statement.\x02Violatio" + + "n of MISRA C++:2008 Rule 6-4-1: An if (condition) construct shall be fol" + + "lowed by a compound statement. The else keyword shall be followed by eit" + + "her a compound statement, or another if statement.\x02Violation of MISRA" + + " C++:2008 Rule 6-4-2: All if ... else if constructs shall be terminated " + + "with an else clause.\x02Violation of MISRA C++:2008 Rule 6-4-3: A switch" + + " statement shall be a well-formed switch statement.\x02Violation of MISR" + + "A C++:2008 Rule 6-4-4: A switch-label shall only be used when the most c" + + "losely-enclosing compound statement is the body of a switch statement." + + "\x02Violation of MISRA C++:2008 Rule 6-4-5: An unconditional throw or br" + + "eak statement shall terminate every non-empty switch-clause.\x02Violatio" + + "n of MISRA C++:2008 Rule 6-4-6: The final clause of a switch statement s" + + "hall be the default-clause.\x02Violation of MISRA C++:2008 Rule 6-4-7: T" + + "he condition of a switch statement shall not have bool type.\x02Violatio" + + "n of MISRA C++:2008 Rule 6-4-8: Every switch statement shall have at lea" + + "st one case-clause,\x02Violation of MISRA C++:2008 Rule 6-5-1: A for loo" + + "p shall contain a single loop-counter which shall not have floating type" + + ".\x02Violation of MISRA C++:2008 Rule 6-5-2: If loop-counter is not modi" + + "fied by -- or ++, then, within condition, the loop-counter shall only be" + + " used as an operand to <=, <, > or >=.\x02Violation of MISRA C++:2008 Ru" + + "le 6-5-3: The loop-counter shall not be modified within statement.\x02Vi" + + "olation of MISRA C++:2008 Rule 6-5-4: The loop-counter shall be modified" + + " by one of: --, ++,-=n, or +=n; where n remains constant for the duratio" + + "n of the loop.\x02Violation of MISRA C++:2008 Rule 6-5-5: A loop-control" + + "-variable other than the loop-counter shall not be modified within condi" + + "tion or expression.\x02Violation of MISRA C++:2008 Rule 6-5-6: A loop-co" + + "ntrol-variable other than the loop-counter which is modified in statemen" + + "t shall have type bool.\x02Violation of MISRA C++:2008 Rule 6-6-1: Any l" + + "abel referenced by a goto statement shall be declared in the same block," + + " or in a block enclosing the goto statement.\x02Violation of MISRA C++:2" + + "008 Rule 6-6-2: The goto statement shall jump to a label declared later " + + "in the same function body.\x02Violation of MISRA C++:2008 Rule 6-6-3: Th" + + "e continue statement shall only be used within a well-formed for loop." + + "\x02Violation of MISRA C++:2008 Rule 6-6-4: For any iteration statement " + + "there shall be no more than one break or goto statement used for loop te" + + "rmination.\x02Violation of MISRA C++:2008 Rule 6-6-5: A function shall h" + + "ave a single point of exit at the end of the function.\x02Violation of M" + + "ISRA C++:2008 Rule 7-1-1: A variable which is not modified shall be cons" + + "t qualified.\x02Violation of MISRA C++:2008 Rule 7-1-2: A pointer or ref" + + "erence parameter in a function shall be declared as pointer to const or " + + "reference to const if the corresponding object is not modified.\x02Viola" + + "tion of MISRA C++:2008 Rule 7-2-1: An expression with enum underlying ty" + + "pe shall only have values corresponding to the enumerators of the enumer" + + "ation.\x02Violation of MISRA C++:2008 Rule 7-3-1: The global namespace s" + + "hall only contain main, namespace declarations and extern \x22C\x22 decl" + + "arations.\x02Violation of MISRA C++:2008 Rule 7-3-2: The identifier main" + + " shall not be used for a function other than the global function main." + + "\x02Violation of MISRA C++:2008 Rule 7-3-3: There shall be no unnamed na" + + "mespaces in header files.\x02Violation of MISRA C++:2008 Rule 7-3-4: usi" + + "ng-directives shall not be used.\x02Violation of MISRA C++:2008 Rule 7-3" + + "-5: Multiple declarations for an identifier in the same namespace shall " + + "not straddle a using-declaration for that idenifier.\x02Violation of MIS" + + "RA C++:2008 Rule 7-3-6: using-directives and using-declarations (excludi" + + "ng class scope or function scope using-declarations) shall not be used i" + + "n header files.\x02Violation of MISRA C++:2008 Rule 7-4-1: All usage of " + + "assembler shall be documented.\x02Violation of MISRA C++:2008 Rule 7-4-2" + + ": Assembler instructions shall only be introduced using the asm declarat" + + "ion.\x02Violation of MISRA C++:2008 Rule 7-4-3: Assembly language shall " + + "be encapsulated and isolated.\x02Violation of MISRA C++:2008 Rule 7-5-1:" + + " A function shall not return a reference or a pointer to an automatic va" + + "riable (including parameters) defined within the function.\x02Violation " + + "of MISRA C++:2008 Rule 7-5-2: The address of an object with automatic st" + + "orage shall not be assigned to another object that may persist after the" + + " first object has ceased to exist.\x02Violation of MISRA C++:2008 Rule 7" + + "-5-3: A function shall not return a reference or a pointer to a paramete" + + "r that is passed by reference or const reference.\x02Violation of MISRA " + + "C++:2008 Rule 7-5-4: Functions should not call themselves, either direct" + + "ly or indirectly.\x02Violation of MISRA C++:2008 Rule 8-0-1: An init-dec" + + "larator-list or a member-declarator-list shall consist of a single init-" + + "declarator or member-declarator respectively.\x02Violation of MISRA C++:" + + "2008 Rule 8-3-1: Parameters in an overriding virtual function shall eith" + + "er use the same default arguments as the function they ovrride, or else " + + "shall not specify any default arguments.\x02Violation of MISRA C++:2008 " + + "Rule 8-4-1: Functions shall not be defined using the ellipsis notation." + + "\x02Violation of MISRA C++:2008 Rule 8-4-2: The identifiers used for the" + + " parameters in a re-declaration of a function shall be identical to thos" + + "e in the declaration.\x02Violation of MISRA C++:2008 Rule 8-4-3: All exi" + + "t paths from a function with non-void return type shall have an explicit" + + " return statement with an expression.\x02Violation of MISRA C++:2008 Rul" + + "e 8-4-4: A function identifier shall either be used to call the function" + + " or it shall be preceded by &.\x02Violation of MISRA C++:2008 Rule 8-5-1" + + ": All variables shall have a defined value before they are used.\x02Viol" + + "ation of MISRA C++:2008 Rule 8-5-2: Braces shall be used to indicate and" + + " match the structure in the non-zero initialization of arrays and struct" + + "ures.\x02Violation of MISRA C++:2008 Rule 8-5-3: In an enumerator list, " + + "the = construct shall not be used to explicitly initialize members other" + + " than the first, unless all items are explicitly initialized.\x02Violati" + + "on of MISRA C++:2008 Rule 9-3-1: const member functions shall not return" + + " non-const pointers or references to class-data.\x02Violation of MISRA C" + + "++:2008 Rule 9-3-2: Member functions shall not return non-const handles " + + "to class-data.\x02Violation of MISRA C++:2008 Rule 9-3-3: If a member fu" + + "nction can be made static then it shall be made static, otherwise if it " + + "can be made const then it shall be made const.\x02Violation of MISRA C++" + + ":2008 Rule 9-5-1: Unions shall not be used.\x02Violation of MISRA C++:20" + + "08 Rule 9-6-1: When the absolute positioning of bits representing a bit-" + + "field is required, then the behaviour and packing of bit-fields shall be" + + " documented.\x02Violation of MISRA C++:2008 Rule 9-6-2: Bit-fields shall" + + " be either bool type or an explicitly unsigned or signed integral type." + + "\x02Violation of MISRA C++:2008 Rule 9-6-3: Bit-fields shall not have en" + + "um type.\x02Violation of MISRA C++:2008 Rule 9-6-4: Named bit-fields wit" + + "h signed integer type shall have a length of more than one bit.\x02Viola" + + "tion of MISRA C++:2008 Rule 10-1-1: Classes should not be derived from v" + + "irtual bases.\x02Violation of MISRA C++:2008 Rule 10-1-2: A base class s" + + "hall only be declared virtual if it is used in a diamond hierarchy.\x02V" + + "iolation of MISRA C++:2008 Rule 10-1-3: An accessible base class shall n" + + "ot be both virtual and non-virtual in the same hierarchy.\x02Violation o" + + "f MISRA C++:2008 Rule 10-2-1: All accessible entity names within a multi" + + "ple inheritance hierarchy should be unique.\x02Violation of MISRA C++:20" + + "08 Rule 10-3-1: There shall be no more than one definition of each virtu" + + "al function on each path through the inheritance hierarchy.\x02Violation" + + " of MISRA C++:2008 Rule 10-3-2: Each overriding virtual function shall b" + + "e declared with the virtual keyword.\x02Violation of MISRA C++:2008 Rule" + + " 10-3-3: A virtual function shall only be overridden by a pure virtual f" + + "unction if it is itself declared as pure virtual.\x02Violation of MISRA " + + "C++:2008 Rule 11-0-1: Member data in non-POD class types shall be privat" + + "e.\x02Violation of MISRA C++:2008 Rule 12-1-1: An object's dynamic type " + + "shall not be used from the body of its constructor or destructor.\x02Vio" + + "lation of MISRA C++:2008 Rule 12-1-2: AlI constructors of a class should" + + " explicitly call a constructor for all of its immediate base classes and" + + " all virtual base classes.\x02Violation of MISRA C++:2008 Rule 12-1-3: A" + + "ll constructors that are callable with a single argument of fundamental " + + "type shall be declared explicit.\x02Violation of MISRA C++:2008 Rule 12-" + + "8-1: A copy constructor shall only initialize its base classes and the n" + + "on-static members of the class of which it is a member.\x02Violation of " + + "MISRA C++:2008 Rule 12-8-2: The copy assignment operator shall be declar" + + "ed protected or private in an abstract class.\x02Violation of MISRA C++:" + + "2008 Rule 14-5-1: A non-member genericfunction shall only be declared in" + + " a namespace that is not an associated namespace.\x02Violation of MISRA " + + "C++:2008 Rule 14-5-2: A copy constructor shall be declared when there is" + + " a template constuctor with a single parameter that is a generic paramet" + + "er.\x02Violation of MISRA C++:2008 Rule 14-5-3: A copy assignment operat" + + "or shall be declared when there is a template assignment operator with a" + + " parameter that is a generic parameter:\x02Violation of MISRA C++:2008 R" + + "ule 14-6-1: In a class template with a dependent base, any name that may" + + " be found in that dependent base shall be referred to using a qualified-" + + "id or this->.\x02Violation of MISRA C++:2008 Rule 14-6-2: The function c" + + "hosen by overload resolution shall resolve to a function declared previo" + + "usly in the translation unit.\x02Violation of MISRA C++:2008 Rule 14-7-1" + + ": All class templates, function templates, class template member functio" + + "ns and class template static members shall be instantiated at least once" + + ".\x02Violation of MISRA C++:2008 Rule 14-7-2: For any given template spe" + + "cialization, an explicit instantiation of the template with the template" + + " arguments used in the specializaion shall not render the program ill-fo" + + "rmed\x02Violation of MISRA C++:2008 Rule 14-7-3: All partial and explici" + + "t specializations for a template shall be declared in the same file as t" + + "he declaration of their primary template.\x02Violation of MISRA C++:2008" + + " Rule 14-8-1: Overloaded function templates shall not be explicitly spec" + + "ialized.\x02Violation of MISRA C++:2008 Rule 14-8-2: The viable function" + + " set for a function call should either contain no function specializaion" + + "s, or only contain function specializations.\x02Violation of MISRA C++:2" + + "008 Rule 15-0-1: Exceptions shall only be used for error handling.\x02Vi" + + "olation of MISRA C++:2008 Rule 15-0-2: An exception object should not ha" + + "ve pointer type.\x02Violation of MISRA C++:2008 Rule 15-0-3: Control sha" + + "ll not be transferred into a try or catch block using a goto or a switch" + + " statement.\x02Violation of MISRA C++:2008 Rule 15-1-1: The assignment-e" + + "xpression of a throw statement shall not itself cause an exception to be" + + " thrown.\x02Violation of MISRA C++:2008 Rule 15-1-2: NULL shall not be t" + + "hrown explicitly.\x02Violation of MISRA C++:2008 Rule 15-1-3: An empty t" + + "hrow (throw;) shall only be used in the compound-statement of a catch ha" + + "ndler.\x02Violation of MISRA C++:2008 Rule 15-3-1: Exceptions shall be r" + + "aised only after start-up and before termination of the program.\x02Viol" + + "ation of MISRA C++:2008 Rule 15-3-2: There should be at least one except" + + "ion handler to catch all otherwise unhandled exceptions.\x02Violation of" + + " MISRA C++:2008 Rule 15-3-3: Handlers of a function-try-block implementa" + + "tion of a class constructor or destructor shall not reference non-static" + + " members from this class or its bases.\x02Violation of MISRA C++:2008 Ru" + + "le 15-3-4: Each exception explicitly thrown in the code shall have a han" + + "dler of a compatible type in all calll paths that could lead to that poi" + + "nt.\x02Violation of MISRA C++:2008 Rule 15-3-5: A class type exception s" + + "hall always be caught by reference.\x02Violation of MISRA C++:2008 Rule " + + "15-3-6: Where multiple handlers are provided in a single try-catch state" + + "ment or, fuction-try-block for a derived class and some or all of its ba" + + "ses, the handlers shall be ordered most-derived to base class.\x02Violat" + + "ion of MISRA C++:2008 Rule 15-3-7: Where multiple handlers are provided " + + "in a single try-catch statement or function-try-block, any elipsis (catc" + + "h-all) handler shall occur last.\x02Violation of MISRA C++:2008 Rule 15-" + + "4-1: If a function is declared with an exception-specification, then all" + + " declarations of the same function (in other translaion units) shall be " + + "declared with the same set of type -ids.\x02Violation of MISRA C++:2008 " + + "Rule 15-5-1: A class destructor shall not exit with an exception.\x02Vio" + + "lation of MISRA C++:2008 Rule 15-5-2: Where a function's declaration inc" + + "ludes an exception-specification, the function shall only be capable of " + + "throwing exceptions of the indicated type(s).\x02Violation of MISRA C++:" + + "2008 Rule 15-5-3: The terminate() function shall not be called implicitl" + + "y.\x02Violation of MISRA C++:2008 Rule 16-0-1: #include directives in a " + + "file shall only be preceded by other preprocessor directives or comments" + + ".\x02Violation of MISRA C++:2008 Rule 16-0-2: Macros shall only be #defi" + + "ne’d or #undef'd in the global namespace.\x02Violation of MISRA C++:2008" + + " Rule 16-0-3: #undef shall not be used.\x02Violation of MISRA C++:2008 R" + + "ule 16-0-4: Function-like macros shall not be defined.\x02Violation of M" + + "ISRA C++:2008 Rule 16-0-5: Arguments to a function-like macro shall not " + + "contain tokens that look like preprocessing directives.\x02Violation of " + + "MISRA C++:2008 Rule 16-0-6: In the definition of a function-like macro, " + + "each instance of a parameter shall be enclosed in parentheses, unless it" + + " is used as the operand of # or ##.\x02Violation of MISRA C++:2008 Rule " + + "16-0-7: Undefined macro identifiers shall not be used in #if or #elif pr" + + "eprocessor directives, except as operands to the defined operator.\x02Vi" + + "olation of MISRA C++:2008 Rule 16-0-8: If the # token appears as the fir" + + "st token on a line, then it shall be immediately followed by a preproces" + + "sing token.\x02Violation of MISRA C++:2008 Rule 16-1-1: The defined prep" + + "rocessor operator shall only be used in one of the two standard forms." + + "\x02Violation of MISRA C++:2008 Rule 16-1-2: All #else, #elif and #endif" + + " preprocessor directives shall reside in the same file as the #if or #if" + + "def directive to which they are related.\x02Violation of MISRA C++:2008 " + + "Rule 16-2-1: The pre-processor shall only be used for file inclusion and" + + " include guards.\x02Violation of MISRA C++:2008 Rule 16-2-2: C++ macros " + + "shall only be used for include guards, type qualifiers, or storage class" + + " specifiers.\x02Violation of MISRA C++:2008 Rule 16-2-3: Include guards " + + "shall be provided.\x02Violation of MISRA C++:2008 Rule 16-2-4: The ', " + + "\x22, /* or // characters shall not occur in a header file name.\x02Viol" + + "ation of MISRA C++:2008 Rule 16-2-5: The \\ character should not occur i" + + "n a header file name.\x02Violation of MISRA C++:2008 Rule 16-2-6: The #i" + + "nclude directive shall be followed by either a or \x22filenam" + + "e\x22 sequence.\x02Violation of MISRA C++:2008 Rule 16-3-1: There shall " + + "be at most one occurrence of the # or ## operators in a single macro def" + + "inition.\x02Violation of MISRA C++:2008 Rule 16-3-2: The # and ## operat" + + "ors should not be used.\x02Violation of MISRA C++:2008 Rule 16-6-1: All " + + "uses of the #pragma directive shall be documented.\x02Violation of MISRA" + + " C++:2008 Rule 17-0-1: Reserved identifiers, macros and functions in the" + + " standard library shall not be defined, redefined or undefined.\x02Viola" + + "tion of MISRA C++:2008 Rule 17-0-2: The names of standard library macros" + + " and objects shall not be reused.\x02Violation of MISRA C++:2008 Rule 17" + + "-0-3: The names of standard library functions shall not be overridden." + + "\x02Violation of MISRA C++:2008 Rule 17-0-4: All library code shall conf" + + "orm to MISRA C++.\x02Violation of MISRA C++:2008 Rule 17-0-5: The setjmp" + + " macro and the longjmp function shall not be used.\x02Violation of MISRA" + + " C++:2008 Rule 18-0-1: The C library shall not be used.\x02Violation of " + + "MISRA C++:2008 Rule 18-0-2: The library functions atof, atoi and atol fr" + + "om library shall not be used.\x02Violation of MISRA C++:2008 R" + + "ule 18-0-3: The library functions abort, exit, getenv and system from li" + + "brary shall not be used.\x02Violation of MISRA C++:2008 Rule 1" + + "8-0-4: The time handling functions of library shall not be used." + + "\x02Violation of MISRA C++:2008 Rule 18-0-5: The unbounded functions of " + + "library shall not be used.\x02Violation of MISRA C++:2008 Rule" + + " 18-2-1: The macro offsetof shall not be used.\x02Violation of MISRA C++" + + ":2008 Rule 18-4-1: Dynamic heap memory allocation shall not be used.\x02" + + "Violation of MISRA C++:2008 Rule 18-7-1: The signal handling facilities " + + "of shall not be used.\x02Violation of MISRA C++:2008 Rule 19-3" + + "-1: The error indicator errno shall not be used.\x02Violation of MISRA C" + + "++:2008 Rule 27-0-1: The stream input/output library shall not " + + "be used.\x02%[1]d lines of C code\x02%[1]d lines of C++ code\x02%[1]d li" + + "nes of headers\x02Use %[1]d CPU(s)\x02Start preparing CTU information" + + "\x02CTU information preparation completed [%[1]s]\x02Start preparing STU" + + " information\x02%[1]s STU information preparation completed (%[2]v/%[3]v" + + ")\x02STU information preparation completed [%[1]s]\x02Analysis completed" + + " [%[1]s]\x02%[1]s BuildAction preparation completed (%[2]v/%[3]v)\x02Bui" + + "ldAction preparation completed [%[1]s]\x02Starting generating CTU inform" + + "ation\x02%[1]s CTU information generated (%[2]v/%[3]v)\x02CTU informatio" + + "n generated successfully [%[1]s]\x02Starting writing CTU information\x02" + + "Writing CTU information completed [%[1]s]" + +var zhIndex = []uint32{ // 495 elements + // Entry 0 - 1F + 0x00000000, 0x00000019, 0x00000032, 0x0000004d, + 0x00000070, 0x0000008b, 0x000000a3, 0x000000c3, + 0x000000e3, 0x00000111, 0x000001c3, 0x00000272, + 0x0000032a, 0x000003f5, 0x000004b5, 0x0000055d, + 0x0000060b, 0x000006c5, 0x0000077b, 0x0000082a, + 0x000008f2, 0x000009a3, 0x00000a54, 0x00000aef, + 0x00000b92, 0x00000c58, 0x00000cfc, 0x00000dbe, + 0x00000e7e, 0x00000f83, 0x00000fd4, 0x00001013, + // Entry 20 - 3F + 0x00001055, 0x000010a4, 0x000010d7, 0x00001142, + 0x00001190, 0x000011d2, 0x00001222, 0x00001261, + 0x000012a7, 0x000012e5, 0x00001333, 0x00001375, + 0x000013d6, 0x00001457, 0x000014b4, 0x00001523, + 0x00001556, 0x00001595, 0x00001634, 0x000016d9, + 0x0000173c, 0x00001805, 0x000018ce, 0x00001923, + 0x00001974, 0x000019b9, 0x000019ef, 0x00001a5d, + 0x00001aa6, 0x00001b2a, 0x00001bbc, 0x00001c46, + // Entry 40 - 5F + 0x00001c97, 0x00001cd0, 0x00001d4b, 0x00001dc7, + 0x00001e42, 0x00001eb5, 0x00001f32, 0x00001fd0, + 0x00002077, 0x0000211e, 0x000021e3, 0x00002265, + 0x000022e7, 0x0000237d, 0x00002413, 0x000024c7, + 0x0000256c, 0x000025ea, 0x00002665, 0x000026b1, + 0x00002715, 0x00002779, 0x000027b9, 0x0000282c, + 0x00002875, 0x000028ca, 0x00002942, 0x00002996, + 0x000029cc, 0x00002a1d, 0x00002a80, 0x00002acc, + // Entry 60 - 7F + 0x00002b30, 0x00002ba9, 0x00002c1f, 0x00002c77, + 0x00002cd5, 0x00002d6c, 0x00002dd9, 0x00002e7b, + 0x00002edf, 0x00002fa2, 0x00003071, 0x000030c9, + 0x00003171, 0x00003219, 0x0000326c, 0x0000331b, + 0x000033c1, 0x0000341d, 0x000034cb, 0x0000353b, + 0x000035f1, 0x0000364d, 0x00003693, 0x00003724, + 0x00003762, 0x000037b4, 0x0000381e, 0x0000389e, + 0x00003960, 0x000039f1, 0x00003a9d, 0x00003add, + // Entry 80 - 9F + 0x00003b23, 0x00003bb1, 0x00003c4f, 0x00003cb6, + 0x00003cfc, 0x00003d36, 0x00003da0, 0x00003e00, + 0x00003e61, 0x00003ed0, 0x00003f40, 0x00003fa5, + 0x00003fe2, 0x00004025, 0x00004085, 0x000040b7, + 0x00004121, 0x00004189, 0x000041ed, 0x0000422d, + 0x00004282, 0x000042da, 0x00004317, 0x00004381, + 0x000043db, 0x00004422, 0x00004493, 0x000044e2, + 0x00004528, 0x00004563, 0x000045c1, 0x0000460a, + // Entry A0 - BF + 0x00004644, 0x000046d0, 0x00004762, 0x00004809, + 0x000048c5, 0x0000494a, 0x0000499f, 0x000049fb, + 0x00004a2f, 0x00004a63, 0x00004acf, 0x00004b36, + 0x00004b9e, 0x00004be2, 0x00004c73, 0x00004cda, + 0x00004d71, 0x00004dc7, 0x00004e0a, 0x00004e92, + 0x00004ee8, 0x00004f37, 0x00004f8e, 0x00004fe6, + 0x0000501c, 0x00005076, 0x000050d8, 0x0000513d, + 0x0000517a, 0x000051a8, 0x000051f7, 0x00005246, + // Entry C0 - DF + 0x000052a8, 0x00005330, 0x00005371, 0x000053d3, + 0x0000546b, 0x000054bc, 0x0000554a, 0x000055d5, + 0x00005650, 0x000056b5, 0x000056f6, 0x00005737, + 0x0000577b, 0x000057e9, 0x00005850, 0x000058a6, + 0x00005907, 0x0000594a, 0x00005990, 0x000059d0, + 0x00005a3f, 0x00005ab7, 0x00005b56, 0x00005bfd, + 0x00005cb6, 0x00005da7, 0x00005e31, 0x00005f3a, + 0x00005fd1, 0x0000608d, 0x000060db, 0x00006168, + // Entry E0 - FF + 0x000061f5, 0x00006243, 0x000062ad, 0x0000630b, + 0x00006372, 0x000063be, 0x00006419, 0x00006472, + 0x000064e5, 0x00006544, 0x000065a0, 0x00006618, + 0x00006652, 0x000066bf, 0x0000670b, 0x00006751, + 0x000067a0, 0x000067e3, 0x00006826, 0x0000688a, + 0x000068f8, 0x0000697a, 0x000069d0, 0x00006a0e, + 0x00006a67, 0x00006ab0, 0x00006ad2, 0x00006af4, + 0x00006b19, 0x00006b65, 0x00006b90, 0x00006beb, + // Entry 100 - 11F + 0x00006c48, 0x00006c82, 0x00006c98, 0x00006ccc, + 0x00006d29, 0x00006da2, 0x00006dca, 0x00006e9d, + 0x00006ee3, 0x00006f37, 0x00006f62, 0x00006f93, + 0x00006fdf, 0x0000702b, 0x0000707d, 0x000070ae, + 0x000070c7, 0x000070ed, 0x00007125, 0x00007163, + 0x00007194, 0x000071c5, 0x00007220, 0x00007282, + 0x000072e6, 0x0000733e, 0x000073c0, 0x000073f7, + 0x0000744e, 0x000074a4, 0x000074c9, 0x00007506, + // Entry 120 - 13F + 0x0000756d, 0x00007592, 0x000075f0, 0x0000762a, + 0x00007649, 0x000076a4, 0x000076e7, 0x0000772d, + 0x000077a0, 0x000077fe, 0x0000787d, 0x000078d3, + 0x0000791f, 0x000079ef, 0x00007ac8, 0x00007b7f, + 0x00007b99, 0x00007bc8, 0x00007c2c, 0x00007c6c, + 0x00007ca4, 0x00007cdb, 0x00007d04, 0x00007d3b, + 0x00007d71, 0x00007db8, 0x00007e02, 0x00007e9c, + 0x00007ed4, 0x00007f1c, 0x00007f5f, 0x00007f97, + // Entry 140 - 15F + 0x00007fc8, 0x00008041, 0x0000807e, 0x000080d6, + 0x0000810d, 0x00008159, 0x00008196, 0x000081da, + 0x0000826f, 0x000082c0, 0x0000832f, 0x00008388, + 0x000083f2, 0x0000844d, 0x000084a9, 0x000084e0, + 0x0000853f, 0x00008577, 0x000085c0, 0x0000860c, + 0x00008658, 0x00008675, 0x000086af, 0x0000871f, + 0x00008772, 0x000087be, 0x000087e1, 0x0000881b, + 0x00008849, 0x00008895, 0x00008926, 0x00008978, + // Entry 160 - 17F + 0x000089f3, 0x00008a30, 0x00008a5d, 0x00008aac, + 0x00008aff, 0x00008b37, 0x00008b60, 0x00008b92, + 0x00008bea, 0x00008c61, 0x00008c92, 0x00008d07, + 0x00008d59, 0x00008dbb, 0x00008e13, 0x00008e65, + 0x00008eac, 0x00008f01, 0x00008f2f, 0x00008f59, + 0x00008fd0, 0x00009020, 0x0000906f, 0x000090ab, + 0x000090dc, 0x000090f4, 0x00009151, 0x000091c1, + 0x000091ef, 0x00009236, 0x00009255, 0x000092b0, + // Entry 180 - 19F + 0x0000931a, 0x00009389, 0x000093b1, 0x00009463, + 0x000094e5, 0x00009507, 0x0000955f, 0x000095c4, + 0x00009611, 0x00009645, 0x000096a0, 0x00009723, + 0x0000976b, 0x000097a4, 0x00009842, 0x00009858, + 0x000098b6, 0x000098fd, 0x0000991a, 0x0000995d, + 0x0000997f, 0x000099e5, 0x00009a34, 0x00009a8f, + 0x00009af0, 0x00009b2e, 0x00009b89, 0x00009bba, + 0x00009c18, 0x00009c79, 0x00009cd7, 0x00009d3f, + // Entry 1A0 - 1BF + 0x00009dad, 0x00009e16, 0x00009e83, 0x00009ee4, + 0x00009f6f, 0x00009fc7, 0x0000a034, 0x0000a0c9, + 0x0000a12d, 0x0000a15b, 0x0000a1c8, 0x0000a1e7, + 0x0000a20c, 0x0000a252, 0x0000a28e, 0x0000a2a5, + 0x0000a2fc, 0x0000a330, 0x0000a37c, 0x0000a3fe, + 0x0000a48f, 0x0000a4c3, 0x0000a5a5, 0x0000a63f, + 0x0000a6f7, 0x0000a725, 0x0000a780, 0x0000a7a4, + 0x0000a7ec, 0x0000a827, 0x0000a83a, 0x0000a853, + // Entry 1C0 - 1DF + 0x0000a89c, 0x0000a90f, 0x0000a985, 0x0000a9d8, + 0x0000aa16, 0x0000aa8f, 0x0000aad8, 0x0000ab23, + 0x0000ab3e, 0x0000ab72, 0x0000ab98, 0x0000abd4, + 0x0000ac1d, 0x0000ac45, 0x0000ac6e, 0x0000acc6, + 0x0000acfa, 0x0000ad22, 0x0000ad4d, 0x0000ad73, + 0x0000ad8a, 0x0000adc3, 0x0000ae0a, 0x0000ae39, + 0x0000ae64, 0x0000ae7c, 0x0000ae9e, 0x0000aecc, + 0x0000aeed, 0x0000af15, 0x0000af28, 0x0000af3d, + // Entry 1E0 - 1FF + 0x0000af52, 0x0000af61, 0x0000af77, 0x0000af95, + 0x0000afab, 0x0000afd4, 0x0000aff2, 0x0000b007, + 0x0000b032, 0x0000b052, 0x0000b068, 0x0000b08b, + 0x0000b0a9, 0x0000b0bf, 0x0000b0dd, +} // Size: 2004 bytes + +const zhData string = "" + // Size: 45277 bytes + "\x02开始生成编译数据\x02开始解析编译指令\x02开始预处理C/C++信息\x02预处理C/C++信息完成 [%[1]s]\x02分析一共" + + "用时 [%[1]s]\x02开始分析C/C++代码\x02C/C++代码分析完成 [%[1]s]\x02开始分析%[1]s (%[2]v/%" + + "[3]v)\x02分析完成%[2]s (%[3]v/%[4]v) %[1]s [%[5]s]\x02[C2201][misra-c2012-1." + + "1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a结构体 %[1]s 中定义了 %[2]s 个成员,超过限制数 %[3]s" + + "\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a函数 %[1]s 中" + + "定义了 %[2]s 个参数,超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约" + + "束,不得超出实现的翻译限制\x0a函数调用 %[1]s 中使用了了 %[2]s 个形参,超过限制数 %[3]s\x02[C2201][mis" + + "ra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a单个结构声明列表中的嵌套结构或联合定义的层数%[2" + + "]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制" + + "\x0a完整表达式 %[1]s 中括号表达式的嵌套层数%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]" + + ": 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0aswitch语句中的case标签数%[2]s 超过限制数 %[3]s\x02" + + "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a单个枚举 %[1]s 中的枚" + + "举常量%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超" + + "出实现的翻译限制\x0a单个字符串字面量 %[1]s 中的字符数量%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2" + + "012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a一个翻译单元中的外部标识符数量%[2]s 超过限制数 %[3" + + "]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a%[1]s: %" + + "[2]s\x0a位置: %[3]s\x0a重复的标识符'%[4]s'位置: %[5]s\x02[C2201][misra-c2012-1.1]:" + + " 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a在一个预处理翻译单元中同时定义的宏标识符数%[2]s 超过限制数 %[3]s" + + "\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a一个宏定义 %[1]" + + "s 中的参数数量%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束," + + "不得超出实现的翻译限制\x0a一次宏调用 %[1]s 中的参数数量%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2" + + "012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a块的嵌套层数%[2]s 超过限制数 %[3]s\x02[C2" + + "201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a#include文件嵌套层数%[2" + + "]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制" + + "\x0a内部标识符或宏名称 %[1]s 中的有效初始字符数%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1." + + "1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a条件包含的嵌套深度%[2]s 超过限制数 %[3]s\x02[C2201" + + "][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a在一个块中声明具有块作用域的标识符数量%" + + "[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译" + + "限制\x0a完整声明符 %[1]s 中括号声明符的嵌套深度%[2]s 超过限制数 %[3]s\x02[C2201][misra-c2012-" + + "1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\x0a指针、数组和函数声明符(任意组合)修改声明 %[1]s 中的算术、结" + + "构、联合或 void 类型的数量%[2]s 超过限制数 %[3]s\x02[C2203][misra-c2012-1.3]: 不得出现未定义" + + "或严重的未指定行为\x0a%[1]s\x02[C2204][misra-c2012-1.4]: 不得使用新涌现的语言特性\x02[C2007" + + "][misra-c2012-2.1]: 项目不得含有不可达代码\x0a%[1]s\x02[C2006][misra-c2012-2.2]: 不得" + + "有死代码\x0a对空函数的调用是死代码\x02[C2006][misra-c2012-2.2]: 不得有死代码\x0a%[1]s\x02[C" + + "2005][misra-c2012-2.3]: 项目不应含有未使用的类型声明\x0a未使用的类型定义名称: %[1]s\x02[C2004][m" + + "isra-c2012-2.4]: 项目不应含有未使用的标签(tag)声明\x02[C2003][misra-c2012-2.5]: 项目不应含有" + + "未使用的宏声明\x02[C2002][misra-c2012-2.6]: 项目不应含有未使用的标记(label)声明\x02[C2001][" + + "misra-c2012-2.7]: 函数中不应有未使用的形参\x02[C2102][misra-c2012-3.1]: 不得在注释中使用字符序列" + + "/*和//\x02[C2101][misra-c2012-3.2]: 不得在//注释中使用行拼接\x02[C1002][misra-c2012-" + + "4.1]: 八进制和十六进制转义序列必须被终止\x02[C1001][misra-c2012-4.2]: 不应使用三字母词(trigraphs)" + + "\x02[C1109][misra-c2012-5.1]: 不得使用重名的外部标识符\x0a包含非ASCII字符\x0a%[1]s: %[2]s" + + "\x02[C1109][misra-c2012-5.1]: 不得使用重名的外部标识符\x0a%[1]s: %[2]s\x0a位置: %[3]s" + + "\x0a重复的标识符'%[4]s'位置: %[5]s\x02[C1108][misra-c2012-5.2]: 在同一作用域和命名空间内声明的标" + + "识符不得重名\x02[C1107][misra-c2012-5.3]: 在内部作用域声明的标识符不得隐藏在外部作用域声明的标识符\x02[C" + + "1106][misra-c2012-5.4]: 宏标识符不得重名\x02[C1105][misra-c2012-5.5]: 标识符不得与宏的名称" + + "重名\x02[C1104][misra-c2012-5.6]: 类型定义名称必须是唯一标识符\x0a类型定义: %[1]s\x0a第一个类型" + + "定义位置: %[2]s\x0a重复的类型定义位置: %[3]s\x02[C1103][misra-c2012-5.7]: 标签(tag)名称" + + "必须是唯一标识符\x0a重复的标签名称: %[1]s\x0a第一个标识符位置: %[2]s\x0a重复的标识符位置: %[3]s\x02[C" + + "1103][misra-c2012-5.7]: 标签(tag)名称必须是唯一标识符\x0a无效的声明在%[1]s处\x02[C1102][mis" + + "ra-c2012-5.8]: 只得使用唯一标识符定义含有外部链接的对象或函数\x0a含有外部链接的%[1]s类型对象应当是唯一的\x0a名称: " + + "%[2]s\x0a位置: %[3]s\x0a其他位置: %[4]s\x02[C1101][misra-c2012-5.9]: 应该使用唯一标识符" + + "定义含有内部链接的对象或函数\x0a含有内部链接的%[1]s类型对象应当是唯一的\x0a名称: %[2]s\x0a位置: %[3]s\x0a" + + "其他位置: %[4]s\x02[C0702][misra-c2012-6.1]: 只得使用合适的类型来声明位域(bit-fields)" + + "\x02[C0701][misra-c2012-6.2]: 一个一位的已命名位域不得为有符号类型\x02[C0703][misra-c2012-" + + "6.3]: 位字段不得声明为联合体的成员\x02[C0904][misra-c2012-7.1]: 不得使用八进制常量\x02[C0903][m" + + "isra-c2012-7.2]: 所有表示为无符号类型的整型常量都必须使用“u”或“U”后缀\x02[C0902][misra-c2012-7." + + "3]: 小写字母“l”不得用作字面量后缀\x02[C0901][misra-c2012-7.4]: 不得将字符串字面量赋值给对象,除非对象类型为" + + "“指向const修饰的char的指针”\x02[C0901][misra-c2012-7.4]: 不得将字符串字面量赋值给对象,除非对象类型" + + "为“指向const修饰的char的指针”\x0a位置: %[1]s\x02[C0901][misra-c2012-7.4]: 不得将字符串字" + + "面量赋值给对象,除非对象类型为“指向const修饰的char的指针”\x0a%[1]s\x02[C0905][misra-c2012-7.5" + + "]: 整型常量宏的参数应具有适当的形式\x0a%[1]s\x02[C0514][misra-c2012-8.1]: 必须明确指定类型\x0a%[" + + "1]s\x02[C0513][misra-c2012-8.2]: 函数类型必须为带有命名形参的原型形式\x0a存在未命名形参\x0a函数名称: " + + "%[1]s\x02[C0513][misra-c2012-8.2]: 函数类型必须为带有命名形参的原型形式\x0a存在带有未命名形参的函数指针" + + "\x02[C0513][misra-c2012-8.2]: 函数类型必须为带有命名形参的原型形式\x0a禁止使用K&R风格\x0a函数名称: %" + + "[1]s\x02[C0513][misra-c2012-8.2]: 函数类型必须为带有命名形参的原型形式\x0a缺少 'void'\x0a函数名" + + "称: %[1]s\x02[C0512][misra-c2012-8.3]: 对同一对象或函数的所有声明必须使用同样的名称和类型修饰符\x0a" + + "名称: %[1]s\x02[C0512][misra-c2012-8.3]: 对同一对象或函数的所有声明必须使用同样的名称和类型修饰符" + + "\x0a名称: %[1]s位置: %[2]s\x0a其他位置: %[3]s\x02[C0511][misra-c2012-8.4]: 对含有外部" + + "链接的对象或函数进行定义时,必须有可见的兼容声明\x0a缺少函数声明\x0a函数名称: %[1]s\x0a位置: %[2]s\x02[C05" + + "11][misra-c2012-8.4]: 对含有外部链接的对象或函数进行定义时,必须有可见的兼容声明\x0a缺少变量声明\x0a变量名称: %" + + "[1]s\x0a位置: %[2]s\x02[C0511][misra-c2012-8.4]: 对含有外部链接的对象或函数进行定义时,必须有可见的" + + "兼容声明\x0a函数声明类型与定义类型不匹配\x0a函数名称: %[1]s\x0a定义位置: %[2]s\x02[C0510][misra-" + + "c2012-8.5]: 外部对象或函数只得在一个文件里进行一次声明\x0a外部对象名称: %[1]s\x0a位置: %[2]s\x02[C051" + + "0][misra-c2012-8.5]: 外部对象或函数只得在一个文件里进行一次声明\x0a外部函数名称: %[1]s\x0a位置: %[2]s" + + "\x02[C0510][misra-c2012-8.5]: 外部对象或函数只得在一个文件里进行一次声明\x0a外部对象名称: %[1]s\x0a" + + "位置: %[2]s\x0a其他位置: %[3]s\x02[C0510][misra-c2012-8.5]: 外部对象或函数只得在一个文件里进" + + "行一次声明\x0a外部函数名称: %[1]s\x0a位置: %[2]s\x0a其他位置: %[3]s\x02[C0509][misra-c2" + + "012-8.6]: 含有外部链接的标识符必须有且只有一个外部定义\x0a重复的变量名称: %[1]s\x0a第一个定义位置: %[2]s\x0a" + + "重复的定义位置: %[3]s\x02[C0508][misra-c2012-8.7]: 不应使用外部链接定义仅在一个翻译单元中被引用的函数和" + + "对象\x0a名称: %[1]s\x0a引用位置: %[2]s\x0a声明位置: %[3]s\x02[C0507][misra-c2012-8" + + ".8]: 对含有内部链接的对象和函数进行的所有声明都必须使用静态存储类说明符\x02[C0506][misra-c2012-8.9]: 如果对象" + + "标识符只在一个函数中出现,那么应该在块作用域中定义该对象\x02[C0505][misra-c2012-8.10]: 必须使用静态存储类别声" + + "明内联函数\x02[C0504][misra-c2012-8.11]: 对含有外部链接的数组进行定义时,应显式指定其大小\x02[C0503" + + "][misra-c2012-8.12]: 枚举列表里,一个隐式指定的枚举常量的值应是唯一的\x02[C0501][misra-c2012-8.1" + + "4]: 不得使用restrict类型修饰符 \x02[C0515][misra-c2012-8.15]: 具有显式对齐规范的对象的所有声明都应指" + + "定相同的对齐方式\x0a%[1]s\x02[C0516][misra-c2012-8.16]: 零对齐规范不应出现在对象声明中\x02[C0" + + "517][misra-c2012-8.17]: 对象声明中最多应出现一个显式对齐说明符\x02[C1205][misra-c2012-9.1]:" + + " 对于具有自动存储周期的对象,不得在设定它的值之前读取它的值\x0a%[1]s\x02[C1204][misra-c2012-9.2]: 聚合或" + + "联合体的初始化器应包含在大括号内\x02[C1203][misra-c2012-9.3]: 不得部分初始化数组\x02[C1202][mis" + + "ra-c2012-9.4]: 对象中的一个元素最多只得被初始化一次\x02[C1201][misra-c2012-9.5]: 对数组对象进行指定" + + "初始化时,必须显式指定数组大小\x02[C0808][misra-c2012-10.1]: 操作数不得为不合适的基本类型\x0a%[1]s" + + "\x02[C0807][misra-c2012-10.2]: 不得在加减运算中不恰当地使用基本字符类型的表达式\x02[C0806][misra" + + "-c2012-10.3]: 表达式的值不得赋给更窄的基本类型,也不得赋给不同的基本类型类别\x02[C0805][misra-c2012-10." + + "4]: 执行寻常算术转换的运算符的两个操作数必须属于同一基本类型类别\x02[C0804][misra-c2012-10.5]: 表达式的值不应" + + "强制转换为不合适的基本类型\x02[C0803][misra-c2012-10.6]: 复合表达式的值不得赋给具有更宽基本类型的对象\x02" + + "[C0802][misra-c2012-10.7]: 寻常算术转换中,如果运算符的一个操作数为复合表达式,则另一个操作数不得具有更宽类型\x02" + + "[C0801][misra-c2012-10.8]: 复合表达式的值不得强制转换为不同基本类型类别或更宽类型\x02[C1409][misra-" + + "c2012-11.1]: 指向函数的指针和任何其他类型之间不得相互转换\x0a对象名: %[1]s\x0a原类型: %[2]s\x0a目标类型:" + + " %[3]s\x0a位置: %[4]s\x02[C1409][misra-c2012-11.1]: 指向函数的指针和任何其他类型之间不得相互转换" + + "\x0a%[1]s\x02[C1408][misra-c2012-11.2]: 指向不完整类型的指针和任何其他类型之间不得相互转换\x0a对象名" + + ": %[1]s\x0a原指针对象类型: %[2]s\x0a目标指针对象类型: %[3]s\x0a位置: %[4]s\x02[C1407][mis" + + "ra-c2012-11.3]: 指向对象类型的指针和指向不同对象类型的指针之间不得显式转换\x0a对象名: %[1]s\x0a原指针对象类型: " + + "%[2]s\x0a目标指针对象类型: %[3]s\x0a位置: %[4]s\x02[C1406][misra-c2012-11.4]: 指向对象" + + "的指针和整数类型之间不应相互转换\x02[C1406][misra-c2012-11.4]: 指向对象的指针和整数类型之间不应相互转换" + + "\x0a对象名: %[1]s\x0a原类型: %[2]s\x0a目标指针对象类型: %[3]s\x0a位置: %[4]s\x02[C1406][" + + "misra-c2012-11.4]: 指向对象的指针和整数类型之间不应相互转换\x0a对象名: %[1]s\x0a原指针对象类型: %[2]s" + + "\x0a目标类型: %[3]s\x0a位置: %[4]s\x02[C1405][misra-c2012-11.5]: 指向void的指针不应转换" + + "为指向对象的指针\x02[C1405][misra-c2012-11.5]: 指向void的指针不应转换为指向对象的指针\x0a对象名: %" + + "[1]s\x0a原指针对象类型: %[2]s\x0a目标指针对象类型: %[3]s\x0a位置: %[4]s\x02[C1404][misra-" + + "c2012-11.6]: 指向void的指针和算术类型之间不得显式转换\x0a对象名: %[1]s\x0a原对象类型: %[2]s\x0a目标对" + + "象类型: %[3]s\x0a位置: %[4]s\x02[C1404][misra-c2012-11.6]: 指向void的指针和算术类型之间" + + "不得显式转换\x0a%[1]s\x02[C1403][misra-c2012-11.7]: 指向对象的指针和非整数类型的算术类型之间不得显式" + + "转换\x0a对象名: %[1]s\x0a原类型: %[2]s\x0a目标类型: %[3]s\x0a位置: %[4]s\x02[C1403][" + + "misra-c2012-11.7]: 指向对象的指针和非整数类型的算术类型之间不得显式转换\x0a%[1]s\x02[C1402][misra-" + + "c2012-11.8]: 显式转换不得移除指针所指向类型的任何const或volatile修饰\x0a对象名: %[1]s\x0a原指针对象类型" + + ": %[2]s\x0a目标指针对象类型: %[3]s\x02[C1401][misra-c2012-11.9]: 宏NULL必须为整数类型空指针" + + "常量的唯一允许形式\x02[C0605][misra-c2012-12.1]: 应明确表达式中操作数的优先级\x02[C0604][misr" + + "a-c2012-12.2]: 移位运算符的右操作数的范围下限为零,上限须比左操作数的基本类型的位宽度小一\x0a%[1]s\x02[C0603]" + + "[misra-c2012-12.3]: 不得使用逗号运算符(,)\x02[C0602][misra-c2012-12.4]: 对常量表达式进行求" + + "值不应导致整数回绕\x02[C0601][misra-c2012-12.5]: sizeof运算符的操作数不得是声明为“数组类型”的函数形参" + + "\x02[C1606][misra-c2012-13.1]: 初始化器列表不得含有持续的副作用\x0a初始化器列表含有被引用的易失性成员\x02" + + "[C1605][misra-c2012-13.2]: 采用任意允许采用的求值顺序时,表达式的值和表达式的持续的副作用不得发生改变\x0a函数调用" + + "顺序不同会导致表达式的值不同\x02[C1605][misra-c2012-13.2]: 采用任意允许采用的求值顺序时,表达式的值和表达式的" + + "持续的副作用不得发生改变\x0a%[1]s\x02[C1604][misra-c2012-13.3]: 含有一个自增或自减运算符的完整表达式" + + ",除因自增或自减运算符引起的副作用外,不应含有其他潜在副作用\x02[C1603][misra-c2012-13.4]: 不得使用赋值运算符" + + "的结果\x02[C1603][misra-c2012-13.4]: 不得使用赋值运算符的结果\x0a%[1]s\x02[C1602][mis" + + "ra-c2012-13.5]: 逻辑与(&&)和逻辑或(||)运算符的右操作数不得含有持续的副作用\x0a副作用位置: %[1]s\x02[C1" + + "602][misra-c2012-13.5]: 逻辑与(&&)和逻辑或(||)运算符的右操作数不得含有持续的副作用\x0a函数%[1]s可能有持" + + "续的副作用\x02[C1601][misra-c2012-13.6]: sizeof运算符的操作数不得包含任何有潜在副作用的表达式\x02[" + + "C1704][misra-c2012-14.1]: 循环计数器不得为基本浮点类型\x02[C1704][misra-c2012-14.1]: f" + + "or循环必须为良构\x0a%[1]s\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0afor循环中的%[" + + "1]s子句可能有持续的副作用\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0a%[2]s子句没有使用循环" + + "计数器%[1]s\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0a循环计数器%[1]s在循环体中被修" + + "改\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0a%[1]s子句使用了在循环体内被修改的引用%[2" + + "]s\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0a%[1]s子句必须设置且只能设置循环计数器的值" + + "\x02[C1703][misra-c2012-14.2]: for循环必须为良构\x0a第二个子句使用了非布尔的控制标记\x02[C1702]" + + "[misra-c2012-14.3]: 控制表达式不得为不变量\x02[C1702][misra-c2012-14.3]: 控制表达式不得为不变" + + "量\x0a%[1]s\x02[C1701][misra-c2012-14.4]: if语句和迭代语句的控制表达式必须为基本布尔类型\x02[" + + "C1807][misra-c2012-15.1]: 不应使用goto语句\x02[C1806][misra-c2012-15.2]: 同一函数中" + + ",goto语句只得跳转到在其后声明的标记(label)\x02[C1805][misra-c2012-15.3]: goto语句引用的标记必" + + "须在同一代码块或上级代码块中声明\x02[C1804][misra-c2012-15.4]: 任何迭代语句最多只应使用一个break或got" + + "o语句进行终止\x02[C1803][misra-c2012-15.5]: 函数结尾应只有一个退出点\x02[C1802][misra-c201" + + "2-15.6]: 迭代语句或分支语句的主体必须为复合语句\x02[C1801][misra-c2012-15.7]: 所有if … else i" + + "f构造都必须以一个else语句终止\x02[C1907][misra-c2012-16.1]: 所有switch语句必须为良构\x02[C190" + + "6][misra-c2012-16.2]: switch标记只得出现在构成switch语句主体的复合语句的最外层\x02[C1905][misr" + + "a-c2012-16.3]: 每个switch子句都必须以一个无条件break语句终止\x02[C1904][misra-c2012-16.4]" + + ": 每个switch语句都必须有default标签\x02[C1903][misra-c2012-16.5]: 在一个switch语句中,def" + + "ault标签必须是第一个或最后一个switch标签\x02[C1902][misra-c2012-16.6]: 每个switch语句必须至少有两" + + "个switch子句\x02[C1901][misra-c2012-16.7]: switch表达式不得是基本布尔类型\x02[C1508][" + + "misra-c2012-17.1]: 不得使用的特性\x02[C1507][misra-c2012-17.2]: 函数不得直" + + "接或间接调用自身\x0a找到一条递归链%[1]s\x02[C1507][misra-c2012-17.2]: 函数不得直接或间接调用自身" + + "\x0a%[1]s\x02[C1506][misra-c2012-17.3]: 不得隐式声明函数\x0a%[1]s\x02[C1505][mis" + + "ra-c2012-17.4]: 函数如果为非void返回类型,则其所有退出路径必须有一个包含表达式的显式return语句\x02[C1505][" + + "misra-c2012-17.4]: 函数如果为非void返回类型,则其所有退出路径必须有一个包含表达式的显式return语句\x0a%[1]s" + + "\x02[C1504][misra-c2012-17.5]: 如果函数形参被声明为数组类型,那么对应的实参必须具有适当数量的元素\x0a空指针实" + + "参用于数组类型形参\x02[C1504][misra-c2012-17.5]: 如果函数形参被声明为数组类型,那么对应的实参必须具有适当数量" + + "的元素\x0a数组大小不合适的实参被用于数组类型的形参\x02[C1504][misra-c2012-17.5]: 如果函数形参被声明为数组" + + "类型,那么对应的实参必须具有适当数量的元素\x0a%[1]s\x02[C1503][misra-c2012-17.6]: 声明数组形参时,[" + + " ]内不得包含关键字static\x02[C1502][misra-c2012-17.7]: 一个非void返回类型的函数所返回的值必须被使用" + + "\x02[C1501][misra-c2012-17.8]: 不应修改函数形参\x02[C1501][misra-c2012-17.8]: 不应" + + "修改函数形参\x02[C1509][misra-c2012-17.9]: 使用 _Noreturn 函数说明符声明的函数不应返回到其调用者" + + "\x0a%[1]s\x02[C1510][misra-c2012-17.10]: 使用 _Noreturn 函数说明符声明的函数应具有 void" + + " 返回类型\x02[C1512][misra-c2012-17.12]: 函数标识符只能与前面的 & 或带括号的参数列表一起使用\x02[C15" + + "13][misra-c2012-17.13]: 函数类型不应被类型限定\x0a%[1]s\x02[C1308][misra-c2012-18.1" + + "]: 对指针操作数进行算术运算得来的指针只得用于寻址与该指针操作数同一数组的元素\x0a%[1]s\x02[C1307][misra-c2012" + + "-18.2]: 只有寻址同一数组元素的指针之间才能进行减法运算\x0a%[1]s\x02[C1306][misra-c2012-18.3]: 大" + + "小比较运算符>,>=,<和<=不得用于两个指针类型的对象,除非这两个指针指向同一对象\x0a%[1]s\x02[C1305][misra-c" + + "2012-18.4]: +, -, +=和-=运算符不得用于指针类型的表达式\x02[C1304][misra-c2012-18.5]: 声明应" + + "含有最多两层嵌套指针\x02[C1303][misra-c2012-18.6]: 不得将自动存储对象的地址复制给在该对象不复存在后仍然存在的" + + "另一个对象\x0a%[1]s\x02[C1302][misra-c2012-18.7]: 不得声明灵活数组成员(flexible array" + + " members)\x02[C1301][misra-c2012-18.8]: 不得使用变长数组(variable-length array)" + + "\x04\x00\x01\x0aR\x02[C0302][misra-c2012-19.1]: 不得将对象赋值或复制给与其重叠的对象\x02[C" + + "0302][misra-c2012-19.1]: 不得将对象赋值或复制给与其重叠的对象\x0a%[1]s\x02[C0301][misra-c2" + + "012-19.2]: 不应使用关键字union\x02[C0114][misra-c2012-20.1]: #include指令之前只能出现只有" + + "预处理指令或注释\x02[C0113][misra-c2012-20.2]: 头文件名中不得出现字符',\x22或\\,以及/*和//字符序" + + "列\x02[C0112][misra-c2012-20.3]: #include指令后面必须是或\x22filename" + + "\x22这样的字符序列\x02[C0111][misra-c2012-20.4]: 宏名称不得与关键字重名\x02[C0110][misra-c" + + "2012-20.5]: 不得使用#undef\x02[C0109][misra-c2012-20.6]: 宏实参中不得有形似预处理指令的词符" + + "\x02[C0108][misra-c2012-20.7]: 宏形参扩展得到的表达式必须在括号内\x02[C0107][misra-c2012-" + + "20.8]: 预处理指令#if或#elif的控制表达式求值结果必须为0或1\x02[C0106][misra-c2012-20.9]: 预处理指" + + "令#if或#elif的控制表达式中的所有标识符在求值之前必须被定义(#define)\x02[C0105][misra-c2012-20.1" + + "0]: 不应使用预处理运算符#和##\x02[C0104][misra-c2012-20.11]: 如果宏形参后面紧跟#运算符,则不得再紧跟##" + + "运算符\x02[C0103][misra-c2012-20.12]: 作为#或##运算符的操作数的宏形参(其自身要进一步进行宏替换)只得作为" + + "它们的操作数使用\x02[C0102][misra-c2012-20.13]: 以#开始的代码行必须为有效预处理指令\x02[C0101][" + + "misra-c2012-20.14]: 所有预处理指令#else,#elif和#endif都必须和对应的#if,#ifdef和#ifndef指令" + + "位于同一文件中\x02[C0420][misra-c2012-21.1]: #define和#undef不得用于保留标识符(reserved" + + " identifier)或保留宏名称(reserved macro name)\x02[C0419][misra-c2012-21.2]: 不得" + + "声明保留标识符(reserved identifier)和保留宏名称(reserved macro name)\x02[C0418][mis" + + "ra-c2012-21.3]: 不得使用中的内存分配和回收(deallocation)函数\x02[C0417][misra" + + "-c2012-21.4]: 不得使用标准头文件\x02[C0416][misra-c2012-21.5]: 不得使用标准头文" + + "件\x02[C0415][misra-c2012-21.6]: 不得使用标准库输入/输出函数\x02[C0414][mi" + + "sra-c2012-21.7]: 不得使用中的标准库函数atof,atoi,atol,以及atoll函数 \x02[C041" + + "3][misra-c2012-21.8]: 不得使用中的标准库终止函数(termination function)\x02[" + + "C0412][misra-c2012-21.9]: 不得使用中的标准库函数bsearch和qsort\x02[C0411][" + + "misra-c2012-21.10]: 不得使用标准库中的时间(time)和日期(date)函数\x02[C0410][misra-c2012-" + + "21.11]: 不得使用标准头文件 \x02[C0409][misra-c2012-21.12]: 不应使用" + + "的异常处理特性\x02[C0409][misra-c2012-21.12]: 不得使用标准头文件\x02[C0408][mi" + + "sra-c2012-21.13]: 传递给函数的值必须能够表示为无符号char或EOF类型\x0a%[1]s\x02[C040" + + "7][misra-c2012-21.14]: 不得使用标准库函数memcmp比较空终止字符串(null terminated string)" + + "\x0a%[1]s\x02[C0406][misra-c2012-21.15]: 指向标准库函数memcpy,memmove和memcmp的指针" + + "实参必须全部为指向兼容类型的修饰或未修饰版本的指针\x02[C0405][misra-c2012-21.16]: 标准库函数memcmp的指" + + "针实参必须指向指针类型,或者指向基本有符号类型,基本布尔类型或基本枚举类型\x02[C0404][misra-c2012-21.17]: 使" + + "用的字符串处理函数不得产生超出指针形参引用对象边界的访问\x0a调用cstring函数可能产生超出边界的访问\x0a%[" + + "1]s\x02[C0403][misra-c2012-21.18]: 如果要将size_t实参传递给中的任意函数,则size" + + "_t实参必须具有恰当的值\x0a作为函数实参的size_t的值无效\x0a原指针对象类型: %[1]s\x0a目标对象类型: %[2]s\x0a" + + "位置: %[3]s\x02[C0403][misra-c2012-21.18]: 如果要将size_t实参传递给中的任意" + + "函数,则size_t实参必须具有恰当的值\x0a%[1]s\x02[C0402][misra-c2012-21.19]: 标准库函数loca" + + "leconv,getenv,setlocale或strerror返回的指针只得作为const修饰类型的指针使用\x0a函数的返回值被赋值给非co" + + "nst修饰类型\x0a原指针对象类型: %[1]s\x0a目标对象类型: %[2]s\x0a位置: %[3]s\x02[C0402][misra" + + "-c2012-21.19]: 标准库函数localeconv,getenv,setlocale或strerror返回的指针只得作为const修饰" + + "类型的指针使用\x0a%[1]s\x02[C0401][misra-c2012-21.20]: 标准库函数asctime,ctime,gmt" + + "ime,localtime,localeconv,getenv,setlocale或strerror返回的指针后面不得紧跟对同一函数的调用" + + "\x0a%[1]s\x02[C0421][misra-c2012-21.21]: 不得使用中的标准库函数system\x02" + + "[C0422][misra-c2012-21.22]: 在中声明的任何类型泛型宏的所有操作数参数都必须具有适当的基本类型" + + "\x0a%[1]s\x02[C0423][misra-c2012-21.23]: 在和>=\x02不得将具有(普通)char和wchar_t类型的表达式用作内置运算符的操作数,以下运算符除外:赋值运算符" + + "=、相等运算符==和!=以及一元运算符&\x02NULL不得用作整型值\x02字面量零(0)不得用作空指针常量\x02无论采取何种求值顺序(只要" + + "允许采用该顺序),表达式的值不得发生改变\x02在表达式中,应有限地依赖C++运算符优先级规则\x02不得将c值表达式隐式转换为其他底层类型" + + "\x02隐式整型转换不得改变底层类型的符号性\x02不得存在隐式的浮点-整型转换\x02隐式的整型或浮点转换不得减小底层类型\x02c值表达式不" + + "得存在显式的浮点-整型转换\x02显式的整型或浮点转换不得增大c值表达式的底层类型\x02显式的整型转换不得改变c值表达式的底层类型的符号性" + + "\x02如果对底层类型为无符号char或无符号short的操作数应用按位操作符~和<<,其结果必须立即转换为该操作数的底层类型\x02简单的ch" + + "ar类型只得用于存储和使用字符值\x02有符号char和无符号char类型只得用于存储和使用数字值\x02if语句的条件和迭代语句的条件都必须具" + + "有bool类型\x02条件运算符的第一个操作数必须为bool类型\x02指针算术只能以数组索引的形式进行\x02指针操作数,以及任何使用该操" + + "作数经过指针算术得到的指针,必须对同一数组的元素寻址\x02只能将指针相减应用于对同一数组的指针寻址\x02不得对类型为指针的对象应用>、>" + + "=、<、<=,除非它们指向同一数组\x02对象的声明不得包含超过两级的指针间接\x02二元按位运算符的非常量操作数必须具有相同的底层类型\x02" + + "按位运算符只得用于无符号底层类型的操作数\x02逻辑运算符&&或||的每个操作数都必须是后缀表达式\x02一个指向虚基类(virtual b" + + "ase class)的指针只能通过dynamic_cast的方式被转换为一个指向派生类(derived class)的指针\x02不应对多态类型" + + "(polymorphic types)进行从基类到派生类的转换\x02不得使用C风格的转换(除了void转换)和函数式记法转换(除了显式构造" + + "函数调用)\x02显式类型转换不得移除指针类型或引用类型的任何const或volatile修饰\x02显式类型转换不得将一个函数指针转换为任" + + "何其他指针类型,包括函数指针类型\x02不得直接或间接将一个具有指针类型的对象转换为不相关的指针类型\x02不得将具有整数类型或void指针" + + "类型的对象转换为具有指针类型的对象\x02显式转换不应把指针类型转换为整数类型\x02在表达式中,自增(++)和自减(--)运算符不应与其他" + + "运算符混合使用\x02不得重载逗号运算符、&&运算符和||运算符\x02作为函数实参传递的数组类型的标识符不得退化为指针\x02!运算符、逻" + + "辑运算符&&或||的每个操作数都必须是bool类型\x02一元减法运算符不得用于底层类型为无符号类型的表达式\x02不得重载一元&操作符" + + "\x02sizeof运算符的操作数的求值不得含有副作用\x02移位运算符的右操作数的范围下限为零,上限须比左操作数的底层类型的位宽度小一\x02" + + "逻辑与(&&)和逻辑或(||)运算符的右操作数不得含有副作用\x02必须保留二元运算符及其赋值运算符形式之间的语义等价\x02不得使用逗号运" + + "算符(,)\x02对无符号常量表达式进行求值不应导致回绕\x02不得在子表达式中使用赋值运算符\x02不得直接或间接地对浮点表达式进行相等性" + + "或不等性测试\x02在预处理之前,null语句只能单独一行出现;如果null语句后接的第一个字符是空格,该null语句可后接一条注释\x02" + + "构成switch、while、do...while或for语句主体的语句必须为复合语句\x02一个if(条件)结构必须后接一个复合语句;el" + + "se关键字必须后接一个复合语句或另一个if语句\x02所有if … else if结构都必须以一个else语句终止\x02switch语句必须为" + + "良构(well-formed)\x02switch标号只得出现在构成switch语句主体的复合语句的最外层\x02每个非空的switch子句" + + "都必须以一个无条件的throw或break语句终止\x02switch语句的最后一个子句必须是default子句\x02switch语句的条" + + "件不得是bool类型\x02每个switch语句至少必须有一个case子句\x02for循环中必须有且仅有一个循环计数器,该计数器不得为浮点" + + "类型\x02如果循环计数器不被--或++修改,那么在条件中,循环计数器只能作为<=、<、>或>=的操作数\x02不得在条件或语句中修改循环计" + + "数器\x02循环计数器应通过以下方式之一进行修改:--、++、-=n或+=n;其中n在循环过程中保持不变\x02不得在条件或表达式中修改循环" + + "控制变量(循环计数器除外)\x02除了在语句中被修改的循环计数器外,其他的循环控制变量应具有bool类型\x02goto语句引用的标号(la" + + "bel)必须在同一代码块或上级代码块中声明\x02goto语句只得跳转到同一函数主体中在其后声明的标号(label)\x02continue语句" + + "只能在为良构(well-formed)的for循环中使用\x02对于任何迭代语句,用于终止循环的break或goto语句不得超过一个\x02" + + "函数结尾必须有且仅有一个退出点\x02不修改的变量必须使用const修饰\x02如果函数形参不被修改,那么必须将相对应的形参的指针或引用声明" + + "为const指针或const引用\x02具有enum底层类型的表达式只应包含与枚举的枚举器对应的值\x02全局命名空间只得包含main、命名" + + "空间声明和extern “C”声明\x02标识符main不得用于除全局函数main之外的函数\x02头文件中不得存在未命名的命名空间\x02" + + "不得使用using指令\x02同一命名空间中对一个标识符的多个声明不得跨越该标识符的using声明\x02不得在头文件中使用using指令或" + + "using声明(不包括类作用域或函数作用域的using声明)\x02所有汇编器的使用必须有文档记录\x02只能使用asm声明引入汇编器指令(as" + + "sembler instructions)\x02必须独立封装汇编语言\x02函数不应返回在该函数中定义的自动变量(包括形参)的引用或指针" + + "\x02不得将自动存储对象的地址赋给在该对象不复存在后仍然可能存在的另一个对象\x02如果一个形参是通过引用或const引用传递的,那么函数不得" + + "返回该形参的引用或指针\x02函数不应直接或间接调用自身\x02初始化声明符列表(init-declarator-list)必须由一个初始化" + + "声明符组成;成员声明符列表(member-declarator-list)必须由一个成员声明符组成\x02覆盖虚拟函数中的形参必须使用与被它" + + "们覆盖的函数相同的默认实参,否则不得指定任何默认实参\x02不得使用省略号定义函数\x02函数的重新声明中用作形参的标识符必须与原声明中的标" + + "识符相同\x02返回非void类型的函数的所有退出路径都必须具有包含表达式的显式return语句\x02函数标识符必须用来调用该函数,否则必" + + "须加上前缀“&”\x02所有变量在使用前都必须先定义一个值\x02数组和结构体进行非零初始化时,必须使用大括号来指示和匹配结构\x02枚举器" + + "列表中,不得将=结构用于显式初始化非首位成员之外的成员,除非所有的项都被显式初始化\x02const成员函数不得返回对 *类数据* 的非co" + + "nst指针或引用\x02成员函数不得返回指向类数据的非const句柄\x02如果一个成员函数可以是静态的,那么就必须将其设为静态,否则,如果该函" + + "数可以是const的,那么就必须将其设为const\x02不得使用联合体\x02需要对代表一个位域的位进行绝对定位时,必须记录位域的行为和包" + + "装\x02位域必须是bool类型,或显式无符号或有符号整数类型\x02位域不得具有enum类型\x02已命名的有符号整数类型的位域长度必须超" + + "过一位\x02不应通过虚拟基来派生类\x02只有在用于菱形层次结构(diamond hierarchy)时,才能声明一个基类为虚拟基类" + + "\x02可访问基类在同一层次结构中不能同时为虚基类和非虚基类\x02在一个多重继承层次结构中,所有可访问的实体名称都应该是唯一的\x02在整个继" + + "承层次结构中,每个虚拟函数在每个路径中的定义不应超过一个\x02每个覆盖虚拟函数都必须用关键字virtual来声明\x02如果虚拟函数被声明" + + "为纯虚函数,则该虚拟函数只应被纯虚函数覆盖\x02在非POD类中,成员数据必须是私有的\x02不得在一个对象的构造函数或析构函数的主体中使用" + + "该对象的动态类型\x02所有类构造函数都应明确地调用它们所有直接基类和虚拟基类的构造函数\x02所有可以通过一个基本类型的实参来调用的构造函" + + "数都必须被显式声明\x02复制构造函数(copy constructor)只得用来初始化它的基类以及本类的非静态成员\x02在抽象类中,复制" + + "赋值运算符必须被声明为受保护的(protected)或私有的(private)\x02非成员泛型函数只能在不是关联命名空间(associat" + + "ed namespace)的命名空间中声明\x02如果模板构造函数只有一个形参,且为泛型形参,那么必须声明一个复制构造函数\x02如果模板赋值运" + + "算符有一个泛型形参,那么必须声明一个复制赋值运算符\x02在一个有依赖基的类模板中,必须使用被修饰的标识符或this->来引用任何可能在该依" + + "赖基中查找到的名称\x02通过重载解析选择的函数必须被解析为翻译单元中先前声明的函数\x02所有类模板、函数模板、类模板成员函数和类模板静态" + + "成员至少必须被实例化一次\x02对于任何给定的模板专门化,使用专门化的模板实参对该模板进行显式实例化,不得导致程序非良构(ill-forme" + + "d)\x02模板的所有部分专门化和显式专门化的声明必须与主模板的声明在同一文件\x02重载的函数模板不得被显式专门化\x02对函数调用可行的函数" + + "集不应包含任何函数专门化,或者应只包含函数函数专门化\x02异常只得用于错误处理\x02异常对象不应具有指针类型\x02不得使用goto或s" + + "witch语句将控制权转移到try或catch块中\x02throw语句的赋值表达式本身不得导致抛出异常\x02不得显式抛出NULL\x02空的" + + "抛出(throw;)只得在捕获(catch)处理程序的复合语句中使用\x02只有程序启动后和终止前才能报告异常\x02至少应该有一个异常处理" + + "程序来捕获所有未经处理的异常\x02对于类构造函数或类析构函数,其函数尝试块实现的处理程序不得引用该类或其基类的非静态成员\x02对于在代码" + + "中显式抛出的每个异常,在所有可能导致该异常的调用路径上,都必须有一个兼容类型的处理程序\x02必须始终通过引用来捕获类类型的异常\x02如果" + + "在一个尝试捕获(try-catch)语句或函数尝试块中,为一个派生类以及它的部分或全部基类提供了多个处理程序,那么应按从最终派生类到基类的顺" + + "序排列这些处理程序\x02如果在一个尝试捕获语句或函数尝试块中提供了多个处理程序,那么所有省略号(catch-all)处理程序必须在最后发生" + + "\x02如果一个函数与异常说明(exception-specification)一起声明,那么该函数在其他翻译单元中的所有声明必须以相同的类型标" + + "识(type-id)集声明\x02一个类析构函数不得随着异常退出\x02当函数的声明包含一个异常说明时,该函数只能抛出指定类型的异常\x02" + + "不得隐式调用terminate()函数\x02文件中的#include指令之前只能是其他预处理指令或注释\x02只能在全局命名空间中对宏进行" + + "#define和#undef\x02不得使用#undef\x02不得定义类函数宏\x02传递给类函数宏的实参不得包含形似预处理指令的标记\x02" + + "在定义类函数宏时,每个实参的实例都必须以小括号括起来,除非它们是#或##的操作数\x02未定义的宏标识符不得用于#if和#elif预处理指令" + + ",除非是作为defined预处理运算符的操作数\x02如果#标识符是行中的第一个标记,则其后应紧接预处理标识符\x02defined预处理运" + + "算符只能使用两种标准形式之一\x02所有的 #else、#elif 和 #endif 预处理指令必须都必须和对应的 #if 或 #ifdef" + + " 指令位于同一文件中\x02预处理器只得用于文件包含和#include防范(include guard)\x02C++的宏只得用于#includ" + + "e防范、类型限定符或存储类标识符\x02必须提供#include防范\x02头文件名称里不得出现'、\x22、/*或//字符\x02头文件名称里" + + "不能出现\\字符\x02#include 预处理指令必须后接或\x22filename\x22\x02在一个宏定义中最多" + + "只得出现一个#或##预处理器运算符\x02不应使用#或##预处理器运算符\x02必须记录所有#pragma指令的使用\x02标准库中保留的标" + + "识符、宏和函数不得被定义、重定义或取消定义\x02不得重复使用标准库中宏和对象的名字\x02不得重写标准库中函数的名称\x02所有库代码必须" + + "遵守MISRA C++规则\x02不得使用setjmp宏和longjmp函数\x02不得使用C标准库\x02不得使用库中的" + + "函数atof、atoi 和 atol\x02不得使用库中的函数 abort、exit、getenv 和 system" + + "\x02不得使用库中的时间处理函数\x02不得使用库中的无界函数\x02不得使用宏offsetof\x02不得使" + + "用动态堆内存分配\x02不得使用中的信号处理功能\x02不得使用错误指示器errno\x02不得使用输入/输出流库\x02C代码行数%[1]d\x02C++代码行数%[1]d\x02头文件行数%[1]d\x02并发数%[1]d\x02开始准备CTU信" + + "息\x02CTU信息准备完成 [%[1]s]\x02开始准备STU信息\x02STU信息准备完成%[1]s (%[2]v/%[3]v)" + + "\x02STU信息准备完成 [%[1]s]\x02分析完成 [%[1]s]\x02BuildAction准备完成%[1]s (%[2]v/%[3" + + "]v)\x02BuildAction准备完成 [%[1]s]\x02CTU信息开始生成\x02CTU信息生成%[1]s (%[2]v/%[3]v" + + ")\x02CTU信息生成成功 [%[1]s]\x02CTU信息开始写入\x02CTU信息写入完成 [%[1]s]" + + // Total table size 121641 bytes (118KiB); checksum: 8F3945E2 diff --git a/misra/analyzer/cmd/locales/en/messages.gotext.json b/misra/analyzer/cmd/locales/en/messages.gotext.json index a715da1687..e82a8bc1d7 100644 --- a/misra/analyzer/cmd/locales/en/messages.gotext.json +++ b/misra/analyzer/cmd/locales/en/messages.gotext.json @@ -163,8 +163,8 @@ "fuzzy": true }, { - "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Name}{StructMemberCount}{StructMemberLimit}", - "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Name}{StructMemberCount}{StructMemberLimit}", + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER{Name}{StructMemberCount}{StructMemberLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER{Name}{StructMemberCount}{StructMemberLimit}", "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many members in structure '{Name}': {StructMemberCount}. The limit is {StructMemberLimit}. ", "translatorComment": "Copied from source.", "placeholders": [ @@ -195,6 +195,649 @@ ], "fuzzy": true }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM{Name}{FunctionParmCount}{FunctionParmLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM{Name}{FunctionParmCount}{FunctionParmLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many parameters in function definition '{Name}': {FunctionParmCount}. The limit is {FunctionParmLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "FunctionParmCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.FunctionParmCount" + }, + { + "id": "FunctionParmLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.FunctionParmLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG{Name}{FunctionArgCount}{FunctionArgLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG{Name}{FunctionArgCount}{FunctionArgLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many arguments in function call '{Name}': {FunctionArgCount}. The limit is {FunctionArgLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "FunctionArgCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.FunctionArgCount" + }, + { + "id": "FunctionArgLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.FunctionArgLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD{Name}{NestedRecordCount}{NestedRecordLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD{Name}{NestedRecordCount}{NestedRecordLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many levels of nested structure or union definitions in a single struct-declaration-list '{Name}': {NestedRecordCount}. The limit is {NestedRecordLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedRecordCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedRecordCount" + }, + { + "id": "NestedRecordLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedRecordLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR{Name}{NestedExprCount}{NestedExprLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR{Name}{NestedExprCount}{NestedExprLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many nesting levels of parenthesized expressions within a full expression '{Name}': {NestedExprCount}. The limit is {NestedExprLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedExprCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedExprCount" + }, + { + "id": "NestedExprLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedExprLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE{Name}{SwitchCaseCount}{SwitchCaseLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE{Name}{SwitchCaseCount}{SwitchCaseLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many case labels for a switch statement '{Name}': {SwitchCaseCount}. The limit is {SwitchCaseLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "SwitchCaseCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.SwitchCaseCount" + }, + { + "id": "SwitchCaseLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.SwitchCaseLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT{Name}{EnumConstantCount}{EnumConstantLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT{Name}{EnumConstantCount}{EnumConstantLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many enumeration constants in a single enumeration '{Name}': {EnumConstantCount}. The limit is {EnumConstantLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "EnumConstantCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.EnumConstantCount" + }, + { + "id": "EnumConstantLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.EnumConstantLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR{Name}{StringCharCount}{StringCharLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR{Name}{StringCharCount}{StringCharLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many characters in a string literal '{Name}': {StringCharCount}. The limit is {StringCharLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "StringCharCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.StringCharCount" + }, + { + "id": "StringCharLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.StringCharLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID{Name}{ExternIdCount}{ExternIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID{Name}{ExternIdCount}{ExternIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many external identifiers in one translation unit '{Name}': {ExternIdCount}. The limit is {ExternIdLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "ExternIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.ExternIdCount" + }, + { + "id": "ExternIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.ExternIdLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Kind}: {Name}\nFirst identifier location: {Loc}\nDuplicated identifier '{ExternalMessage}' location: {OtherLoc}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Kind}: {Name}\nFirst identifier location: {Loc}\nDuplicated identifier '{ExternalMessage}' location: {OtherLoc}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits (The identifiers '{Name}' and '{ExternalMessage}' at {Loc} and {OtherLoc} are not distinct)", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Kind", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Kind" + }, + { + "id": "Name", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.Name" + }, + { + "id": "Loc", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.Loc" + }, + { + "id": "ExternalMessage", + "string": "%[4]s", + "type": "string", + "underlyingType": "string", + "argNum": 4, + "expr": "result.ExternalMessage" + }, + { + "id": "OtherLoc", + "string": "%[5]s", + "type": "string", + "underlyingType": "string", + "argNum": 5, + "expr": "result.OtherLoc" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID{Name}{MacroIdCount}{MacroIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID{Name}{MacroIdCount}{MacroIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many macro identifiers simultaneously defined in one preprocessing translation unit '{Name}': {MacroIdCount}. The limit is {MacroIdLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroIdCount" + }, + { + "id": "MacroIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroIdLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM{Name}{MacroParmCount}{MacroParmLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM{Name}{MacroParmCount}{MacroParmLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many parameters in one macro definition '{Name}': {MacroParmCount}. The limit is {MacroParmLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroParmCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroParmCount" + }, + { + "id": "MacroParmLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroParmLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG{Name}{MacroArgCount}{MacroArgLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG{Name}{MacroArgCount}{MacroArgLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many arguments in one macro invocation '{Name}': {MacroArgCount}. The limit is {MacroArgLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroArgCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroArgCount" + }, + { + "id": "MacroArgLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroArgLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK{Name}{NestedBlockCount}{NestedBlockLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK{Name}{NestedBlockCount}{NestedBlockLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many nesting levels of blocks '{Name}': {NestedBlockCount}. The limit is {NestedBlockLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedBlockCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedBlockCount" + }, + { + "id": "NestedBlockLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedBlockLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE{Name}{NestedIncludeCount}{NestedIncludeLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE{Name}{NestedIncludeCount}{NestedIncludeLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many nesting levels for #included files '{Name}': {NestedIncludeCount}. The limit is {NestedIncludeLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedIncludeCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedIncludeCount" + }, + { + "id": "NestedIncludeLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedIncludeLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR{Name}{IomIdCharCount}{IomIdCharLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR{Name}{IomIdCharCount}{IomIdCharLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many significant initial characters in an internal identifier or a macro name '{Name}': {IomIdCharCount}. The limit is {IomIdCharLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "IomIdCharCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.IomIdCharCount" + }, + { + "id": "IomIdCharLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.IomIdCharLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU{Name}{NestedCondIncluCount}{NestedCondIncluLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU{Name}{NestedCondIncluCount}{NestedCondIncluLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many nesting levels of conditional inclusion '{Name}': {NestedCondIncluCount}. The limit is {NestedCondIncluLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedCondIncluCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedCondIncluCount" + }, + { + "id": "NestedCondIncluLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedCondIncluLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID{Name}{BlockIdCount}{BlockIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID{Name}{BlockIdCount}{BlockIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many identifiers with block scope declared in one block '{Name}': {BlockIdCount}. The limit is {BlockIdLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "BlockIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.BlockIdCount" + }, + { + "id": "BlockIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.BlockIdLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL{Name}{NestedDeclCount}{NestedDeclLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL{Name}{NestedDeclCount}{NestedDeclLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many nesting levels of parenthesized declarators within a full declarator '{Name}': {NestedDeclCount}. The limit is {NestedDeclLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedDeclCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedDeclCount" + }, + { + "id": "NestedDeclLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedDeclLimit" + } + ], + "fuzzy": true + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL{Name}{ModifyDeclCount}{ModifyDeclLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL{Name}{ModifyDeclCount}{ModifyDeclLimit}", + "translation": "[C2201][misra-c2012-1.1]: Violation of MISRA C:2012 Rule 1.1: The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits\nToo many pointer, array, and function declarators (in any combinations) modifying an arithmetic, structure, union, or void type in a declaration '{Name}': {ModifyDeclCount}. The limit is {ModifyDeclLimit}. ", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "ModifyDeclCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.ModifyDeclCount" + }, + { + "id": "ModifyDeclLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.ModifyDeclLimit" + } + ], + "fuzzy": true + }, { "id": "[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n{ExternalMessage}", "message": "[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n{ExternalMessage}", @@ -614,6 +1257,13 @@ "translatorComment": "Copied from source.", "fuzzy": true }, + { + "id": "[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3", + "message": "[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3", + "translation": "[C0703][misra-c2012-6.3]: Violation of MISRA C:2012 Rule 6.3: A bit field shall not be declared as a member of a union", + "translatorComment": "Copied from source.", + "fuzzy": true + }, { "id": "[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1", "message": "[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1", @@ -676,6 +1326,23 @@ ], "fuzzy": true }, + { + "id": "[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n{ExternalMessage}", + "message": "[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n{ExternalMessage}", + "translation": "[C0905][misra-c2012-7.5]: Violation of MISRA C:2012 Rule 7.5: The argument of an integer constant macro shall have an appropriate form: {ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, { "id": "[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n{ExternalMessage}", "message": "[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n{ExternalMessage}", @@ -1100,6 +1767,37 @@ "translatorComment": "Copied from source.", "fuzzy": true }, + { + "id": "[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n{ExternalMessage}", + "message": "[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n{ExternalMessage}", + "translation": "[C0515][misra-c2012-8.15]: Violation of MISRA C:2012 Rule 8.15: All declarations of an object with an explicit alignment specification shall specify the same alignment: {ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, + { + "id": "[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16", + "message": "[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16", + "translation": "[C0516][misra-c2012-8.16]: Violation of MISRA C:2012 Rule 8.16: The alignment specification of zero should not appear in an object declaration", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17", + "message": "[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17", + "translation": "[C0517][misra-c2012-8.17]: Violation of MISRA C:2012 Rule 8.17: At most one explicit alignment specifier should appear in an object declaration", + "translatorComment": "Copied from source.", + "fuzzy": true + }, { "id": "[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n{ExternalMessage}", "message": "[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n{ExternalMessage}", @@ -2194,6 +2892,54 @@ "translatorComment": "Copied from source.", "fuzzy": true }, + { + "id": "[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n{ExternalMessage}", + "message": "[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n{ExternalMessage}", + "translation": "[C1509][misra-c2012-17.9]: Violation of MISRA C:2012 Rule 17.9: A function declared with a _Noreturn function specifier shall not return to its caller\n{ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, + { + "id": "[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10", + "message": "[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10", + "translation": "[C1510][misra-c2012-17.10]: Violation of MISRA C:2012 Rule 17.10: A function declared with a _Noreturn function specifier shall have void return type", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12", + "message": "[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12", + "translation": "[C1512][misra-c2012-17.12]: Violation of MISRA C:2012 Rule 17.12: A function identifier should only be used with either a preceding \u0026, or with a parenthesized parameter list", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n{ExternalMessage}", + "message": "[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n{ExternalMessage}", + "translation": "[C1513][misra-c2012-17.13]: Violation of MISRA C:2012 Rule 17.13: A function type shall not be type qualified\n{ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, { "id": "[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n{ExternalMessage}", "message": "[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n{ExternalMessage}", @@ -2503,6 +3249,13 @@ "translatorComment": "Copied from source.", "fuzzy": true }, + { + "id": "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3", + "message": "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3", + "translation": "[C0409][misra-c2012-21.12]: Violation of MISRA C:2012 Rule 21.12: The standard header file \u003cfenv.h\u003e shall not be used", + "translatorComment": "Copied from source.", + "fuzzy": true + }, { "id": "[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n{ExternalMessage}", "message": "[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n{ExternalMessage}", @@ -2692,6 +3445,37 @@ "translatorComment": "Copied from source.", "fuzzy": true }, + { + "id": "[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n{ExternalMessage}", + "message": "[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n{ExternalMessage}", + "translation": "[C0422][misra-c2012-21.22]: Violation of MISRA C:2012 Rule 21.22: All operand arguments to any type-generic macros declared in \u003ctgmath.h\u003c shall have an appropriate essential type: {ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, + { + "id": "[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23", + "message": "[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23", + "translation": "[C0423][misra-c2012-21.23]: Violation of MISRA C:2012 Rule 21.23: All operand arguments to any multi-argument type-generic macros declared in \u003ctgmath.h\u003c shall have the same standard type", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24", + "message": "[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24", + "translation": "[C0424][misra-c2012-21.24]: Violation of MISRA C:2012 Rule 21.24: The random number generator functions of \u003cstdlib.h\u003c shall not be used", + "translatorComment": "Copied from source.", + "fuzzy": true + }, { "id": "[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n{ExternalMessage}", "message": "[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n{ExternalMessage}", @@ -2862,6 +3646,51 @@ ], "fuzzy": true }, + { + "id": "[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1", + "message": "[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1", + "translation": "[C2401][misra-c2012-23.1]: Violation of MISRA C:2012 Rule 23.1: A generic selection should only be expanded from a macro", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2", + "message": "[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2", + "translation": "[C2402][misra-c2012-23.2]: Violation of MISRA C:2012 Rule 23.2: A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3", + "message": "[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3", + "translation": "[C2403][misra-c2012-23.3]: Violation of MISRA C:2012 Rule 23.3: A generic selection should contain at least one non-default association", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n{ExternalMessage}", + "message": "[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n{ExternalMessage}", + "translation": "[C2404][misra-c2012-23.4]: Violation of MISRA C:2012 Rule 23.4: A generic association shall list an appropriate type: {ExternalMessage}", + "translatorComment": "Copied from source.", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ], + "fuzzy": true + }, + { + "id": "[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5", + "message": "[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5", + "translation": "[C2405][misra-c2012-23.5]: Violation of MISRA C:2012 Rule 23.5: A generic selection should not depend on implicit pointer type conversion", + "translatorComment": "Copied from source.", + "fuzzy": true + }, { "id": "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated", "message": "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated", @@ -4796,9 +5625,9 @@ "fuzzy": true }, { - "id": "Starting generating CTU infomation", - "message": "Starting generating CTU infomation", - "translation": "Starting generating CTU infomation", + "id": "Starting generating CTU information", + "message": "Starting generating CTU information", + "translation": "Starting generating CTU information", "translatorComment": "Copied from source.", "fuzzy": true }, diff --git a/misra/analyzer/cmd/locales/zh/messages.gotext.json b/misra/analyzer/cmd/locales/zh/messages.gotext.json index ba2ca6f83c..89f08a1069 100644 --- a/misra/analyzer/cmd/locales/zh/messages.gotext.json +++ b/misra/analyzer/cmd/locales/zh/messages.gotext.json @@ -145,8 +145,8 @@ ] }, { - "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Name}{StructMemberCount}{StructMemberLimit}", - "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Name}{StructMemberCount}{StructMemberLimit}", + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER{Name}{StructMemberCount}{StructMemberLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRUCT_MEMBER{Name}{StructMemberCount}{StructMemberLimit}", "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n结构体 {Name} 中定义了 {StructMemberCount} 个成员,超过限制数 {StructMemberLimit}", "placeholders": [ { @@ -175,6 +175,611 @@ } ] }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM{Name}{FunctionParmCount}{FunctionParmLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_PARM{Name}{FunctionParmCount}{FunctionParmLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n函数 {Name} 中定义了 {FunctionParmCount} 个参数,超过限制数 {FunctionParmLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "FunctionParmCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.FunctionParmCount" + }, + { + "id": "FunctionParmLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.FunctionParmLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG{Name}{FunctionArgCount}{FunctionArgLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nFUNCTION_ARG{Name}{FunctionArgCount}{FunctionArgLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n函数调用 {Name} 中使用了了 {FunctionArgCount} 个形参,超过限制数 {FunctionArgLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "FunctionArgCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.FunctionArgCount" + }, + { + "id": "FunctionArgLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.FunctionArgLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD{Name}{NestedRecordCount}{NestedRecordLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_RECORD{Name}{NestedRecordCount}{NestedRecordLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n单个结构声明列表中的嵌套结构或联合定义的层数{NestedRecordCount} 超过限制数 {NestedRecordLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedRecordCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedRecordCount" + }, + { + "id": "NestedRecordLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedRecordLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR{Name}{NestedExprCount}{NestedExprLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_EXPR{Name}{NestedExprCount}{NestedExprLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n完整表达式 {Name} 中括号表达式的嵌套层数{NestedExprCount} 超过限制数 {NestedExprLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedExprCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedExprCount" + }, + { + "id": "NestedExprLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedExprLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE{Name}{SwitchCaseCount}{SwitchCaseLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSWITCH_CASE{Name}{SwitchCaseCount}{SwitchCaseLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\nswitch语句中的case标签数{SwitchCaseCount} 超过限制数 {SwitchCaseLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "SwitchCaseCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.SwitchCaseCount" + }, + { + "id": "SwitchCaseLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.SwitchCaseLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT{Name}{EnumConstantCount}{EnumConstantLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nENUM_CONSTANT{Name}{EnumConstantCount}{EnumConstantLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n单个枚举 {Name} 中的枚举常量{EnumConstantCount} 超过限制数 {EnumConstantLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "EnumConstantCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.EnumConstantCount" + }, + { + "id": "EnumConstantLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.EnumConstantLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR{Name}{StringCharCount}{StringCharLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nSTRING_CHAR{Name}{StringCharCount}{StringCharLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n单个字符串字面量 {Name} 中的字符数量{StringCharCount} 超过限制数 {StringCharLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "StringCharCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.StringCharCount" + }, + { + "id": "StringCharLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.StringCharLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID{Name}{ExternIdCount}{ExternIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nEXTERN_ID{Name}{ExternIdCount}{ExternIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n一个翻译单元中的外部标识符数量{ExternIdCount} 超过限制数 {ExternIdLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "ExternIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.ExternIdCount" + }, + { + "id": "ExternIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.ExternIdLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Kind}: {Name}\nFirst identifier location: {Loc}\nDuplicated identifier '{ExternalMessage}' location: {OtherLoc}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\n{Kind}: {Name}\nFirst identifier location: {Loc}\nDuplicated identifier '{ExternalMessage}' location: {OtherLoc}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n{Kind}: {Name}\n位置: {Loc}\n重复的标识符'{ExternalMessage}'位置: {OtherLoc}", + "placeholders": [ + { + "id": "Kind", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Kind" + }, + { + "id": "Name", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.Name" + }, + { + "id": "Loc", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.Loc" + }, + { + "id": "ExternalMessage", + "string": "%[4]s", + "type": "string", + "underlyingType": "string", + "argNum": 4, + "expr": "result.ExternalMessage" + }, + { + "id": "OtherLoc", + "string": "%[5]s", + "type": "string", + "underlyingType": "string", + "argNum": 5, + "expr": "result.OtherLoc" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID{Name}{MacroIdCount}{MacroIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ID{Name}{MacroIdCount}{MacroIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n在一个预处理翻译单元中同时定义的宏标识符数{MacroIdCount} 超过限制数 {MacroIdLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroIdCount" + }, + { + "id": "MacroIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroIdLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM{Name}{MacroParmCount}{MacroParmLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_PARM{Name}{MacroParmCount}{MacroParmLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n一个宏定义 {Name} 中的参数数量{MacroParmCount} 超过限制数 {MacroParmLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroParmCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroParmCount" + }, + { + "id": "MacroParmLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroParmLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG{Name}{MacroArgCount}{MacroArgLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMACRO_ARG{Name}{MacroArgCount}{MacroArgLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n一次宏调用 {Name} 中的参数数量{MacroArgCount} 超过限制数 {MacroArgLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "MacroArgCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.MacroArgCount" + }, + { + "id": "MacroArgLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.MacroArgLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK{Name}{NestedBlockCount}{NestedBlockLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_BLOCK{Name}{NestedBlockCount}{NestedBlockLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n块的嵌套层数{NestedBlockCount} 超过限制数 {NestedBlockLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedBlockCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedBlockCount" + }, + { + "id": "NestedBlockLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedBlockLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE{Name}{NestedIncludeCount}{NestedIncludeLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_INCLUDE{Name}{NestedIncludeCount}{NestedIncludeLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n#include文件嵌套层数{NestedIncludeCount} 超过限制数 {NestedIncludeLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedIncludeCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedIncludeCount" + }, + { + "id": "NestedIncludeLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedIncludeLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR{Name}{IomIdCharCount}{IomIdCharLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nIOM_ID_CHAR{Name}{IomIdCharCount}{IomIdCharLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n内部标识符或宏名称 {Name} 中的有效初始字符数{IomIdCharCount} 超过限制数 {IomIdCharLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "IomIdCharCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.IomIdCharCount" + }, + { + "id": "IomIdCharLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.IomIdCharLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU{Name}{NestedCondIncluCount}{NestedCondIncluLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_COND_INCLU{Name}{NestedCondIncluCount}{NestedCondIncluLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n条件包含的嵌套深度{NestedCondIncluCount} 超过限制数 {NestedCondIncluLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedCondIncluCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedCondIncluCount" + }, + { + "id": "NestedCondIncluLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedCondIncluLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID{Name}{BlockIdCount}{BlockIdLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nBLOCK_ID{Name}{BlockIdCount}{BlockIdLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n在一个块中声明具有块作用域的标识符数量{BlockIdCount} 超过限制数 {BlockIdLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "BlockIdCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.BlockIdCount" + }, + { + "id": "BlockIdLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.BlockIdLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL{Name}{NestedDeclCount}{NestedDeclLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nNESTED_DECL{Name}{NestedDeclCount}{NestedDeclLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n完整声明符 {Name} 中括号声明符的嵌套深度{NestedDeclCount} 超过限制数 {NestedDeclLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "NestedDeclCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.NestedDeclCount" + }, + { + "id": "NestedDeclLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.NestedDeclLimit" + } + ] + }, + { + "id": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL{Name}{ModifyDeclCount}{ModifyDeclLimit}", + "message": "[C2201][misra-c2012-1.1]: violation of misra-c2012-1.1\nMODIFY_DECL{Name}{ModifyDeclCount}{ModifyDeclLimit}", + "translation": "[C2201][misra-c2012-1.1]: 程序不得违反C语言标准语法和约束,不得超出实现的翻译限制\n指针、数组和函数声明符(任意组合)修改声明 {Name} 中的算术、结构、联合或 void 类型的数量{ModifyDeclCount} 超过限制数 {ModifyDeclLimit}", + "placeholders": [ + { + "id": "Name", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.Name" + }, + { + "id": "ModifyDeclCount", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "result.ModifyDeclCount" + }, + { + "id": "ModifyDeclLimit", + "string": "%[3]s", + "type": "string", + "underlyingType": "string", + "argNum": 3, + "expr": "result.ModifyDeclLimit" + } + ] + }, { "id": "[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n{ExternalMessage}", "message": "[C2203][misra-c2012-1.3]: violation of misra-c2012-1.3\n{ExternalMessage}", @@ -540,6 +1145,11 @@ "message": "[C0701][misra-c2012-6.2]: violation of misra-c2012-6.2", "translation": "[C0701][misra-c2012-6.2]: 一个一位的已命名位域不得为有符号类型" }, + { + "id": "[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3", + "message": "[C0703][misra-c2012-6.3]: violation of misra-c2012-6.3", + "translation": "[C0703][misra-c2012-6.3]: 位字段不得声明为联合体的成员" + }, { "id": "[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1", "message": "[C0904][misra-c2012-7.1]: violation of misra-c2012-7.1", @@ -590,6 +1200,21 @@ } ] }, + { + "id": "[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n{ExternalMessage}", + "message": "[C0905][misra-c2012-7.5]: violation of misra-c2012-7.5\n{ExternalMessage}", + "translation": "[C0905][misra-c2012-7.5]: 整型常量宏的参数应具有适当的形式\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, { "id": "[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n{ExternalMessage}", "message": "[C0514][misra-c2012-8.1]: violation of misra-c2012-8.1\n{ExternalMessage}", @@ -970,6 +1595,31 @@ "message": "[C0501][misra-c2012-8.14]: violation of misra-c2012-8.14", "translation": "[C0501][misra-c2012-8.14]: 不得使用restrict类型修饰符 " }, + { + "id": "[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n{ExternalMessage}", + "message": "[C0515][misra-c2012-8.15]: violation of misra-c2012-8.15\n{ExternalMessage}", + "translation": "[C0515][misra-c2012-8.15]: 具有显式对齐规范的对象的所有声明都应指定相同的对齐方式\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, + { + "id": "[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16", + "message": "[C0516][misra-c2012-8.16]: violation of misra-c2012-8.16", + "translation": "[C0516][misra-c2012-8.16]: 零对齐规范不应出现在对象声明中" + }, + { + "id": "[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17", + "message": "[C0517][misra-c2012-8.17]: violation of misra-c2012-8.17", + "translation": "[C0517][misra-c2012-8.17]: 对象声明中最多应出现一个显式对齐说明符" + }, { "id": "[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n{ExternalMessage}", "message": "[C1205][misra-c2012-9.1]: violation of misra-c2012-9.1\n{ExternalMessage}", @@ -1904,6 +2554,46 @@ "message": "[C1501][misra-c2012-17.8]: parameters should not be modified", "translation": "[C1501][misra-c2012-17.8]: 不应修改函数形参" }, + { + "id": "[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n{ExternalMessage}", + "message": "[C1509][misra-c2012-17.9]: violation of misra-c2012-17.9\n{ExternalMessage}", + "translation": "[C1509][misra-c2012-17.9]: 使用 _Noreturn 函数说明符声明的函数不应返回到其调用者\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, + { + "id": "[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10", + "message": "[C1510][misra-c2012-17.10]: violation of misra-c2012-17.10", + "translation": "[C1510][misra-c2012-17.10]: 使用 _Noreturn 函数说明符声明的函数应具有 void 返回类型" + }, + { + "id": "[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12", + "message": "[C1512][misra-c2012-17.12]: violation of misra-c2012-17.12", + "translation": "[C1512][misra-c2012-17.12]: 函数标识符只能与前面的 \u0026 或带括号的参数列表一起使用" + }, + { + "id": "[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n{ExternalMessage}", + "message": "[C1513][misra-c2012-17.13]: violation of misra-c2012-17.13\n{ExternalMessage}", + "translation": "[C1513][misra-c2012-17.13]: 函数类型不应被类型限定\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, { "id": "[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n{ExternalMessage}", "message": "[C1308][misra-c2012-18.1]: Pointer arithmetic may cause array out of bound.\n{ExternalMessage}", @@ -2139,6 +2829,11 @@ "message": "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12", "translation": "[C0409][misra-c2012-21.12]: 不应使用\u003cfenv.h\u003e的异常处理特性" }, + { + "id": "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3", + "message": "[C0409][misra-c2012-21.12]: violation of misra-c2012-21.12-amd3", + "translation": "[C0409][misra-c2012-21.12]: 不得使用标准头文件\u003cfenv.h\u003e" + }, { "id": "[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n{ExternalMessage}", "message": "[C0408][misra-c2012-21.13]: violation of misra-c2012-21.13\n{ExternalMessage}", @@ -2306,6 +3001,31 @@ "message": "[C0421][misra-c2012-21.21]: violation of misra-c2012-21.21", "translation": "[C0421][misra-c2012-21.21]: 不得使用\u003cstdlib.h\u003e中的标准库函数system" }, + { + "id": "[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n{ExternalMessage}", + "message": "[C0422][misra-c2012-21.22]: violation of misra-c2012-21.22\n{ExternalMessage}", + "translation": "[C0422][misra-c2012-21.22]: 在\u003ctgmath.h\u003e中声明的任何类型泛型宏的所有操作数参数都必须具有适当的基本类型\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, + { + "id": "[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23", + "message": "[C0423][misra-c2012-21.23]: violation of misra-c2012-21.23", + "translation": "[C0423][misra-c2012-21.23]: 在\u003ctgmath.h\u003c中声明的任何多参数类型泛型宏的所有操作数参数必须具有相同的标准类型" + }, + { + "id": "[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24", + "message": "[C0424][misra-c2012-21.24]: violation of misra-c2012-21.24", + "translation": "[C0424][misra-c2012-21.24]: 不能使用\u003cstdlib.h\u003c的随机数生成器函数" + }, { "id": "[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n{ExternalMessage}", "message": "[C0210][misra-c2012-22.1]: violation of misra-c2012-22.1\n{ExternalMessage}", @@ -2456,6 +3176,41 @@ } ] }, + { + "id": "[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1", + "message": "[C2401][misra-c2012-23.1]: violation of misra-c2012-23.1", + "translation": "[C2401][misra-c2012-23.1]: 通用选择只能从宏扩展" + }, + { + "id": "[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2", + "message": "[C2402][misra-c2012-23.2]: violation of misra-c2012-23.2", + "translation": "[C2402][misra-c2012-23.2]: 未从宏扩展的通用选择不应在控制表达式中包含潜在的副作用" + }, + { + "id": "[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3", + "message": "[C2403][misra-c2012-23.3]: violation of misra-c2012-23.3", + "translation": "[C2403][misra-c2012-23.3]: 通用选择应至少包含一个非默认关联" + }, + { + "id": "[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n{ExternalMessage}", + "message": "[C2404][misra-c2012-23.4]: violation of misra-c2012-23.4\n{ExternalMessage}", + "translation": "[C2404][misra-c2012-23.4]: 通用关联应列出适当的类型\n{ExternalMessage}", + "placeholders": [ + { + "id": "ExternalMessage", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "result.ExternalMessage" + } + ] + }, + { + "id": "[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5", + "message": "[C2405][misra-c2012-23.5]: violation of misra-c2012-23.5", + "translation": "[C2405][misra-c2012-23.5]: 通用选择不应依赖于隐式指针类型转换" + }, { "id": "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated", "message": "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated", @@ -3892,8 +4647,8 @@ ] }, { - "id": "Starting generating CTU infomation", - "message": "Starting generating CTU infomation", + "id": "Starting generating CTU information", + "message": "Starting generating CTU information", "translation": "CTU信息开始生成" }, { diff --git a/misra/analyzer/cmd/main.go b/misra/analyzer/cmd/main.go index a74f36a699..3434eeb5b5 100644 --- a/misra/analyzer/cmd/main.go +++ b/misra/analyzer/cmd/main.go @@ -38,6 +38,7 @@ import ( "naive.systems/analyzer/cruleslib/filter" "naive.systems/analyzer/cruleslib/i18n" "naive.systems/analyzer/cruleslib/options" + "naive.systems/analyzer/cruleslib/runner" "naive.systems/analyzer/cruleslib/stats" googlecpp "naive.systems/analyzer/googlecpp/analyzer" "naive.systems/analyzer/misra/analyzer/analyzerinterface" @@ -45,7 +46,9 @@ import ( "naive.systems/analyzer/misra/checker_integration/checkrule" misra_c_2012_crules "naive.systems/analyzer/misra_c_2012_crules/analyzer" misra_cpp_2008 "naive.systems/analyzer/misra_cpp_2008/analyzer" + telemetry "naive.systems/analyzer/telemetry/client/sender" toy_rules "naive.systems/analyzer/toy_rules/analyzer" + ) var compileCommandsPath = "/src/compile_commands.json" @@ -83,23 +86,27 @@ func main() { if logDir.Value.String() == "" { err := flag.Set("log_dir", filepath.Join(sharedOptions.GetResultsDir(), "logs")) if err != nil { + telemetry.Wait() glog.Fatalf("failed to set default log_dir: %v", err) } } err := analyzerinterface.CreateLogDir(logDir.Value.String()) if err != nil { + telemetry.Wait() glog.Fatalf("failed to create log dir: %v", err) } if !sharedOptions.GetDebugMode() { err := flag.Set("stderrthreshold", "FATAL") if err != nil { + telemetry.Wait() glog.Fatalf("failed to set default stderrthreshold: %v", err) } } fmt.Println("(c) 2023 Naive Systems Ltd.") + telemetry.Send("Start to generate compilation database", "sharedOptions", sharedOptions) if sharedOptions.GetCheckProgress() { basic.PrintfWithTimeStamp(printer.Sprintf("Start to generate compilation database")) stats.WriteProgress(sharedOptions.GetResultsDir(), stats.CC, "0%", time.Now()) @@ -107,6 +114,7 @@ func main() { numWorkers, err := options.ParseLimitMemory(sharedOptions, numWorkersStr) if err != nil { + telemetry.Wait() glog.Fatalf("options.ParseLimitMemory: %v", err) } @@ -116,6 +124,7 @@ func main() { err = analyzerinterface.CreateResultDir(sharedOptions.GetResultsDir()) if err != nil { + telemetry.Wait() glog.Fatalf("failed to create result dir: %v", err) } @@ -123,24 +132,34 @@ func main() { resultsWithSuffixPath := filepath.Join(sharedOptions.GetResultsDir(), "results.nsa_results") resultsJsonPath := filepath.Join(sharedOptions.GetResultsDir(), "nsa_results.json") if !filepath.IsAbs(sharedOptions.GetConfigDir()) { + telemetry.Wait() glog.Fatal("configDir must be an absolute path") } if sharedOptions.GetSrcDir() != "/src" { - srcDir := filepath.Join("/src", sharedOptions.GetSrcDir()) + workingDir, err := os.Getwd() + if err != nil { + telemetry.Wait() + glog.Fatalf("os.Getwd: %v", err) + } + srcDir := sharedOptions.GetSrcDir() + if !filepath.IsAbs(srcDir) { + srcDir = filepath.Join(workingDir, sharedOptions.GetSrcDir()) + } compileCommandsPath = filepath.Join(srcDir, analyzerinterface.CCJson) sharedOptions.SetSrcDir(srcDir) } projType, err := options.ParseProjectType(sharedOptions) if err != nil { + telemetry.Wait() glog.Fatalf("options.ParseProjectType: %v", err) } if projType == analyzerinterface.Keil { options.ProcessKeilProject(sharedOptions) } - shouldCreateNew := (!sharedOptions.GetSkipBearMake() && (projType == analyzerinterface.Make || projType == analyzerinterface.CMake || projType == analyzerinterface.QMake || projType == analyzerinterface.Script)) + shouldCreateNew := (!sharedOptions.GetSkipBearMake() && (projType == analyzerinterface.Make || projType == analyzerinterface.CMake || projType == analyzerinterface.QMake || projType == analyzerinterface.Script || projType == analyzerinterface.None)) onlyCppcheck, err := analyzerinterface.CheckCompilationDatabase( compileCommandsPath, shouldCreateNew, @@ -153,6 +172,7 @@ func main() { /*isDev=*/ false, ) if err != nil { + telemetry.Wait() if os.IsNotExist(err) { glog.Fatal("Compilation database not found, consider removing `-skip_bear_make`?") } else { @@ -169,6 +189,7 @@ func main() { // 2) if the number of code lines exceed the maximum limit. clines, cpplines, err := options.CheckCodeLines(compileCommandsPath, sharedOptions, linesLimitStr) if err != nil { + telemetry.Wait() glog.Fatalf("options.CheckCodeLines: %v", err) } @@ -178,6 +199,7 @@ func main() { start := time.Now() + telemetry.Send("Start parsing compilation database", "start", start) if sharedOptions.GetCheckProgress() { basic.PrintfWithTimeStamp(printer.Sprintf("Start parsing compilation database")) stats.WriteProgress(sharedOptions.GetResultsDir(), stats.PP, "0%", start) @@ -185,10 +207,12 @@ func main() { // TODO: there still some duplicated action which remove ignore files twice. compileCommandsPath, err := analyzerinterface.GenerateActualCCJsonByRemoveIgnoreFiles(compileCommandsPath, sharedOptions.GetIgnoreDirPatterns()) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.GenerateActualCCJsonByRemoveIgnoreFiles(: %v", err) } filteredCompileCommandsFolder, err := analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(compileCommandsPath) if err != nil { + telemetry.Wait() glog.Fatalf("analyzerinterface.CreateTempFolderContainsFilteredCompileCommandsJsonFile(: %v", err) } defer os.RemoveAll(filteredCompileCommandsFolder) @@ -197,12 +221,14 @@ func main() { checkRulesPath := filepath.Join(sharedOptions.GetConfigDir(), "check_rules") checkRules, err := analyzerinterface.ReadCheckRules(checkRulesPath) if err != nil { - glog.Errorf("failed to read check rules from %s: %v", checkRulesPath, err) + telemetry.Wait() + glog.Fatalf("failed to read check rules from %s: %v", checkRulesPath, err) } var allResults *pb.ResultsList standardSet, err := checkrule.ConstructStandardSet(checkRules) if err != nil { + telemetry.Wait() glog.Fatalf("failed to construct standard set: %v", err) } @@ -211,6 +237,30 @@ func main() { glog.Errorf("failed to clean log and result dir: %v", err) } + coccinelleResults, err := runner.RunCoccinelle(sharedOptions.GetSrcDir(), sharedOptions.GetConfigDir()) + if err != nil { + glog.Errorf("coccinelle.Run: %v", err) + } else { + coccinelleResults = analyzerinterface.ProcessIgnoreDir(coccinelleResults, &sharedOptions.IgnoreDirPatterns) + if allResults == nil { + allResults = coccinelleResults + } else { + allResults.Results = append(allResults.Results, coccinelleResults.Results...) + } + } + + semgrepResults, err := runner.RunSemgrep(sharedOptions.GetSrcDir(), sharedOptions.GetConfigDir(), sharedOptions.GetSemgrepBin()) + if err != nil { + glog.Errorf("semgrep.Run: %v", err) + } else { + semgrepResults = analyzerinterface.ProcessIgnoreDir(semgrepResults, &sharedOptions.IgnoreDirPatterns) + if allResults == nil { + allResults = semgrepResults + } else { + allResults.Results = append(allResults.Results, semgrepResults.Results...) + } + } + csaSystemLibOptionsCopy := parsedCheckerConfig.CsaSystemLibOptions checkerPathsMap := map[string]string{} @@ -237,6 +287,7 @@ func main() { if len(filteredCheckRules) > 0 { start := time.Now() + telemetry.Send("Start preprocessing C/C++ files", "start", start) basic.PrintfWithTimeStamp(printer.Sprintf("Start preprocessing C/C++ files")) envOptions := options.NewEnvOptionsFromShared( standardSet, @@ -250,6 +301,7 @@ func main() { ) elapsed := time.Since(start) timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("Preprocessing C/C++ files completed", "start", start, "envOptions", envOptions, "elapsed", elapsed, "timeUsed", timeUsed) basic.PrintfWithTimeStamp(printer.Sprintf("Preprocessing C/C++ files completed [%s]", timeUsed)) results := checkRuleSet(sharedOptions.GetSrcDir(), ruleSet, filteredCheckRules, envOptions, printer) @@ -274,6 +326,7 @@ func main() { err = checker_integration.DeleteRepeatedResults(results) if err != nil { + telemetry.Wait() glog.Fatal(err) } @@ -317,15 +370,18 @@ func main() { // write results err = analyzerinterface.WriteResults(allResults, resultsPath) if err != nil { + telemetry.Wait() glog.Fatal(err) } err = analyzerinterface.WriteResults(allResults, resultsWithSuffixPath) if err != nil { + telemetry.Wait() glog.Fatal(err) } if sharedOptions.GetShowJsonResults() { err = analyzerinterface.WriteJsonResults(allResults, resultsJsonPath) if err != nil { + telemetry.Wait() glog.Fatal(err) } } @@ -346,6 +402,7 @@ func main() { elapsed := time.Since(start) if sharedOptions.GetCheckProgress() { timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("Total time for analysis", "start", start, "elapsed", elapsed, "timeUsed", timeUsed, "resultsCount", len(allResults.Results)) basic.PrintfWithTimeStamp(printer.Sprintf("Total time for analysis: %s", timeUsed)) } @@ -371,6 +428,7 @@ func main() { glog.Errorf("failed to compress log files: %v", err) } glog.Flush() + telemetry.Wait() } type runFuncType = func([]checkrule.CheckRule, string, *options.EnvOptions) (*pb.ResultsList, []error) @@ -403,13 +461,15 @@ func checkRuleSet( glog.Infof("nothing to check for %s rules", strings.ToUpper(rulePrefix)) } else { start := time.Now() + telemetry.Send("Start analyzing C/C++ files", "srcdir", srcdir, "rulePrefix", rulePrefix, "checkRules", checkRules, "envOptions", envOptions, "start", start) if envOptions.CheckProgress { basic.PrintfWithTimeStamp(printer.Sprintf("Start analyzing C/C++ files")) stats.WriteProgress(envOptions.ResultsDir, stats.AC, "0%", start) } - runner, error := selectRun(rulePrefix) - if error != nil { - glog.Fatal(error) + runner, err := selectRun(rulePrefix) + if err != nil { + telemetry.Wait() + glog.Fatal(err) } // TODO: handle onlyCppcheck results, errors := runner(checkRules, srcdir, envOptions) @@ -419,8 +479,9 @@ func checkRuleSet( } } elapsed := time.Since(start) + timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("Analyzing C/C++ files completed", "start", start, "elapsed", elapsed, "timeUsed", timeUsed) if envOptions.CheckProgress { - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("Analyzing C/C++ files completed [%s]", timeUsed)) } return results diff --git a/misra/analyzer/run_analyzer.go b/misra/analyzer/run_analyzer.go index ad95e2d9f6..391ab5ddbe 100644 --- a/misra/analyzer/run_analyzer.go +++ b/misra/analyzer/run_analyzer.go @@ -49,6 +49,7 @@ import ( "naive.systems/analyzer/misra/checker_integration/csa" "naive.systems/analyzer/misra/checker_integration/libtooling" "naive.systems/analyzer/misra/utils" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) func ListSourceFiles(compileCommandsPath string, ignoreDirPatterns []string) ([]string, error) { @@ -453,7 +454,6 @@ func PreAnalyze( resultsDir string, config *pb.CheckerConfiguration, checkProgress bool, - enableCodeChecker bool, numWorkers int32, ignoreDirPatterns []string, lang string, @@ -461,7 +461,7 @@ func PreAnalyze( ) (map[string]string, error) { glog.Infof("Start PreAnalyze") - err := resolveCheckerBinariesPath(checkRules, config, enableCodeChecker) + err := resolveCheckerBinariesPath(checkRules, config) if err != nil { return nil, err } @@ -490,7 +490,6 @@ func PreAnalyze( resultsDir, config, checkProgress, - enableCodeChecker, numWorkers, ignoreDirPatterns, lang, @@ -508,7 +507,6 @@ func PreAnalyzeBody( resultsDir string, config *pb.CheckerConfiguration, checkProgress bool, - enableCodeChecker bool, numWorkers int32, ignoreDirPatterns []string, lang string, @@ -521,25 +519,19 @@ func PreAnalyzeBody( } if (usedCheckers[checker_integration.CSA] || usedCheckers[checker_integration.Misra]) && !onlyCppcheck { start := time.Now() + telemetry.Send("Start preparing CTU information", "start", start, "config", config) if checkProgress { basic.PrintfWithTimeStamp(printer.Sprintf("Start preparing CTU information")) stats.WriteProgress(resultsDir, stats.CTU, "0%", start) } - if enableCodeChecker { - err := csa.GenerateCTUExtraArgumentsFromCodeChecker(compileCommandsPath, resultsDir, config) - if err != nil { - return dumpErrors, fmt.Errorf("csa.GenerateCTUExtraArgumentsFromCodeChecker: %v", err) - } - } else { - // currently use our pre-analyzer - err := csa.GenerateCTUExtraArguments(compileCommandsPath, resultsDir, config, checkProgress, lang, numWorkers) - if err != nil { - return dumpErrors, fmt.Errorf("csa.GenerateCTUExtraArguments: %v", err) - } + err := csa.GenerateCTUExtraArguments(compileCommandsPath, resultsDir, config, checkProgress, lang, numWorkers) + if err != nil { + return dumpErrors, fmt.Errorf("csa.GenerateCTUExtraArguments: %v", err) } elapsed := time.Since(start) + timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("CTU information preparation completed", "start", start, "elapsed", elapsed, "timeUsed", timeUsed) if checkProgress { - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("CTU information preparation completed [%s]", timeUsed)) } } @@ -550,6 +542,7 @@ func PreAnalyzeBody( var finishededTaskNumbers int = 0 start := time.Now() + telemetry.Send("Start preparing STU information", "start", start) if checkProgress { basic.PrintfWithTimeStamp(printer.Sprintf("Start preparing STU information")) stats.WriteProgress(resultsDir, stats.STU, "0%", start) @@ -566,6 +559,7 @@ func PreAnalyzeBody( for i := 0; i < taskNumbers; i++ { actionErrs := <-results finishededTaskNumbers++ + telemetry.Send("STU information preparation completed", "finishededTaskNumbers", finishededTaskNumbers, "taskNumbers", taskNumbers) if checkProgress { percent := basic.GetPercentString(finishededTaskNumbers, taskNumbers) stats.WriteProgress(resultsDir, stats.STU, percent, start) @@ -585,8 +579,9 @@ func PreAnalyzeBody( }) elapsed := time.Since(start) + timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("STU information preparation completed", "start", start, "elapsed", elapsed, "timeUsed", timeUsed) if checkProgress { - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("STU information preparation completed [%s]", timeUsed)) } } @@ -672,6 +667,7 @@ func Analyze( if numWorkers == 0 { numWorkers = int32(runtime.NumCPU()) } + telemetry.Send("Use CPU(s)", "numWorkers", numWorkers) if checkProgress { basic.PrintfWithTimeStamp(printer.Sprintf("Use %d CPU(s)", numWorkers)) } @@ -701,13 +697,14 @@ func Analyze( elapsed := time.Since(start) currentFinishedNumber := atomic.AddInt32(&finishedTaskNumbers, 1) + timeUsed := basic.FormatTimeDuration(elapsed) + totalRuleNumber := len(checkRules) + ruleName := j.Rule.Name + telemetry.Send("Analysis completed", "ruleName", ruleName, "currentFinishedNumber", currentFinishedNumber, "totalRuleNumber", totalRuleNumber, "timeUsed", timeUsed) if checkProgress { percent := basic.GetPercentString(int(currentFinishedNumber), len(checkRules)) stats.WriteProgress(resultsDir, stats.AC, percent, analyzeStart) percent += "%" - totalRuleNumber := len(checkRules) - ruleName := j.Rule.Name - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("Analysis of %s completed (%s, %v/%v) [%s]", ruleName, percent, currentFinishedNumber, totalRuleNumber, timeUsed)) } @@ -736,6 +733,7 @@ func Analyze( select { case <-sigs: // if recived a SIGINT, stop collector and analyze rule loop + telemetry.Send("Ctrl C Pressed. Stop analysis") if checkProgress { basic.PrintfWithTimeStamp("Ctrl C Pressed. Stop analysis") } @@ -790,8 +788,9 @@ func Analyze( collectorWg.Wait() glog.Infof("Finish Analyze") analyzeElapsed := time.Since(analyzeStart) + timeUsed := basic.FormatTimeDuration(analyzeElapsed) + telemetry.Send("Analysis completed", "analyzeStart", analyzeStart, "analyzeElapsed", analyzeElapsed, "timeUsed", timeUsed) if checkProgress { - timeUsed := basic.FormatTimeDuration(analyzeElapsed) basic.PrintfWithTimeStamp(printer.Sprintf("Analysis completed [%s]", timeUsed)) } return allResults @@ -849,11 +848,10 @@ func ExecMixture(checkRule checkrule.CheckRule, compileCommandsPath, resultsDir, return nil } -func resolveCheckerBinariesPath(checkRules []checkrule.CheckRule, config *pb.CheckerConfiguration, enableCodeChecker bool) error { +func resolveCheckerBinariesPath(checkRules []checkrule.CheckRule, config *pb.CheckerConfiguration) error { binPathSet := []*string{ &config.InferBin, &config.ClangBin, - &config.CodeCheckerBin, &config.CppcheckBin, &config.PythonBin, &config.ClangtidyBin, @@ -861,11 +859,9 @@ func resolveCheckerBinariesPath(checkRules []checkrule.CheckRule, config *pb.Che &config.ClangmappingBin, } for _, binPath := range binPathSet { - if *binPath == config.CodeCheckerBin && !enableCodeChecker { - continue - } resolvedBinPath, err := utils.ResovleBinaryPath(*binPath) if err != nil { + telemetry.Wait() glog.Fatalf("utils.ResovleBinaryPath: %v", err) } *binPath = resolvedBinPath @@ -883,6 +879,7 @@ func resolveCheckerBinariesPath(checkRules []checkrule.CheckRule, config *pb.Che progName := filepath.Join(config.MisraCheckerPath, ruleNumber) _, err := utils.ResovleBinaryPath(progName) if err != nil { + telemetry.Wait() glog.Fatalf("utils.ResovleBinaryPath: %v", err) } } diff --git a/misra/analyzer/run_analyzer_test.go b/misra/analyzer/run_analyzer_test.go deleted file mode 100644 index 7dff6961b8..0000000000 --- a/misra/analyzer/run_analyzer_test.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -package analyzer - -import ( - "testing" - - pb "naive.systems/analyzer/analyzer/proto" - "naive.systems/analyzer/misra/checker_integration/checkrule" -) - -func TestResolveCheckerBinariesPath(t *testing.T) { - for _, testCase := range [...]struct { - name string - binPath string - checkRules []checkrule.CheckRule - enableCodeChecker bool - expectedErr error - }{ - { - name: "skip CodeChecker", - binPath: "CodeChecker", - checkRules: []checkrule.CheckRule{ - { - Name: "misra_c_2012/dir_4_14", - JSONOptions: checkrule.JSONOption{}, - }, - }, - enableCodeChecker: false, - expectedErr: nil, - }, - } { - t.Run(testCase.name, func(t *testing.T) { - config := &pb.CheckerConfiguration{} - config.InferBin = testCase.binPath - config.ClangBin = testCase.binPath - config.CodeCheckerBin = testCase.binPath - config.CppcheckBin = testCase.binPath - config.PythonBin = testCase.binPath - config.ClangtidyBin = testCase.binPath - config.ClangqueryBin = testCase.binPath - config.ClangmappingBin = testCase.binPath - err := resolveCheckerBinariesPath(testCase.checkRules, config, testCase.enableCodeChecker) - if err != testCase.expectedErr { - t.Errorf("unexpected error for resolving binary binaries. error: %v. expected: %v.", err, testCase.checkRules) - } - }) - } -} diff --git a/misra/checker_integration/README b/misra/checker_integration/README index 5fff848602..7671b89d5f 100644 --- a/misra/checker_integration/README +++ b/misra/checker_integration/README @@ -13,6 +13,6 @@ You can also test single rule by using Makefile (in checker_integration/): make check_22_1 compile_commands_path=../../../misra_c_2012/rule_22_1/bad/bad1/compile_commands.json \ If you want to customize your checker binaries instead of using default config, you can add a parameter like this: --checker_config='{"csa_system_lib_options":"-isystem /usr/include -isystem /usr/lib/gcc/x86_64-redhat-linux/11/include/","infer_bin":"infer","clang_bin":"clang","code_checker_bin":"CodeChecker","cppcheck_bin":"third_party/cppcheck/cppcheck","python_bin":"python"}' +-checker_config='{"csa_system_lib_options":"-isystem /usr/include -isystem /usr/lib/gcc/x86_64-redhat-linux/11/include/","infer_bin":"infer","clang_bin":"clang","cppcheck_bin":"third_party/cppcheck/cppcheck","python_bin":"python"}' For CSA checker, csa_system_lib_options defines the path of system library which may differ between operating systems. diff --git a/misra/checker_integration/checkrule/checkrule.go b/misra/checker_integration/checkrule/checkrule.go index 56e75a5a25..db528eed66 100644 --- a/misra/checker_integration/checkrule/checkrule.go +++ b/misra/checker_integration/checkrule/checkrule.go @@ -35,12 +35,13 @@ type SourceFuncList []SourceFunc const emptyString = "" type CheckRule struct { - Name string - JSONOptions JSONOption + Name string `json:"name"` + JSONOptions JSONOption `json:"jsonOptions"` } type JSONOption struct { CaseSensitive *bool `json:"case-sensitive,omitempty" yaml:"-"` + Misra2023 *bool `json:"misra-2023,omitempty" yaml:"-"` Limit *int `json:"limit,omitempty" yaml:"-"` Standard string `json:"standard,omitempty" yaml:"-"` MaxLoop *int `json:"max-loop,omitempty" yaml:"-"` @@ -55,9 +56,9 @@ type JSONOption struct { MaximumAllowedSize *int `json:"maximum-allowed-size,omitempty" yaml:"-"` // CSAAnalyzerInliningMode determines the heuristic used to select functions for inlining. // This can take on two values as defined in third_party/llvm-project/clang/include/clang/StaticAnalyzer/Core/Analyses.def: - // 1. all: analyze all functions as top-level. - // 2. noredundancy: avoid analyzing a function that has already been inlined. - CSAAnalyzerInliningMode *string `json:"csa-analyzer-inlining-mode,omitempty" yaml:"-"` + // 1. true represents all mode, which analyzes all functions as top-level. + // 2. false (default) represents noredundancy mode, which avoids analyzing a function that has already been inlined. + CSAAnalyzerInliningMode *bool `json:"csa-analyzer-inlining-mode,omitempty" yaml:"-"` UseInfer bool `json:"use-infer,omitempty" yaml:"-"` UseCSA bool `json:"use-csa,omitempty" yaml:"-"` UseZ3 string `json:"use-z3,omitempty" yaml:"-"` @@ -89,6 +90,7 @@ type JSONOption struct { BlockIDLimit *int `json:"block-id-limit,omitempty" yaml:"-"` //misra_c_2012/rule_1_1 NestedDeclLimit *int `json:"nested-decl-limit,omitempty" yaml:"-"` //misra_c_2012/rule_1_1 ModifyDeclLimit *int `json:"modify-decl-limit,omitempty" yaml:"-"` //misra_c_2012/rule_1_1 + ErrorMessage *string `json:"error-message,omitempty" yaml:"-"` //coccinelle } type FilterAndSinkFunc struct { @@ -176,6 +178,9 @@ func (jsonOption *JSONOption) Update(newOption JSONOption) { if newOption.CaseSensitive != nil { jsonOption.CaseSensitive = newOption.CaseSensitive } + if newOption.Misra2023 != nil { + jsonOption.Misra2023 = newOption.Misra2023 + } if newOption.Limit != nil { jsonOption.Limit = newOption.Limit } diff --git a/misra/checker_integration/clangformat/run.go b/misra/checker_integration/clangformat/run.go new file mode 100644 index 0000000000..7507901136 --- /dev/null +++ b/misra/checker_integration/clangformat/run.go @@ -0,0 +1,91 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package clangformat + +import ( + "os/exec" + "regexp" + "strconv" + + "github.com/golang/glog" + "naive.systems/analyzer/cruleslib/basic" +) + +type Report struct { + Filename string + LineNumber int + ColumnNumber int + Message string + Category string +} + +func ParseReports(out []byte) (reports []Report, err error) { + // example output of clang-format: + // foo.cpp:129:23: error: code should be clang-formatted [-Wclang-format-violations] + re := regexp.MustCompile(`(.*):(\d*):(\d*): (.*) \[(.*)\]`) + matches := re.FindAllStringSubmatch(string(out), -1) + for _, match := range matches { + linenum, err := strconv.Atoi(match[2]) + if err != nil { + glog.Errorf("clang-format output cannot be parsed: %s", string(out)) + return reports, err + } + colnum, err := strconv.Atoi(match[3]) + if err != nil { + glog.Errorf("clang-format output cannot be parsed: %s", string(out)) + return reports, err + } + reports = append(reports, Report{ + Filename: match[1], + LineNumber: linenum, + ColumnNumber: colnum, + Message: match[4], + Category: match[5], + }) + } + return reports, nil +} + +type Runner struct { + TaskName string + LimitMemory bool + TimeoutNormal int + TimeoutOom int +} + +func (r *Runner) Run(srcs []string, style string) (reports []Report, err error) { + cmd := exec.Command("clang-format", "-Werror", "--style="+style, "--dry-run") + cmd.Args = append(cmd.Args, srcs...) + glog.Info("executing: ", cmd.String()) + out, err := basic.CombinedOutput(cmd, r.TaskName, r.LimitMemory, r.TimeoutNormal, r.TimeoutOom) + // err == nil ==> no report + if err == nil { + return + } + if serr, ok := err.(*exec.ExitError); !ok || serr.ExitCode() != 1 { + glog.Errorf("clang-format execution error: executing %s, reported:\n%s", cmd.String(), string(out)) + return + } + // ExitError 1 ==> normal report + reports, err = ParseReports(out) + if err != nil { + glog.Errorf("parse clang-format output error: %v", err) + } + return +} diff --git a/misra/checker_integration/cmd/main.go b/misra/checker_integration/cmd/main.go index 730d48f690..b2a1e3d01d 100644 --- a/misra/checker_integration/cmd/main.go +++ b/misra/checker_integration/cmd/main.go @@ -47,7 +47,6 @@ func main() { `{"csa_system_lib_options":"-isystem /usr/lib/gcc/x86_64-redhat-linux/11/include/", "infer_bin":"infer", "clang_bin":"bazel-bin/external/llvm-project/clang/clang", - "code_checker_bin":"CodeChecker", "cppcheck_bin":"third_party/cppcheck/cppcheck", "python_bin":"python3", "clangtidy_bin":"clang-tidy", @@ -58,7 +57,6 @@ func main() { "Checker configuration in JSON format") jsonOptions := flag.String("json_options", "{}", "Json options for the analyzer.") checkProgress := flag.Bool("check_progress", true, "Show the checking progress") - enableCodeChecker := flag.Bool("enable_codechecker", false, "Use CodeChecker to perform CTU pre-analysis for CSA") var ignoreDirPatterns analyzerinterface.ArrayFlags flag.Var(&ignoreDirPatterns, "ignore_dir", "Shell file name pattern to a directory that will be ignored") flag.Parse() @@ -117,7 +115,6 @@ func main() { *resultsDir, parsedCheckerConfig, *checkProgress, - *enableCodeChecker, numWorkers, /*ignoreDirPatterns=*/ []string{}, /*lang=*/ "zh", diff --git a/misra/checker_integration/csa/cmd_parser.go b/misra/checker_integration/csa/cmd_parser.go index 85ab1ef3c5..de1268a1ba 100644 --- a/misra/checker_integration/csa/cmd_parser.go +++ b/misra/checker_integration/csa/cmd_parser.go @@ -39,6 +39,7 @@ import ( "naive.systems/analyzer/cruleslib/stats" "naive.systems/analyzer/misra/checker_integration/compilecommand" "naive.systems/analyzer/misra/utils" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) type csaBuildAction struct { @@ -663,6 +664,16 @@ func getTarget(commands []string, details *csaBuildAction) bool { details.compilerTarget = commands[1] return true } + for _, t := range targets { + prefix := t + "=" + if strings.HasPrefix(commands[0], prefix) { + compilerTarget := strings.TrimLeft(commands[0], prefix) + if compilerTarget != "" { + details.compilerTarget = compilerTarget + return true + } + } + } return false } @@ -953,6 +964,7 @@ func GetBuildActionsFromCompileCommands(resultsDir string, compilationDatabase * percentStr := basic.GetPercentString(startedTaskNumbers, taskNumbers) percent := percentStr + "%" if action.lang == "" || action.actionType != COMPILE { + telemetry.Send("BuildAction preparation completed", "percent", percent, "startedTaskNumbers", startedTaskNumbers, "taskNumbers", taskNumbers) if checkProgress { basic.PrintfWithTimeStamp(printer.Sprintf("%s BuildAction preparation completed (%v/%v)", percent, startedTaskNumbers, taskNumbers)) } @@ -965,6 +977,7 @@ func GetBuildActionsFromCompileCommands(resultsDir string, compilationDatabase * } else if action.output < sourceFileToBuildActionMap[action.source].output { sourceFileToBuildActionMap[action.source] = action } + telemetry.Send("BuildAction preparation completed", "percent", percent, "startedTaskNumbers", startedTaskNumbers, "taskNumbers", taskNumbers) if checkProgress { basic.PrintfWithTimeStamp(printer.Sprintf("%s BuildAction preparation completed (%v/%v)", percent, startedTaskNumbers, taskNumbers)) stats.WriteProgress(resultsDir, stats.PP, percentStr, start) @@ -982,8 +995,9 @@ func GetBuildActionsFromCompileCommands(resultsDir string, compilationDatabase * } glog.Info("GetBuildActionsFromCompileCommands: parsing commands done.") elapsed := time.Since(start) + timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("BuildAction preparation completed", "start", start, "elapsed", elapsed, "timeUsed", timeUsed) if checkProgress { - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("BuildAction preparation completed [%s]", timeUsed)) } return &BuildActions diff --git a/misra/checker_integration/csa/ctu.go b/misra/checker_integration/csa/ctu.go index 27f1351ea2..c1333b15c8 100644 --- a/misra/checker_integration/csa/ctu.go +++ b/misra/checker_integration/csa/ctu.go @@ -21,71 +21,24 @@ package csa import ( "fmt" "os" - "os/exec" "path/filepath" "reflect" "strings" "github.com/golang/glog" "github.com/google/shlex" - "gopkg.in/yaml.v2" pb "naive.systems/analyzer/analyzer/proto" "naive.systems/analyzer/misra/analyzer/analyzerinterface" "naive.systems/analyzer/misra/checker_integration/compilecommand" ) -// Use CodeChecker to generate needed extra arguments for CTU analysis from given -// compile_commands.json, including externalDefMap.txt & invocation-list.yml . -func GenerateCTUExtraArgumentsFromCodeChecker(compileCommandsPath, resultsDir string, config *pb.CheckerConfiguration) error { - cmd_arr := []string{"analyze", "--ctu-collect", "--ctu-ast-mode", "parse-on-demand"} - cmd_arr = append(cmd_arr, "-o", resultsDir) // TODO: Replace with a configurable path - cmd_arr = append(cmd_arr, compileCommandsPath) - cmd := exec.Command(config.CodeCheckerBin, cmd_arr...) - glog.Info("executing: ", cmd.String()) - if out, err := cmd.CombinedOutput(); err != nil { - glog.Errorf("failed to execute codechecker, reported: \n%s", string(out)) - return err - } - // Inject CSA System Lib Options & GCC Predefined Macros into all `/ctu-dir/*/invocation-list.yml`` - invocationListPattern := filepath.Join(resultsDir, "ctu-dir", "*", "invocation-list.yml") - matches, err := filepath.Glob(invocationListPattern) - if err != nil { - return fmt.Errorf("filepath.Glob: %v", err) - } - for _, match := range matches { - invocations := make(map[string][]string) - contents, err := os.ReadFile(match) - if err != nil { - glog.Errorf("os.ReadFile: %v", err) - continue - } - err = yaml.Unmarshal(contents, &invocations) - if err != nil { - glog.Errorf("yaml.Unmarshal: %v", err) - continue - } - for k := range invocations { - invocations[k] = append(invocations[k], strings.Fields(config.CsaSystemLibOptions)...) - invocations[k] = append(invocations[k], ParseGccPredefinedMacros(config.GetGccPredefinedMacros(), false)...) - } - contents, err = yaml.Marshal(invocations) - if err != nil { - glog.Errorf("yaml.Unmarshal: %v", err) - continue - } - err = os.WriteFile(match, contents, os.ModePerm) - if err != nil { - glog.Errorf("os.WriteFile: %v", err) - } - } - return nil -} - // BuildAction contains info extracted from compile command. type BuildAction struct { - Command compilecommand.CompileCommand - Arch string // the processor architecture, e.g., 'x86_64' - Target string // the target hardware platform, e.g.,'x86_64-redhat-linux' + Command compilecommand.CompileCommand `json:"command"` + // the processor architecture, e.g., 'x86_64' + Arch string `json:"arch"` + // the target hardware platform, e.g.,'x86_64-redhat-linux' + Target string `json:"target"` } // To prepare unique entrance files for CSA. diff --git a/misra/checker_integration/csa/pre_analyzer.go b/misra/checker_integration/csa/pre_analyzer.go index 17cb48bf38..f70b5f7a22 100644 --- a/misra/checker_integration/csa/pre_analyzer.go +++ b/misra/checker_integration/csa/pre_analyzer.go @@ -50,6 +50,7 @@ import ( "naive.systems/analyzer/cruleslib/i18n" "naive.systems/analyzer/cruleslib/stats" "naive.systems/analyzer/misra/utils" + telemetry "naive.systems/analyzer/telemetry/client/sender" ) var ( @@ -345,8 +346,9 @@ func PerformPreAnalysis(ctuDir string, actions *[]csaBuildAction, config *pb.Che tasks := make(chan csaBuildAction, numWorkers) arches := make(chan string, taskNumbers) results := make(chan map[string][]string, taskNumbers) + telemetry.Send("Starting generating CTU information", "start", start, "config", config) if checkProgress { - basic.PrintfWithTimeStamp(printer.Sprintf("Starting generating CTU infomation")) + basic.PrintfWithTimeStamp(printer.Sprintf("Starting generating CTU information")) } for i := 0; i < int(numWorkers); i++ { go getFuncAstListByArch(tasks, arches, results, ctuDir, config) @@ -369,17 +371,20 @@ func PerformPreAnalysis(ctuDir string, actions *[]csaBuildAction, config *pb.Che } performPreAnalysisLock.Unlock() finishedTaskNumbers++ + percent := basic.GetPercentString(int(finishedTaskNumbers), taskNumbers) + stats.WriteProgress(filepath.Dir(ctuDir), stats.CTU, percent, start) + percent += "%" + telemetry.Send("CTU information generated", "taskNumbers", taskNumbers, "finishedTaskNumbers", finishedTaskNumbers, "taskNumbers", taskNumbers) if checkProgress { - percent := basic.GetPercentString(int(finishedTaskNumbers), taskNumbers) - stats.WriteProgress(filepath.Dir(ctuDir), stats.CTU, percent, start) - percent += "%" basic.PrintfWithTimeStamp(printer.Sprintf("%s CTU information generated (%v/%v)", percent, finishedTaskNumbers, taskNumbers)) } } elapsed := time.Since(start) + timeUsed := basic.FormatTimeDuration(elapsed) + telemetry.Send("CTU information generated", "start", start, "elapsed", elapsed, "timeUsed", timeUsed) + telemetry.Send("Starting writing CTU information") if checkProgress { - timeUsed := basic.FormatTimeDuration(elapsed) basic.PrintfWithTimeStamp(printer.Sprintf("CTU information generated successfully [%s]", timeUsed)) basic.PrintfWithTimeStamp(printer.Sprintf("Starting writing CTU information")) } @@ -390,8 +395,9 @@ func PerformPreAnalysis(ctuDir string, actions *[]csaBuildAction, config *pb.Che } // TODO: perform pre-analysis in a multi-processing way mergeElapsed := time.Since(mergeStart) + timeUsed = basic.FormatTimeDuration(mergeElapsed) + telemetry.Send("Writing CTU information completed", "start", start, "mergeElapsed", mergeElapsed, "timeUsed", timeUsed) if checkProgress { - timeUsed := basic.FormatTimeDuration(mergeElapsed) basic.PrintfWithTimeStamp(printer.Sprintf("Writing CTU information completed [%s]", timeUsed)) } } diff --git a/misra/checker_integration/csa/run_csa.go b/misra/checker_integration/csa/run_csa.go index 678d1c10c7..695dbea76b 100644 --- a/misra/checker_integration/csa/run_csa.go +++ b/misra/checker_integration/csa/run_csa.go @@ -130,7 +130,11 @@ func runSingleCSA( csaAnalyzerInliningMode := jsonOptions.CSAAnalyzerInliningMode if csaAnalyzerInliningMode != nil { - cmd_arr = append(cmd_arr, "-Xanalyzer", "-analyzer-inlining-mode="+*csaAnalyzerInliningMode) + csaAnalyzerInliningModeStr := "noredundancy" + if *csaAnalyzerInliningMode { + csaAnalyzerInliningModeStr = "all" + } + cmd_arr = append(cmd_arr, "-Xanalyzer", "-analyzer-inlining-mode="+csaAnalyzerInliningModeStr) } maxLoop := jsonOptions.MaxLoop diff --git a/misra/checker_integration/misra/cmd/main.go b/misra/checker_integration/misra/cmd/main.go index 79d2a688f7..80e1ba0b43 100644 --- a/misra/checker_integration/misra/cmd/main.go +++ b/misra/checker_integration/misra/cmd/main.go @@ -39,7 +39,6 @@ func main() { `{"csa_system_lib_options":"-isystem /usr/lib/gcc/x86_64-redhat-linux/11/include/", "infer_bin":"infer", "clang_bin":"bazel-bin/external/llvm-project/clang/clang", - "code_checker_bin":"CodeChecker", "cppcheck_bin":"third_party/cppcheck/cppcheck", "python_bin":"python3", "clangtidy_bin":"clang-tidy", diff --git a/misra/dir_4_10/checker.cc b/misra/dir_4_10/checker.cc index 5fa6cf727a..655e21709c 100644 --- a/misra/dir_4_10/checker.cc +++ b/misra/dir_4_10/checker.cc @@ -33,7 +33,7 @@ using analyzer::proto::ResultsList; namespace misra { namespace dir_4_10 { -void PrecautionCheck::Init(analyzer::proto::ResultsList* results_list, +void PrecautionCheck::Init(ResultsList* results_list, SourceManager* source_manager) { results_list_ = results_list; source_manager_ = source_manager; @@ -225,9 +225,7 @@ bool PrecautionAction::BeginSourceFileAction(CompilerInstance& ci) { return true; } -void Checker::Init(analyzer::proto::ResultsList* results_list) { - results_list_ = results_list; -} +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; } } // namespace dir_4_10 } // namespace misra diff --git a/misra/dir_4_10/main.cc b/misra/dir_4_10/main.cc index d3797d970d..5c0027c680 100644 --- a/misra/dir_4_10/main.cc +++ b/misra/dir_4_10/main.cc @@ -47,13 +47,13 @@ int dir_4_10(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/dir_4_11/checker.cc b/misra/dir_4_11/checker.cc index af2722480f..cf099d51ef 100644 --- a/misra/dir_4_11/checker.cc +++ b/misra/dir_4_11/checker.cc @@ -60,7 +60,7 @@ class CallCallback : public MatchFinder::MatchCallback { return; } } - std::string error_message = + string error_message = "[C2314][misra-c2012-dir-4.11]: violation of misra-c2012-dir-4.11"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -82,7 +82,7 @@ class CallCallback : public MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CallCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/dir_4_11/main.cc b/misra/dir_4_11/main.cc index 4991c24977..2bcfe2e87a 100644 --- a/misra/dir_4_11/main.cc +++ b/misra/dir_4_11/main.cc @@ -47,13 +47,13 @@ int dir_4_11(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/dir_4_12/checker.cc b/misra/dir_4_12/checker.cc index 8a359fc62b..012503ebe0 100644 --- a/misra/dir_4_12/checker.cc +++ b/misra/dir_4_12/checker.cc @@ -51,7 +51,7 @@ class CallCallback : public MatchFinder::MatchCallback { string function_name = callee_function->getAsFunction()->getNameAsString(); if (function_name == "malloc" || function_name == "calloc" || function_name == "realloc" || function_name == "free") { - std::string error_message = + string error_message = "[C2315][misra-c2012-dir-4.12]: dynamic allocation should not be used"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -72,7 +72,7 @@ class CallCallback : public MatchFinder::MatchCallback { } }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CallCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/dir_4_12/main.cc b/misra/dir_4_12/main.cc index 2a3742dfd1..baf0250eca 100644 --- a/misra/dir_4_12/main.cc +++ b/misra/dir_4_12/main.cc @@ -47,13 +47,13 @@ int dir_4_12(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/dir_4_3/checker.cc b/misra/dir_4_3/checker.cc index a161348b5f..169f42c4c9 100644 --- a/misra/dir_4_3/checker.cc +++ b/misra/dir_4_3/checker.cc @@ -47,9 +47,9 @@ class AsmFunctionCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const Stmt* mixed_asm = result.Nodes.getNodeAs("mixed_asm"); - std::string error_message = + string error_message = "[C2306][misra-c2012-dir-4.3]: assembly code should be isolated"; - std::string path = + string path = misra::libtooling_utils::GetFilename(mixed_asm, result.SourceManager); int line = misra::libtooling_utils::GetLine(mixed_asm, result.SourceManager); @@ -83,9 +83,9 @@ class AsmCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C2306][misra-c2012-dir-4.3]: assembly code should be encapsulated"; - std::string path = + string path = misra::libtooling_utils::GetFilename(asm_stmt, result.SourceManager); int line = misra::libtooling_utils::GetLine(asm_stmt, result.SourceManager); analyzer::proto::Result* pb_result = @@ -101,7 +101,7 @@ class AsmCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; encapsulated_callback_ = new AsmCallback; encapsulated_callback_->Init(results_list_, &finder_); diff --git a/misra/dir_4_3/main.cc b/misra/dir_4_3/main.cc index 764e1b63b2..38c2515376 100644 --- a/misra/dir_4_3/main.cc +++ b/misra/dir_4_3/main.cc @@ -47,13 +47,13 @@ int dir_4_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/dir_4_7/checker.cc b/misra/dir_4_7/checker.cc index 8fa219d0a2..c73566abed 100644 --- a/misra/dir_4_7/checker.cc +++ b/misra/dir_4_7/checker.cc @@ -54,7 +54,7 @@ class CallParamCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const Expr* call = result.Nodes.getNodeAs("call"); - std::string error_message = + string error_message = "[C2310][misra-c2012-dir-4.7]: error should be tested"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -117,7 +117,7 @@ class CallAssignCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const Expr* call = result.Nodes.getNodeAs("call"); - std::string error_message = + string error_message = "[C2310][misra-c2012-dir-4.7]: error should be tested"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -152,7 +152,7 @@ class CallCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const CallExpr* call = result.Nodes.getNodeAs("call"); - std::string error_message = + string error_message = "[C2310][misra-c2012-dir-4.7]: error should be tested"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -168,7 +168,7 @@ class CallCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; call_callback_ = new CallCallback; call_callback_->Init(results_list_, &finder_); diff --git a/misra/dir_4_7/main.cc b/misra/dir_4_7/main.cc index c32af3eb3f..9e805745eb 100644 --- a/misra/dir_4_7/main.cc +++ b/misra/dir_4_7/main.cc @@ -47,13 +47,13 @@ int dir_4_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/libtooling_utils/libtooling_utils.h b/misra/libtooling_utils/libtooling_utils.h index ed0b022c39..33bdae0501 100644 --- a/misra/libtooling_utils/libtooling_utils.h +++ b/misra/libtooling_utils/libtooling_utils.h @@ -237,6 +237,10 @@ class ASTVisitor : public RecursiveASTVisitor { funcDecls.emplace_back(fd); // Store the node return true; // Continue traversal } + bool VisitCallExpr(const CallExpr* ce) { + callExprs.emplace_back(ce); // Store the node + return true; // Continue traversal + } bool VisitArrayType(const ArrayType* at) { arrayTypes.emplace_back(at); // Store the node return true; // Continue traversal @@ -272,6 +276,7 @@ class ASTVisitor : public RecursiveASTVisitor { return binaryOps; } const vector& getFuncDecls() const { return funcDecls; } + const vector& getCallExprs() const { return callExprs; } const vector& getArrayTypes() const { return arrayTypes; } const vector& getFuncTypes() const { return funcTypes; } const vector& getPtrTypes() const { return ptrTypes; } @@ -286,6 +291,7 @@ class ASTVisitor : public RecursiveASTVisitor { vector varDecls{}; vector binaryOps{}; vector funcDecls{}; + vector callExprs{}; vector arrayTypes{}; vector funcTypes{}; vector ptrTypes{}; diff --git a/misra/rule_11_1/checker.cc b/misra/rule_11_1/checker.cc index 970499c259..9eb1868939 100644 --- a/misra/rule_11_1/checker.cc +++ b/misra/rule_11_1/checker.cc @@ -32,10 +32,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - string loc, std::string path, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, string loc, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1409][misra-c2012-11.1]: Conversions violation of misra-c2012-11.1\n" "source type: %s\n" "destination type: %s\n" @@ -84,7 +83,7 @@ class CastCallback : public MatchFinder::MatchCallback { assert(ce); ASTContext* context = result.Context; - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType().getCanonicalType(); QualType source_type = ce->getSubExpr()->getType().getCanonicalType(); @@ -113,7 +112,7 @@ class CastCallback : public MatchFinder::MatchCallback { return; } } - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -124,7 +123,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_1/main.cc b/misra/rule_11_1/main.cc index 145eb42db9..97abf37943 100644 --- a/misra/rule_11_1/main.cc +++ b/misra/rule_11_1/main.cc @@ -47,7 +47,7 @@ int rule_11_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_2/checker.cc b/misra/rule_11_2/checker.cc index 72741aef7a..a2c88866b2 100644 --- a/misra/rule_11_2/checker.cc +++ b/misra/rule_11_2/checker.cc @@ -33,10 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - string loc, std::string path, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, string loc, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1408][misra-c2012-11.2]: Conversions violation of misra-c2012-11.2\n" "source pointer object type: %s\n" "destination pointer object type: %s\n" @@ -81,7 +80,7 @@ class CastCallback : public MatchFinder::MatchCallback { assert(ce); ASTContext* context = result.Context; - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType().getCanonicalType(); @@ -130,7 +129,7 @@ class CastCallback : public MatchFinder::MatchCallback { return; } } - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -141,7 +140,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_2/main.cc b/misra/rule_11_2/main.cc index e8adfb83da..5b70968072 100644 --- a/misra/rule_11_2/main.cc +++ b/misra/rule_11_2/main.cc @@ -47,7 +47,7 @@ int rule_11_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_3/checker.cc b/misra/rule_11_3/checker.cc index 2f91a6fe60..d1a00d9ec3 100644 --- a/misra/rule_11_3/checker.cc +++ b/misra/rule_11_3/checker.cc @@ -33,10 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - string loc, std::string path, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, string loc, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1407][misra-c2012-11.3]: Conversions violation of misra-c2012-11.3\n" "source pointer object type: %s\n" "destination pointer object type: %s\n" @@ -80,7 +79,7 @@ class CastCallback : public MatchFinder::MatchCallback { return; } ASTContext* context = result.Context; - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType()->getPointeeType(); @@ -97,7 +96,7 @@ class CastCallback : public MatchFinder::MatchCallback { } if (base_dtype != base_stype) { if (!base_dtype->isCharType()) { - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), @@ -110,7 +109,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_3/main.cc b/misra/rule_11_3/main.cc index 8c93742f31..b5626c6efd 100644 --- a/misra/rule_11_3/main.cc +++ b/misra/rule_11_3/main.cc @@ -47,7 +47,7 @@ int rule_11_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_4/checker.cc b/misra/rule_11_4/checker.cc index e295244ab1..969883a2ee 100644 --- a/misra/rule_11_4/checker.cc +++ b/misra/rule_11_4/checker.cc @@ -33,10 +33,10 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, bool ifIntToPointer, QualType destination, - QualType source, string loc, std::string path, int line_number, +void ReportError(string name, bool ifIntToPointer, QualType destination, + QualType source, string loc, string path, int line_number, ResultsList* results_list) { - std::string error_message; + string error_message; analyzer::proto::Result* pb_result; if (ifIntToPointer) { error_message = absl::StrFormat( @@ -108,7 +108,7 @@ class CastCallback : public MatchFinder::MatchCallback { return; } ASTContext* context = result.Context; - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ifIntToPointer ? ce->getType()->getPointeeType() : ce->getType(); @@ -122,7 +122,7 @@ class CastCallback : public MatchFinder::MatchCallback { // The can not only matches ((void*)0), but also other NULL types. return; } - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, ifIntToPointer, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -133,7 +133,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_4/main.cc b/misra/rule_11_4/main.cc index e045fe9a44..2c8df59f09 100644 --- a/misra/rule_11_4/main.cc +++ b/misra/rule_11_4/main.cc @@ -47,7 +47,7 @@ int rule_11_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_5/checker.cc b/misra/rule_11_5/checker.cc index 285b5a1881..76869393c3 100644 --- a/misra/rule_11_5/checker.cc +++ b/misra/rule_11_5/checker.cc @@ -32,10 +32,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - string loc, std::string path, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, string loc, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1405][misra-c2012-11.5]: Conversions violation of misra-c2012-11.5\n" "source pointer object type: %s\n" "destination pointer object type: %s\n" @@ -79,13 +78,13 @@ class CastCallback : public MatchFinder::MatchCallback { if (libtooling_utils::IsInSystemHeader(ce, context)) { return; } - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType()->getPointeeType(); QualType source_type = ce->getSubExpr()->getType()->getPointeeType(); if (ce->getSubExpr()->isNullPointerConstant( *context, Expr::NPC_NeverValueDependent) == Expr::NPCK_NotNull) { - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -97,7 +96,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_5/main.cc b/misra/rule_11_5/main.cc index 78c9c58075..b17e7f8047 100644 --- a/misra/rule_11_5/main.cc +++ b/misra/rule_11_5/main.cc @@ -47,7 +47,7 @@ int rule_11_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_6/checker.cc b/misra/rule_11_6/checker.cc index 8ef58804cb..cbf934bb44 100644 --- a/misra/rule_11_6/checker.cc +++ b/misra/rule_11_6/checker.cc @@ -33,10 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - string loc, std::string path, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, string loc, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1404][misra-c2012-11.6]: Conversions violation of misra-c2012-11.6\n" "source object type: %s\n" "destination object type: %s\n" @@ -99,11 +98,11 @@ class CastCallback : public MatchFinder::MatchCallback { if (libtooling_utils::IsInSystemHeader(ce, context)) { return; } - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType(); QualType source_type = ce->getSubExpr()->getType(); - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -114,7 +113,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_6/main.cc b/misra/rule_11_6/main.cc index 7e17d88567..e8a72eea8a 100644 --- a/misra/rule_11_6/main.cc +++ b/misra/rule_11_6/main.cc @@ -47,7 +47,7 @@ int rule_11_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_7/checker.cc b/misra/rule_11_7/checker.cc index daa13e1d77..e8388286aa 100644 --- a/misra/rule_11_7/checker.cc +++ b/misra/rule_11_7/checker.cc @@ -34,8 +34,8 @@ using analyzer::proto::ResultsList; namespace { void ReportError(string name, QualType destination, QualType source, string loc, - std::string path, int line_number, ResultsList* results_list) { - std::string error_message = absl::StrFormat( + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1403][misra-c2012-11.7]: Conversions violation of misra-c2012-11.7\n" "source type: %s\n" "destination type: %s\n" @@ -95,11 +95,11 @@ class CastCallback : public MatchFinder::MatchCallback { if (libtooling_utils::IsInSystemHeader(ce, context)) { return; } - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); QualType destination_type = ce->getType(); QualType source_type = ce->getSubExpr()->getType(); - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); ReportError(source_name, destination_type, source_type, libtooling_utils::GetLocation(ce, result.SourceManager), path, @@ -110,7 +110,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_7/main.cc b/misra/rule_11_7/main.cc index ec28cf4b1b..242228bdfc 100644 --- a/misra/rule_11_7/main.cc +++ b/misra/rule_11_7/main.cc @@ -47,7 +47,7 @@ int rule_11_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_11_8/checker.cc b/misra/rule_11_8/checker.cc index 55292b0ec1..fc22fa691a 100644 --- a/misra/rule_11_8/checker.cc +++ b/misra/rule_11_8/checker.cc @@ -33,9 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string name, QualType destination, QualType source, - std::string path, int line_number, ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string name, QualType destination, QualType source, + string path, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C1402][misra-c2012-11.8]: Conversions violation of misra-c2012-11.8\n" "source pointer object type: %s\n" "destination pointer object type: %s", @@ -79,10 +79,10 @@ class CastCallback : public MatchFinder::MatchCallback { return; } - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); - std::string source_name = libtooling_utils::GetExprName( + string source_name = libtooling_utils::GetExprName( ce->getSubExpr(), result.SourceManager, context); QualType destination_type = ce->getType()->getPointeeType(); QualType source_type = ce->getSubExpr()->getType()->getPointeeType(); @@ -102,7 +102,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_11_8/main.cc b/misra/rule_11_8/main.cc index b7a26ea075..137c4666e2 100644 --- a/misra/rule_11_8/main.cc +++ b/misra/rule_11_8/main.cc @@ -47,7 +47,7 @@ int rule_11_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_12_3/checker.cc b/misra/rule_12_3/checker.cc index f0042fa3ee..15b380131c 100644 --- a/misra/rule_12_3/checker.cc +++ b/misra/rule_12_3/checker.cc @@ -75,7 +75,7 @@ class CommaCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; comma_callback_ = new CommaCallback; comma_callback_->Init(results_list_, &finder_); diff --git a/misra/rule_12_3/main.cc b/misra/rule_12_3/main.cc index 951faec3b4..f193c4ce3f 100644 --- a/misra/rule_12_3/main.cc +++ b/misra/rule_12_3/main.cc @@ -47,7 +47,7 @@ int rule_12_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_13_1/checker.cc b/misra/rule_13_1/checker.cc index e5b198efb5..6c140c2fab 100644 --- a/misra/rule_13_1/checker.cc +++ b/misra/rule_13_1/checker.cc @@ -57,7 +57,7 @@ class InitListCallback : public MatchFinder::MatchCallback { if (location.isInvalid() || location.isInSystemHeader()) { return; } - std::string error_message = + string error_message = "[C1606][misra-c2012-13.1]: Init list has volatile referenced member"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, libtooling_utils::GetFilename(init_list, source_manager), @@ -71,7 +71,7 @@ class InitListCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new InitListCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_13_1/main.cc b/misra/rule_13_1/main.cc index d2a8dc6b55..7cd4517830 100644 --- a/misra/rule_13_1/main.cc +++ b/misra/rule_13_1/main.cc @@ -47,13 +47,13 @@ int rule_13_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_13_2/checker.cc b/misra/rule_13_2/checker.cc index 640d3a2e92..8f13d68537 100644 --- a/misra/rule_13_2/checker.cc +++ b/misra/rule_13_2/checker.cc @@ -39,7 +39,7 @@ struct Loc { string begin_loc; }; void ReportError(string filename, int line, ResultsList* results_list) { - std::string error_message = + string error_message = "[C1605][misra-c2012-13.2]: multiple related functions should not be called in the same expression"; analyzer::proto::Result* pb_result = AddResultToResultsList(results_list, filename, line, error_message); @@ -214,8 +214,7 @@ class MemberExprCallCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(bool aggressive_mode, - analyzer::proto::ResultsList* results_list) { +void Checker::Init(bool aggressive_mode, ResultsList* results_list) { results_list_ = results_list; callback_ = new OperatorSideEffectCallback; callback_->Init(aggressive_mode, results_list_, &finder_); diff --git a/misra/rule_13_2/main.cc b/misra/rule_13_2/main.cc index e6e8841879..aadde553da 100644 --- a/misra/rule_13_2/main.cc +++ b/misra/rule_13_2/main.cc @@ -49,13 +49,13 @@ int rule_13_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_13_3/checker.cc b/misra/rule_13_3/checker.cc index c6557dd8b6..55a93c5019 100644 --- a/misra/rule_13_3/checker.cc +++ b/misra/rule_13_3/checker.cc @@ -65,7 +65,7 @@ class ExprCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C1604][misra-c2012-13.3]: expression has more than one side effects"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -80,7 +80,7 @@ class ExprCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new ExprCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_13_3/main.cc b/misra/rule_13_3/main.cc index d8719f249c..672567ce0d 100644 --- a/misra/rule_13_3/main.cc +++ b/misra/rule_13_3/main.cc @@ -47,7 +47,7 @@ int rule_13_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_13_4/checker.cc b/misra/rule_13_4/checker.cc index 3c81bae24a..a3485bf1dc 100644 --- a/misra/rule_13_4/checker.cc +++ b/misra/rule_13_4/checker.cc @@ -71,7 +71,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C1603][misra-c2012-13.4]: Result of assignment operator should not " "be used"; analyzer::proto::Result* pb_result = AddResultToResultsList( @@ -87,7 +87,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new AssignOpCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_13_4/main.cc b/misra/rule_13_4/main.cc index 6dcf21371b..dba6976c35 100644 --- a/misra/rule_13_4/main.cc +++ b/misra/rule_13_4/main.cc @@ -47,7 +47,7 @@ int rule_13_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_13_5/checker.cc b/misra/rule_13_5/checker.cc index ddf97f7672..93b8dcac52 100644 --- a/misra/rule_13_5/checker.cc +++ b/misra/rule_13_5/checker.cc @@ -64,7 +64,7 @@ class CastCallback : public MatchFinder::MatchCallback { if (!Visitor.ShouldReport(aggressive_mode_)) { return; } - std::string error_message = absl::StrFormat( + string error_message = absl::StrFormat( "[C1602][misra-c2012-13.5]: Right hand operand may have persistent side effect, Location: %s", location); analyzer::proto::Result* pb_result = diff --git a/misra/rule_13_5/main.cc b/misra/rule_13_5/main.cc index 645cb39370..ff48ee907f 100644 --- a/misra/rule_13_5/main.cc +++ b/misra/rule_13_5/main.cc @@ -48,13 +48,13 @@ int rule_13_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_14_1/checker.cc b/misra/rule_14_1/checker.cc index cd86bcabc9..05dccc693d 100644 --- a/misra/rule_14_1/checker.cc +++ b/misra/rule_14_1/checker.cc @@ -156,7 +156,7 @@ class WhileCounterCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; for_callback_ = new ForCounterCallback; for_callback_->Init(results_list_, &finder_); diff --git a/misra/rule_14_1/main.cc b/misra/rule_14_1/main.cc index aac2f8ff88..5aaffb31cb 100644 --- a/misra/rule_14_1/main.cc +++ b/misra/rule_14_1/main.cc @@ -47,13 +47,13 @@ int rule_14_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_14_2/checker.cc b/misra/rule_14_2/checker.cc index af97ed7383..302afb4416 100644 --- a/misra/rule_14_2/checker.cc +++ b/misra/rule_14_2/checker.cc @@ -429,7 +429,7 @@ class FirstDefCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; def_callback_ = new FirstDefCallback; def_callback_->Init(results_list_, &finder_); diff --git a/misra/rule_14_2/main.cc b/misra/rule_14_2/main.cc index 13460fec0e..10233cd19b 100644 --- a/misra/rule_14_2/main.cc +++ b/misra/rule_14_2/main.cc @@ -47,13 +47,13 @@ int rule_14_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_14_3/checker.cc b/misra/rule_14_3/checker.cc index bd0c78ddae..a31050156b 100644 --- a/misra/rule_14_3/checker.cc +++ b/misra/rule_14_3/checker.cc @@ -54,7 +54,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C1702][misra-c2012-14.3]: violation of misra-c2012-14.3"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, libtooling_utils::GetFilename(assign, source_manager), @@ -68,7 +68,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new AssignOpCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_14_3/main.cc b/misra/rule_14_3/main.cc index 755363155c..7f54bdef67 100644 --- a/misra/rule_14_3/main.cc +++ b/misra/rule_14_3/main.cc @@ -47,13 +47,13 @@ int rule_14_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_15_7/checker.cc b/misra/rule_15_7/checker.cc index 88f18c5a93..9cc0b91344 100644 --- a/misra/rule_15_7/checker.cc +++ b/misra/rule_15_7/checker.cc @@ -91,7 +91,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_15_7/main.cc b/misra/rule_15_7/main.cc index b1cf5d6188..b1b2c6dedb 100644 --- a/misra/rule_15_7/main.cc +++ b/misra/rule_15_7/main.cc @@ -46,7 +46,7 @@ int rule_15_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_17_5/main.cc b/misra/rule_17_5/main.cc index 6354d9d141..be54d9b3a5 100644 --- a/misra/rule_17_5/main.cc +++ b/misra/rule_17_5/main.cc @@ -48,13 +48,13 @@ int rule_17_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_17_8/checker.cc b/misra/rule_17_8/checker.cc index d80ddef354..bb8794ee3e 100644 --- a/misra/rule_17_8/checker.cc +++ b/misra/rule_17_8/checker.cc @@ -55,7 +55,7 @@ class ExprCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C1501][misra-c2012-17.8]: parameters should not be modified"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, @@ -70,7 +70,7 @@ class ExprCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new ExprCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_17_8/main.cc b/misra/rule_17_8/main.cc index 862fa0c6f3..ec1919893d 100644 --- a/misra/rule_17_8/main.cc +++ b/misra/rule_17_8/main.cc @@ -47,7 +47,7 @@ int rule_17_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_18_5/checker.cc b/misra/rule_18_5/checker.cc index f962b8b41e..a710cbd418 100644 --- a/misra/rule_18_5/checker.cc +++ b/misra/rule_18_5/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra { namespace rule_18_5 { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(unless(isExpansionInSystemHeader())).bind("var_decl"), this); @@ -59,7 +58,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { remaining_pointer); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { Decl* decl; const VarDecl* var_decl = result.Nodes.getNodeAs("var_decl"); const FieldDecl* field_decl = diff --git a/misra/rule_18_5/main.cc b/misra/rule_18_5/main.cc index a6de2ce881..257aadbba5 100644 --- a/misra/rule_18_5/main.cc +++ b/misra/rule_18_5/main.cc @@ -48,13 +48,13 @@ int rule_18_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_19_1/checker.cc b/misra/rule_19_1/checker.cc index 90592663fd..dbc4b08ec7 100644 --- a/misra/rule_19_1/checker.cc +++ b/misra/rule_19_1/checker.cc @@ -29,10 +29,9 @@ using namespace llvm; namespace misra { namespace rule_19_1 { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* e = result.Nodes.getNodeAs("op"); const VarDecl* decl = result.Nodes.getNodeAs("LDecl"); if (misra::libtooling_utils::IsInSystemHeader(e, result.Context)) { diff --git a/misra/rule_19_1/main.cc b/misra/rule_19_1/main.cc index accc106cd2..64641f7274 100644 --- a/misra/rule_19_1/main.cc +++ b/misra/rule_19_1/main.cc @@ -49,7 +49,7 @@ int rule_19_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra/rule_1_1/checker.cc b/misra/rule_1_1/checker.cc index bfe13d021f..8e0e294a4c 100644 --- a/misra/rule_1_1/checker.cc +++ b/misra/rule_1_1/checker.cc @@ -750,7 +750,8 @@ void PPCheck::MacroExpands(const Token& MacroNameTok, const MacroDefinition& MD, if (arg_count > limits_->macro_arg_limit && !source_manager_->isInSystemHeader(sl)) ReportMacroArgError( - limits_->macro_arg_limit, arg_count, MacroNameTok.getName(), + limits_->macro_arg_limit, arg_count, + MacroNameTok.getIdentifierInfo()->getName().str(), libtooling_utils::GetLocationFilename(sl, source_manager_), libtooling_utils::GetLocationLine(sl, source_manager_), results_list_); } diff --git a/misra/rule_1_1/main.cc b/misra/rule_1_1/main.cc index f11ef177ee..7c7aa53ca6 100644 --- a/misra/rule_1_1/main.cc +++ b/misra/rule_1_1/main.cc @@ -64,7 +64,7 @@ int rule_1_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_21_18/checker.cc b/misra/rule_21_18/checker.cc index b0d32e11ed..c542307ae9 100644 --- a/misra/rule_21_18/checker.cc +++ b/misra/rule_21_18/checker.cc @@ -33,9 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(QualType destination, QualType source, string loc, - std::string path, int line_number, ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(QualType destination, QualType source, string loc, string path, + int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C0403][misra-c2012-21.18]: size_t value invalid as function argument.\n" "source pointer object type: %s\n" "destination object type: %s\n" @@ -78,7 +78,7 @@ class SizetCallback : public MatchFinder::MatchCallback { clang::Expr::EvalResult rint; third_arg->EvaluateAsInt(rint, *context); if (rint.Val.isInt() && rint.Val.getInt() < 0) { - std::string path = + string path = libtooling_utils::GetFilename(third_arg, result.SourceManager); int line_number = libtooling_utils::GetLine(third_arg, result.SourceManager); @@ -96,7 +96,7 @@ class SizetCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new SizetCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_21_18/main.cc b/misra/rule_21_18/main.cc index 76d3859fc3..e1ce3dcd46 100644 --- a/misra/rule_21_18/main.cc +++ b/misra/rule_21_18/main.cc @@ -47,7 +47,7 @@ int rule_21_18(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_21_19/checker.cc b/misra/rule_21_19/checker.cc index 9ba4893318..a17235dc5c 100644 --- a/misra/rule_21_19/checker.cc +++ b/misra/rule_21_19/checker.cc @@ -33,9 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(QualType destination, QualType source, string loc, - std::string path, int line_number, ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(QualType destination, QualType source, string loc, string path, + int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "[C0402][misra-c2012-21.19]: the return value of function is assigned to non-const qualified type\n" "source pointer object type: %s\n" "destination object type: %s\n" @@ -81,7 +81,7 @@ class CastCallback : public MatchFinder::MatchCallback { if (libtooling_utils::IsInSystemHeader(withoutCast, result.Context)) { return; } - std::string path = + string path = libtooling_utils::GetFilename(withoutCast, result.SourceManager); int line_number = libtooling_utils::GetLine(withoutCast, result.SourceManager); @@ -99,11 +99,10 @@ class CastCallback : public MatchFinder::MatchCallback { return; } - std::string path = - libtooling_utils::GetFilename(withCast, result.SourceManager); + string path = libtooling_utils::GetFilename(withCast, result.SourceManager); int line_number = libtooling_utils::GetLine(withCast, result.SourceManager); - std::string location = libtooling_utils::GetLocation(withCast->getSubExpr(), - result.SourceManager); + string location = libtooling_utils::GetLocation(withCast->getSubExpr(), + result.SourceManager); QualType destination_type = withCast->getType(); QualType source_type = withCast->getSubExpr()->getType(); if (destination_type->isVoidType()) { @@ -122,7 +121,7 @@ class CastCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CastCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_21_19/main.cc b/misra/rule_21_19/main.cc index 1a8ef0a80a..95ea085e29 100644 --- a/misra/rule_21_19/main.cc +++ b/misra/rule_21_19/main.cc @@ -47,13 +47,13 @@ int rule_21_19(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_2_2/checker.cc b/misra/rule_2_2/checker.cc index a27ebafe48..c67d0d4e5e 100644 --- a/misra/rule_2_2/checker.cc +++ b/misra/rule_2_2/checker.cc @@ -54,7 +54,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { return; } - std::string error_message = + string error_message = "[C2006][misra-c2012-2.2]: A call to empty function is dead code"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, libtooling_utils::GetFilename(assign, source_manager), @@ -68,7 +68,7 @@ class AssignOpCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new AssignOpCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_2_2/main.cc b/misra/rule_2_2/main.cc index 43ce6a2a4d..e66b984264 100644 --- a/misra/rule_2_2/main.cc +++ b/misra/rule_2_2/main.cc @@ -47,13 +47,13 @@ int rule_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_2_3/checker.cc b/misra/rule_2_3/checker.cc index c418b3b3e3..6fd1ac7ea9 100644 --- a/misra/rule_2_3/checker.cc +++ b/misra/rule_2_3/checker.cc @@ -31,7 +31,7 @@ using analyzer::proto::ResultsList; namespace misra { namespace rule_2_3 { -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; finder_.addMatcher(typedefDecl().bind("typedef_decl"), this); } diff --git a/misra/rule_2_3/main.cc b/misra/rule_2_3/main.cc index e5eefb0cb7..31ec7a2253 100644 --- a/misra/rule_2_3/main.cc +++ b/misra/rule_2_3/main.cc @@ -50,7 +50,7 @@ int rule_2_3(int argc, char** argv) { CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_5_1/main.cc b/misra/rule_5_1/main.cc index c7c4940a6f..512aa863a6 100644 --- a/misra/rule_5_1/main.cc +++ b/misra/rule_5_1/main.cc @@ -52,13 +52,13 @@ int rule_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_5_6/main.cc b/misra/rule_5_6/main.cc index 4dc0e6c293..f2c419f450 100644 --- a/misra/rule_5_6/main.cc +++ b/misra/rule_5_6/main.cc @@ -48,13 +48,13 @@ int rule_5_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_5_7/checker.cc b/misra/rule_5_7/checker.cc index c1d34e0a0a..312d26afae 100644 --- a/misra/rule_5_7/checker.cc +++ b/misra/rule_5_7/checker.cc @@ -321,7 +321,7 @@ class CheckTagDeclCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new CheckTagDeclCallback; callback_->Init(results_list_, &finder_); diff --git a/misra/rule_5_7/main.cc b/misra/rule_5_7/main.cc index 5071f2bdbd..5d8e3c988a 100644 --- a/misra/rule_5_7/main.cc +++ b/misra/rule_5_7/main.cc @@ -47,13 +47,13 @@ int rule_5_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_5_8/main.cc b/misra/rule_5_8/main.cc index c2c7e77531..d532bcf383 100644 --- a/misra/rule_5_8/main.cc +++ b/misra/rule_5_8/main.cc @@ -48,13 +48,13 @@ int rule_5_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_5_9/main.cc b/misra/rule_5_9/main.cc index 61e082564f..5e1db21562 100644 --- a/misra/rule_5_9/main.cc +++ b/misra/rule_5_9/main.cc @@ -48,13 +48,13 @@ int rule_5_9(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_7_4/checker.cc b/misra/rule_7_4/checker.cc index b5d0ccf4e4..f686619b14 100644 --- a/misra/rule_7_4/checker.cc +++ b/misra/rule_7_4/checker.cc @@ -33,9 +33,9 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(string loc, std::string path, int line_number, +void ReportError(string loc, string path, int line_number, ResultsList* results_list) { - std::string error_message = absl::StrFormat( + string error_message = absl::StrFormat( "[C0901][misra-c2012-7.4]: Assignment violation of misra-c2012-7.4\n" "try to assign string literal to object with improper type\n" "Location: %s", @@ -55,7 +55,7 @@ namespace rule_7_4 { class CastCallback : public MatchFinder::MatchCallback { public: - void Init(std::map* count_str_literal_cast, + void Init(std::map* count_str_literal_cast, ResultsList* results_list, MatchFinder* finder) { count_str_literal_cast_ = count_str_literal_cast; results_list_ = results_list; @@ -73,10 +73,9 @@ class CastCallback : public MatchFinder::MatchCallback { return; } ASTContext* context = result.Context; - std::string path = libtooling_utils::GetFilename(ce, result.SourceManager); + string path = libtooling_utils::GetFilename(ce, result.SourceManager); int line_number = libtooling_utils::GetLine(ce, result.SourceManager); - std::string location = - libtooling_utils::GetLocation(ce, result.SourceManager); + string location = libtooling_utils::GetLocation(ce, result.SourceManager); if (!ce->getType()->isPointerType()) { ReportError(location, path, line_number, results_list_); return; @@ -114,8 +113,8 @@ class CastCallback : public MatchFinder::MatchCallback { }; void Checker::Init( - analyzer::proto::ResultsList* results_list, - std::map* count_str_literal_cast) { + ResultsList* results_list, + std::map* count_str_literal_cast) { results_list_ = results_list; callback_ = new CastCallback; count_str_literal_cast_ = count_str_literal_cast; diff --git a/misra/rule_7_4/main.cc b/misra/rule_7_4/main.cc index 76d7cf4c19..ef52be80e1 100644 --- a/misra/rule_7_4/main.cc +++ b/misra/rule_7_4/main.cc @@ -47,7 +47,7 @@ int rule_7_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_8_2/main.cc b/misra/rule_8_2/main.cc index 91498ab9d1..954c5bafbf 100644 --- a/misra/rule_8_2/main.cc +++ b/misra/rule_8_2/main.cc @@ -48,7 +48,7 @@ int rule_8_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_8_3/checker.cc b/misra/rule_8_3/checker.cc index a27542f0f5..9af7a5801f 100644 --- a/misra/rule_8_3/checker.cc +++ b/misra/rule_8_3/checker.cc @@ -36,7 +36,7 @@ namespace { void ReportInvalidDeclarationError(string name, string path, int line, ResultsList* results_list) { - std::string error_message = absl::StrFormat( + string error_message = absl::StrFormat( "[C0512][misra-c2012-8.3]: violation of misra-c2012-8.3 for invalid declaration\n" "Name: %s", name); @@ -57,7 +57,7 @@ void ReportError(const FunctionDecl* fd, const MatchFinder::MatchResult& result, auto path = misra::libtooling_utils::GetFilename(fd, result.SourceManager); auto line = misra::libtooling_utils::GetLine(fd, result.SourceManager); auto loc = misra::libtooling_utils::GetLocation(fd, result.SourceManager); - std::string error_message = absl::StrFormat( + string error_message = absl::StrFormat( "[C0512][misra-c2012-8.3]: violation of misra-c2012-8.3 for %s\n" "Name: %s\n" "Location: %s\n" diff --git a/misra/rule_8_3/main.cc b/misra/rule_8_3/main.cc index 12f5497923..e04c83f7b8 100644 --- a/misra/rule_8_3/main.cc +++ b/misra/rule_8_3/main.cc @@ -47,13 +47,13 @@ int rule_8_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_8_4/checker.cc b/misra/rule_8_4/checker.cc index b831c503e7..898eabb48b 100644 --- a/misra/rule_8_4/checker.cc +++ b/misra/rule_8_4/checker.cc @@ -172,7 +172,7 @@ class ExternalFDCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; vd_callback_ = new ExternalVDCallback; vd_callback_->Init(results_list_, &finder_); diff --git a/misra/rule_8_4/main.cc b/misra/rule_8_4/main.cc index 7bc83f160e..45afad3d7b 100644 --- a/misra/rule_8_4/main.cc +++ b/misra/rule_8_4/main.cc @@ -48,7 +48,7 @@ int rule_8_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra/rule_8_5/main.cc b/misra/rule_8_5/main.cc index 0985c2e3e8..e6cf78de16 100644 --- a/misra/rule_8_5/main.cc +++ b/misra/rule_8_5/main.cc @@ -48,13 +48,13 @@ int rule_8_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_8_6/main.cc b/misra/rule_8_6/main.cc index 262e8eaaad..2fc7b022c4 100644 --- a/misra/rule_8_6/main.cc +++ b/misra/rule_8_6/main.cc @@ -48,13 +48,13 @@ int rule_8_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra/rule_8_7/checker.cc b/misra/rule_8_7/checker.cc index ef072953c7..a4791cdaef 100644 --- a/misra/rule_8_7/checker.cc +++ b/misra/rule_8_7/checker.cc @@ -152,7 +152,7 @@ void Checker::Run() { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; vd_callback_ = new ExternalVDCallback; vd_callback_->Init(results_list_, &finder_, &vd_name_locations_); diff --git a/misra/rule_8_7/main.cc b/misra/rule_8_7/main.cc index 87c73c0b68..d6589074ca 100644 --- a/misra/rule_8_7/main.cc +++ b/misra/rule_8_7/main.cc @@ -48,13 +48,13 @@ int rule_8_7(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_c_2012_crules/rule_1_4/rule_1_4.go b/misra_c_2012_crules/rule_1_4/rule_1_4.go index f9604a02a2..83fe6e59da 100644 --- a/misra_c_2012_crules/rule_1_4/rule_1_4.go +++ b/misra_c_2012_crules/rule_1_4/rule_1_4.go @@ -29,7 +29,11 @@ import ( ) func Analyze(srcdir string, opts *options.CheckOptions) (*pb.ResultsList, error) { - results, err := runner.RunCppcheck(srcdir, "misra_c_2012/rule_1_4", checker_integration.Cppcheck_STU, opts) + ruleName := "misra_c_2012/rule_1_4" + if opts.JsonOption.Misra2023 != nil && *opts.JsonOption.Misra2023 { + ruleName = "misra_c_2012/rule_1_4_amd3" + } + results, err := runner.RunCppcheck(srcdir, ruleName, checker_integration.Cppcheck_STU, opts) if err != nil { glog.Error(err) return nil, err diff --git a/misra_c_2012_crules/rule_21_12/rule_21_12.go b/misra_c_2012_crules/rule_21_12/rule_21_12.go index 4e7b8c5c60..8f1fae963a 100644 --- a/misra_c_2012_crules/rule_21_12/rule_21_12.go +++ b/misra_c_2012_crules/rule_21_12/rule_21_12.go @@ -32,15 +32,25 @@ func Analyze(srcdir string, opts *options.CheckOptions) (*pb.ResultsList, error) if opts.JsonOption.Standard == "c89" || opts.JsonOption.Standard == "c90" { return &pb.ResultsList{}, nil } - - results, err := runner.RunCppcheck(srcdir, "misra_c_2012/rule_21_12", checker_integration.Cppcheck_STU, opts) + ruleName := "misra_c_2012/rule_21_12" + isMisra2023 := opts.JsonOption.Misra2023 != nil && *opts.JsonOption.Misra2023 + if isMisra2023 { + ruleName = "misra_c_2012/rule_21_12_amd3" + } + results, err := runner.RunCppcheck(srcdir, ruleName, checker_integration.Cppcheck_STU, opts) if err != nil { glog.Error(err) return nil, err } for _, v := range results.Results { if strings.HasPrefix(v.ErrorMessage, "[C0409][misra-c2012-21.12]") { - v.ErrorMessage = "[C0409][misra-c2012-21.12]: 不应使用 的异常处理特性" + if isMisra2023 { + v.ErrorMessage = "[C0409][misra-c2012-21.12]: 不得使用标准头文件 " + v.ErrorKind = pb.Result_MISRA_C_2012_RULE_21_12_AMD3 + } else { + v.ErrorMessage = "[C0409][misra-c2012-21.12]: 不应使用 的异常处理特性" + v.ErrorKind = pb.Result_MISRA_C_2012_RULE_21_12 + } } } return results, nil diff --git a/misra_cpp_2008/rule_0_1_10/libtooling/checker.cc b/misra_cpp_2008/rule_0_1_10/libtooling/checker.cc index 707111844c..9acd0264e6 100644 --- a/misra_cpp_2008/rule_0_1_10/libtooling/checker.cc +++ b/misra_cpp_2008/rule_0_1_10/libtooling/checker.cc @@ -92,7 +92,7 @@ class ParamCallback : public MatchFinder::MatchCallback { finder->addMatcher(callExpr().bind("call_fd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); if (fd) { if (!fd->doesThisDeclarationHaveABody()) return; @@ -116,7 +116,7 @@ class ParamCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; void Checker::Run() const { @@ -129,7 +129,7 @@ void Checker::Run() const { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new ParamCallback; callback_->Init(results_list, &finder_); diff --git a/misra_cpp_2008/rule_0_1_10/libtooling/main.cc b/misra_cpp_2008/rule_0_1_10/libtooling/main.cc index 81da00f192..6ef77b3c09 100644 --- a/misra_cpp_2008/rule_0_1_10/libtooling/main.cc +++ b/misra_cpp_2008/rule_0_1_10/libtooling/main.cc @@ -50,13 +50,13 @@ int rule_0_1_10(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_0_1_11/libtooling/checker.cc b/misra_cpp_2008/rule_0_1_11/libtooling/checker.cc index 13f0222736..f5c743a88f 100644 --- a/misra_cpp_2008/rule_0_1_11/libtooling/checker.cc +++ b/misra_cpp_2008/rule_0_1_11/libtooling/checker.cc @@ -63,7 +63,7 @@ class ParamCallback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* callback_fd = result.Nodes.getNodeAs("callback_fd"); @@ -133,13 +133,13 @@ class ParamCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; // key is function qualifier(if any) + function name, value is a list of // function references with the given key as name. std::unordered_map> callback_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new ParamCallback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_0_1_11/libtooling/main.cc b/misra_cpp_2008/rule_0_1_11/libtooling/main.cc index efa282a993..b7bf53fbac 100644 --- a/misra_cpp_2008/rule_0_1_11/libtooling/main.cc +++ b/misra_cpp_2008/rule_0_1_11/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_0_1_11(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_0_1_12/libtooling/checker.cc b/misra_cpp_2008/rule_0_1_12/libtooling/checker.cc index fe29334b08..0de6c0a53e 100644 --- a/misra_cpp_2008/rule_0_1_12/libtooling/checker.cc +++ b/misra_cpp_2008/rule_0_1_12/libtooling/checker.cc @@ -61,7 +61,7 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXMethodDecl* fd = result.Nodes.getNodeAs("bad_md"); // skip system header @@ -126,12 +126,12 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::unordered_map> checked_fd_; std::unordered_map> param_use_count_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_0_1_12/libtooling/main.cc b/misra_cpp_2008/rule_0_1_12/libtooling/main.cc index d9970d96f7..f010a3249e 100644 --- a/misra_cpp_2008/rule_0_1_12/libtooling/main.cc +++ b/misra_cpp_2008/rule_0_1_12/libtooling/main.cc @@ -50,13 +50,13 @@ int rule_0_1_12(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_0_1_4/libtooling/checker.cc b/misra_cpp_2008/rule_0_1_4/libtooling/checker.cc index 62c954b0b7..39d3f201a7 100644 --- a/misra_cpp_2008/rule_0_1_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_0_1_4/libtooling/checker.cc @@ -54,7 +54,7 @@ namespace libtooling { * not violate this rule. */ -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; finder_.addMatcher(varDecl(unless(parmVarDecl())).bind("var_decl"), this); finder_.addMatcher( diff --git a/misra_cpp_2008/rule_0_1_4/libtooling/main.cc b/misra_cpp_2008/rule_0_1_4/libtooling/main.cc index d463e4ddb3..450d2a50a4 100644 --- a/misra_cpp_2008/rule_0_1_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_0_1_4/libtooling/main.cc @@ -51,7 +51,7 @@ int rule_0_1_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_0_1_5/libtooling/rule_0_1_5.cc b/misra_cpp_2008/rule_0_1_5/libtooling/rule_0_1_5.cc index e7353df2be..1cbe17d6c5 100644 --- a/misra_cpp_2008/rule_0_1_5/libtooling/rule_0_1_5.cc +++ b/misra_cpp_2008/rule_0_1_5/libtooling/rule_0_1_5.cc @@ -47,13 +47,13 @@ int rule_0_1_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_0_1_8/libtooling/checker.cc b/misra_cpp_2008/rule_0_1_8/libtooling/checker.cc index 7f9e28e928..350be0aa7c 100644 --- a/misra_cpp_2008/rule_0_1_8/libtooling/checker.cc +++ b/misra_cpp_2008/rule_0_1_8/libtooling/checker.cc @@ -62,7 +62,7 @@ namespace libtooling { // which writes to a file) // - does not raise any exception // We need to report on definition, so declaration is skipped. -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; finder_.addMatcher( // have no parameter whose type is a pointer type or reference type diff --git a/misra_cpp_2008/rule_0_1_8/libtooling/main.cc b/misra_cpp_2008/rule_0_1_8/libtooling/main.cc index 8b8dd5e790..7d64b2b3ac 100644 --- a/misra_cpp_2008/rule_0_1_8/libtooling/main.cc +++ b/misra_cpp_2008/rule_0_1_8/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_0_1_8(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_10_1_2/libtooling/checker.cc b/misra_cpp_2008/rule_10_1_2/libtooling/checker.cc index 6458ac33f2..4b07c95024 100644 --- a/misra_cpp_2008/rule_10_1_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_10_1_2/libtooling/checker.cc @@ -70,9 +70,8 @@ inline const CXXRecordDecl* GetBaseClass( return base_specifier.getType()->getAsCXXRecordDecl(); } -void ReportError(std::string filepath, int line_number, - ResultsList* results_list) { - std::string error_message = absl::StrFormat( +void ReportError(string filepath, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat( "只有在用于菱形层次结构(diamond hierarchy)时,才能声明一个基类为虚拟基类"); analyzer::proto::Result* pb_result = AddResultToResultsList( results_list, filepath, line_number, error_message); diff --git a/misra_cpp_2008/rule_10_1_2/libtooling/main.cc b/misra_cpp_2008/rule_10_1_2/libtooling/main.cc index 56489d994d..2dd014d8f6 100644 --- a/misra_cpp_2008/rule_10_1_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_10_1_2/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_10_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_10_1_3/libtooling/main.cc b/misra_cpp_2008/rule_10_1_3/libtooling/main.cc index 1fdec4b189..e1cf600618 100644 --- a/misra_cpp_2008/rule_10_1_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_10_1_3/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_10_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_10_3_1/libtooling/main.cc b/misra_cpp_2008/rule_10_3_1/libtooling/main.cc index ad6ea0aa63..c1e9387ded 100644 --- a/misra_cpp_2008/rule_10_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_10_3_1/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_10_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_10_3_2/libtooling/main.cc b/misra_cpp_2008/rule_10_3_2/libtooling/main.cc index ccabca9260..e42bd3c211 100644 --- a/misra_cpp_2008/rule_10_3_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_10_3_2/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_10_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_10_3_3/libtooling/main.cc b/misra_cpp_2008/rule_10_3_3/libtooling/main.cc index 4a16b2a584..06ade8f9f5 100644 --- a/misra_cpp_2008/rule_10_3_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_10_3_3/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_10_3_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_11_0_1/libtooling/main.cc b/misra_cpp_2008/rule_11_0_1/libtooling/main.cc index 7a0b3c52b3..c4287bab8e 100644 --- a/misra_cpp_2008/rule_11_0_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_11_0_1/libtooling/main.cc @@ -49,13 +49,13 @@ int rule_11_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_12_1_1/libtooling/checker.cc b/misra_cpp_2008/rule_12_1_1/libtooling/checker.cc index c7d601ed8e..449385b5f2 100644 --- a/misra_cpp_2008/rule_12_1_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_12_1_1/libtooling/checker.cc @@ -50,10 +50,9 @@ namespace libtooling { * constructor/destructor are matched and then checked they are purely virtual * in 'VirtualCallToVirtualFunction'. */ -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -114,9 +113,8 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { // check if the contructor/destructor contains a virtual call to a virtual // function, return false if such call does not exist - bool VirtualCallToVirtualFunction( - const ast_matchers::MatchFinder::MatchResult& result, - const CallExpr* callexpr) { + bool VirtualCallToVirtualFunction(const MatchFinder::MatchResult& result, + const CallExpr* callexpr) { // get the function declaration const FunctionDecl* func_decl = callexpr->getDirectCallee(); if (func_decl == nullptr) { @@ -147,7 +145,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { return true; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXDynamicCastExpr* dcast = result.Nodes.getNodeAs("dcast"); const CallExpr* callexpr = result.Nodes.getNodeAs("callexpr"); diff --git a/misra_cpp_2008/rule_12_1_1/libtooling/main.cc b/misra_cpp_2008/rule_12_1_1/libtooling/main.cc index bc754a918b..0a9d78498b 100644 --- a/misra_cpp_2008/rule_12_1_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_12_1_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_12_1_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_12_1_3/libtooling/checker.cc b/misra_cpp_2008/rule_12_1_3/libtooling/checker.cc index 8822bfaa2c..f0b8010548 100644 --- a/misra_cpp_2008/rule_12_1_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_12_1_3/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_12_1_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -44,7 +43,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* s = result.Nodes.getNodeAs("decl"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { diff --git a/misra_cpp_2008/rule_12_1_3/libtooling/main.cc b/misra_cpp_2008/rule_12_1_3/libtooling/main.cc index b6865e1d9c..662a62873f 100644 --- a/misra_cpp_2008/rule_12_1_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_12_1_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_12_1_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_12_8_1/libtooling/checker.cc b/misra_cpp_2008/rule_12_8_1/libtooling/checker.cc index 4165a9ffe5..02aa2f05ea 100644 --- a/misra_cpp_2008/rule_12_8_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_12_8_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_12_8_1/libtooling/checker.h" @@ -60,7 +72,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(decl_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(decl_, result.SourceManager); diff --git a/misra_cpp_2008/rule_12_8_1/libtooling/checker.h b/misra_cpp_2008/rule_12_8_1/libtooling/checker.h index 49a1b96167..f3b4bed311 100644 --- a/misra_cpp_2008/rule_12_8_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_12_8_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_12_8_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_12_8_1/libtooling/main.cc b/misra_cpp_2008/rule_12_8_1/libtooling/main.cc index ee87016fd0..8abab57060 100644 --- a/misra_cpp_2008/rule_12_8_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_12_8_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_12_8_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_12_8_2/libtooling/checker.cc b/misra_cpp_2008/rule_12_8_2/libtooling/checker.cc index e2311f560c..ed97dba5da 100644 --- a/misra_cpp_2008/rule_12_8_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_12_8_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_12_8_2/libtooling/checker.h" @@ -51,7 +63,7 @@ class Callback : public MatchFinder::MatchCallback { const CXXMethodDecl* assign_ = result.Nodes.getNodeAs("assign"); const CXXRecordDecl* cls_ = result.Nodes.getNodeAs("cls"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(assign_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(assign_, result.SourceManager); diff --git a/misra_cpp_2008/rule_12_8_2/libtooling/checker.h b/misra_cpp_2008/rule_12_8_2/libtooling/checker.h index 0741ff2549..5fe195227f 100644 --- a/misra_cpp_2008/rule_12_8_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_12_8_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_12_8_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_12_8_2/libtooling/main.cc b/misra_cpp_2008/rule_12_8_2/libtooling/main.cc index 39a48d5c6a..30c78fd82c 100644 --- a/misra_cpp_2008/rule_12_8_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_12_8_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_12_8_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_14_5_1/libtooling/checker.cc b/misra_cpp_2008/rule_14_5_1/libtooling/checker.cc index f57da0f391..a5d15aef2a 100644 --- a/misra_cpp_2008/rule_14_5_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_5_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_14_5_1/libtooling/checker.h" @@ -124,7 +136,7 @@ class GenericFDCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd_ = result.Nodes.getNodeAs("fd"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(fd_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(fd_, result.SourceManager); @@ -156,10 +168,10 @@ class GenericFDCallback : public MatchFinder::MatchCallback { string loc2) { string error_message = "非成员泛型函数只能在不是关联命名空间的命名空间中声明"; - std::vector locations{loc1, loc2}; + std::vector locations{loc1, loc2}; analyzer::proto::Result* pb_result = - misra::proto_util::AddMultipleLocationsResultToResultsList( - results_list_, filename, line, error_message, locations); + AddMultipleLocationsResultToResultsList(results_list_, filename, line, + error_message, locations); pb_result->set_error_kind( analyzer::proto::Result_ErrorKind_MISRA_CPP_2008_RULE_14_5_1); pb_result->set_name(name); diff --git a/misra_cpp_2008/rule_14_5_1/libtooling/checker.h b/misra_cpp_2008/rule_14_5_1/libtooling/checker.h index ba84581f5e..24ef4cd590 100644 --- a/misra_cpp_2008/rule_14_5_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_14_5_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_14_5_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_14_5_1/libtooling/main.cc b/misra_cpp_2008/rule_14_5_1/libtooling/main.cc index b2bc321340..77bdbef20c 100644 --- a/misra_cpp_2008/rule_14_5_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_5_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_14_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_14_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_14_5_2/libtooling/checker.cc index 73887e8344..ae89c76a61 100644 --- a/misra_cpp_2008/rule_14_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_5_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_14_5_2/libtooling/checker.h" @@ -48,7 +60,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const CXXConstructorDecl* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(decl_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(decl_, result.SourceManager); @@ -71,7 +83,7 @@ class Callback : public MatchFinder::MatchCallback { // section of Deleted implicitly-declared copy constructor of the above // link for the conditions. const CXXRecordDecl* cls = result.Nodes.getNodeAs("cls"); - std::string cls_path = + string cls_path = misra::libtooling_utils::GetFilename(cls, result.SourceManager); int cls_line_number = misra::libtooling_utils::GetLine(cls, result.SourceManager); @@ -84,7 +96,7 @@ class Callback : public MatchFinder::MatchCallback { if (!ctor->isCopyConstructor()) { continue; } - std::string ctor_path = + string ctor_path = misra::libtooling_utils::GetFilename(ctor, result.SourceManager); int ctor_line_number = misra::libtooling_utils::GetLine(ctor, result.SourceManager); diff --git a/misra_cpp_2008/rule_14_5_2/libtooling/checker.h b/misra_cpp_2008/rule_14_5_2/libtooling/checker.h index c3db898520..defc0632b3 100644 --- a/misra_cpp_2008/rule_14_5_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_14_5_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_14_5_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_14_5_2/libtooling/main.cc b/misra_cpp_2008/rule_14_5_2/libtooling/main.cc index 0fc53e87ea..90a5515d15 100644 --- a/misra_cpp_2008/rule_14_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_5_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_14_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_14_5_3/libtooling/checker.cc b/misra_cpp_2008/rule_14_5_3/libtooling/checker.cc index f4b0f77f55..7f3ac04f7b 100644 --- a/misra_cpp_2008/rule_14_5_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_5_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_14_5_3/libtooling/checker.h" @@ -47,7 +59,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const CXXMethodDecl* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(decl_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(decl_, result.SourceManager); @@ -70,7 +82,7 @@ class Callback : public MatchFinder::MatchCallback { // section of Deleted implicitly-declared copy assignment operator of the // above link for the conditions. const CXXRecordDecl* cls = result.Nodes.getNodeAs("cls"); - std::string cls_path = + string cls_path = misra::libtooling_utils::GetFilename(cls, result.SourceManager); int cls_line_number = misra::libtooling_utils::GetLine(cls, result.SourceManager); @@ -84,7 +96,7 @@ class Callback : public MatchFinder::MatchCallback { if (!method->isCopyAssignmentOperator()) { continue; } - std::string method_path = + string method_path = misra::libtooling_utils::GetFilename(method, result.SourceManager); int method_line_number = misra::libtooling_utils::GetLine(method, result.SourceManager); diff --git a/misra_cpp_2008/rule_14_5_3/libtooling/checker.h b/misra_cpp_2008/rule_14_5_3/libtooling/checker.h index 7eb7c82d53..baf933f0d8 100644 --- a/misra_cpp_2008/rule_14_5_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_14_5_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_14_5_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_14_5_3/libtooling/main.cc b/misra_cpp_2008/rule_14_5_3/libtooling/main.cc index db7b2dff62..c8de025cae 100644 --- a/misra_cpp_2008/rule_14_5_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_5_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_14_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_14_6_1/libtooling/checker.cc b/misra_cpp_2008/rule_14_6_1/libtooling/checker.cc index 1f262e5de8..b6e90ff503 100644 --- a/misra_cpp_2008/rule_14_6_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_6_1/libtooling/checker.cc @@ -69,7 +69,7 @@ unordered_map> dependent_base_names_; // if not, report class InfoFillCallback : public MatchFinder::MatchCallback { public: - void Init(ast_matchers::MatchFinder* finder) { + void Init(MatchFinder* finder) { finder->addMatcher( classTemplateDecl(hasDescendant( cxxRecordDecl(forEachDescendant(namedDecl().bind("name"))) @@ -87,8 +87,7 @@ class InfoFillCallback : public MatchFinder::MatchCallback { class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( classTemplateDecl( @@ -183,7 +182,7 @@ class Callback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; string GetDependentBaseClassName(string base) { auto pos = base.find("<"); if (pos == string::npos) { @@ -247,7 +246,7 @@ void InfoFillChecker::Init() { callback_ = new InfoFillCallback; callback_->Init(&finder_); } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_14_6_1/libtooling/main.cc b/misra_cpp_2008/rule_14_6_1/libtooling/main.cc index ee4e46529c..577a5f1c98 100644 --- a/misra_cpp_2008/rule_14_6_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_6_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_14_6_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_14_6_2/libtooling/checker.cc b/misra_cpp_2008/rule_14_6_2/libtooling/checker.cc index 47dbfdef53..1bffc211c4 100644 --- a/misra_cpp_2008/rule_14_6_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_6_2/libtooling/checker.cc @@ -30,16 +30,15 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_14_6_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(callExpr(usesADL()).bind("call"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CallExpr* ce = result.Nodes.getNodeAs("call"); if (misra::libtooling_utils::IsInSystemHeader(ce, result.Context)) { diff --git a/misra_cpp_2008/rule_14_6_2/libtooling/main.cc b/misra_cpp_2008/rule_14_6_2/libtooling/main.cc index 9ea9df1f67..388a72a4fd 100644 --- a/misra_cpp_2008/rule_14_6_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_6_2/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_14_6_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_14_7_1/libtooling/checker.cc b/misra_cpp_2008/rule_14_7_1/libtooling/checker.cc index 6fd58689b0..187cd91b5a 100644 --- a/misra_cpp_2008/rule_14_7_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_7_1/libtooling/checker.cc @@ -44,17 +44,15 @@ void ReportError(const Decl* decl, SourceManager* sm, namespace misra_cpp_2008 { namespace rule_14_7_1 { namespace libtooling { -class ClassTemplateDeclCallback - : public ast_matchers::MatchFinder::MatchCallback { +class ClassTemplateDeclCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { this->results_list_ = results_list; finder->addMatcher(classTemplateDecl().bind("class_template_unins"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ClassTemplateDecl* class_template = result.Nodes.getNodeAs("class_template_unins"); if (misra::libtooling_utils::IsInSystemHeader(class_template, @@ -68,14 +66,12 @@ class ClassTemplateDeclCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -class ClassTemplateInstanceCallback - : public ast_matchers::MatchFinder::MatchCallback { +class ClassTemplateInstanceCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(classTemplateSpecializationDecl( @@ -102,7 +98,7 @@ class ClassTemplateInstanceCallback this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXMethodDecl* cxx_method = result.Nodes.getNodeAs("method"); const FieldDecl* field_decl = @@ -150,20 +146,18 @@ class ClassTemplateInstanceCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -class FuncTemplateInitCallback - : public ast_matchers::MatchFinder::MatchCallback { +class FuncTemplateInitCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { this->results_list_ = results_list; finder->addMatcher(functionTemplateDecl().bind("func_template"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const FunctionTemplateDecl* func_template = result.Nodes.getNodeAs("func_template"); if (misra::libtooling_utils::IsInSystemHeader(func_template, @@ -177,10 +171,10 @@ class FuncTemplateInitCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { class_template_decl_callback_ = new ClassTemplateDeclCallback; class_template_decl_callback_->Init(results_list, &finder_); class_template_callback_ = new ClassTemplateInstanceCallback; diff --git a/misra_cpp_2008/rule_14_7_1/libtooling/main.cc b/misra_cpp_2008/rule_14_7_1/libtooling/main.cc index ceabea1c5c..8affd7ef3e 100644 --- a/misra_cpp_2008/rule_14_7_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_7_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_14_7_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_14_7_2/libtooling/checker.cc b/misra_cpp_2008/rule_14_7_2/libtooling/checker.cc index 1a1eb11e41..63f7de3bf2 100644 --- a/misra_cpp_2008/rule_14_7_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_7_2/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_14_7_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(classTemplateSpecializationDecl( @@ -42,7 +41,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXMethodDecl* method = result.Nodes.getNodeAs("method"); diff --git a/misra_cpp_2008/rule_14_7_2/libtooling/main.cc b/misra_cpp_2008/rule_14_7_2/libtooling/main.cc index 1be8c5fff6..3746cd9be4 100644 --- a/misra_cpp_2008/rule_14_7_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_7_2/libtooling/main.cc @@ -50,13 +50,13 @@ int rule_14_7_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_14_7_3/libtooling/checker.cc b/misra_cpp_2008/rule_14_7_3/libtooling/checker.cc index ec1d48264e..9c373fda27 100644 --- a/misra_cpp_2008/rule_14_7_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_7_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_14_7_3/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_14_7_3/libtooling/checker.h b/misra_cpp_2008/rule_14_7_3/libtooling/checker.h index 9cbe68cfe6..cf4aa8212d 100644 --- a/misra_cpp_2008/rule_14_7_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_14_7_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_14_7_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_14_7_3/libtooling/main.cc b/misra_cpp_2008/rule_14_7_3/libtooling/main.cc index cddee64e78..dee8ac821e 100644 --- a/misra_cpp_2008/rule_14_7_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_7_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_14_7_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_14_8_1/libtooling/checker.cc b/misra_cpp_2008/rule_14_8_1/libtooling/checker.cc index a1a56dd187..34df1949db 100644 --- a/misra_cpp_2008/rule_14_8_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_14_8_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_14_8_1/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_14_8_1/libtooling/checker.h b/misra_cpp_2008/rule_14_8_1/libtooling/checker.h index 771c40c245..6b2efab7bd 100644 --- a/misra_cpp_2008/rule_14_8_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_14_8_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_14_8_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_14_8_1/libtooling/main.cc b/misra_cpp_2008/rule_14_8_1/libtooling/main.cc index 33476475bd..7347568938 100644 --- a/misra_cpp_2008/rule_14_8_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_14_8_1/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_14_8_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_15_0_2/libtooling/checker.cc b/misra_cpp_2008/rule_15_0_2/libtooling/checker.cc index 5a0bfc9f31..aa9f1a5c7c 100644 --- a/misra_cpp_2008/rule_15_0_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_0_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_0_2/libtooling/checker.h" @@ -54,7 +66,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_0_2/libtooling/checker.h b/misra_cpp_2008/rule_15_0_2/libtooling/checker.h index 7244f8d129..750547c4e0 100644 --- a/misra_cpp_2008/rule_15_0_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_0_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_0_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_0_2/libtooling/main.cc b/misra_cpp_2008/rule_15_0_2/libtooling/main.cc index 9730532b73..d9af73fa3b 100644 --- a/misra_cpp_2008/rule_15_0_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_0_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_1_1/libtooling/checker.cc b/misra_cpp_2008/rule_15_1_1/libtooling/checker.cc index 261f0a66e6..ef7d55b248 100644 --- a/misra_cpp_2008/rule_15_1_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_1_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_1_1/libtooling/checker.hh" @@ -123,7 +135,7 @@ bool Callback::HasException(const Expr* e) { return false; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_1_1/libtooling/checker.hh b/misra_cpp_2008/rule_15_1_1/libtooling/checker.hh index 922543bf6b..278111be79 100644 --- a/misra_cpp_2008/rule_15_1_1/libtooling/checker.hh +++ b/misra_cpp_2008/rule_15_1_1/libtooling/checker.hh @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_1_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_1_1/libtooling/main.cc b/misra_cpp_2008/rule_15_1_1/libtooling/main.cc index 4d6ddcbc29..6d6ae4acc8 100644 --- a/misra_cpp_2008/rule_15_1_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_1_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_1_2/libtooling/checker.cc b/misra_cpp_2008/rule_15_1_2/libtooling/checker.cc index ff6783a55c..aecd372a6f 100644 --- a/misra_cpp_2008/rule_15_1_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_1_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_1_2/libtooling/checker.h" @@ -54,7 +66,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_1_2/libtooling/checker.h b/misra_cpp_2008/rule_15_1_2/libtooling/checker.h index 6f5b540d15..149654216f 100644 --- a/misra_cpp_2008/rule_15_1_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_1_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_1_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_1_2/libtooling/main.cc b/misra_cpp_2008/rule_15_1_2/libtooling/main.cc index 33bb10f0e4..992f661004 100644 --- a/misra_cpp_2008/rule_15_1_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_1_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_1_3/libtooling/checker.cc b/misra_cpp_2008/rule_15_1_3/libtooling/checker.cc index dcc1d70af7..37e334d3d5 100644 --- a/misra_cpp_2008/rule_15_1_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_1_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_1_3/libtooling/checker.h" @@ -53,7 +65,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_1_3/libtooling/checker.h b/misra_cpp_2008/rule_15_1_3/libtooling/checker.h index e287469912..76b38e9880 100644 --- a/misra_cpp_2008/rule_15_1_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_1_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_1_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_1_3/libtooling/main.cc b/misra_cpp_2008/rule_15_1_3/libtooling/main.cc index 12df8f362e..57029fd6f0 100644 --- a/misra_cpp_2008/rule_15_1_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_1_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_1_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_3_3/libtooling/checker.cc b/misra_cpp_2008/rule_15_3_3/libtooling/checker.cc index 8acd851518..f347693127 100644 --- a/misra_cpp_2008/rule_15_3_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_3_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_3_3/libtooling/checker.h" @@ -58,7 +70,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_3_3/libtooling/checker.h b/misra_cpp_2008/rule_15_3_3/libtooling/checker.h index 1801fe43ce..c7c7dacf81 100644 --- a/misra_cpp_2008/rule_15_3_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_3_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_3_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_3_3/libtooling/main.cc b/misra_cpp_2008/rule_15_3_3/libtooling/main.cc index 20e8782164..f59bb07822 100644 --- a/misra_cpp_2008/rule_15_3_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_3_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_3_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_3_5/libtooling/checker.cc b/misra_cpp_2008/rule_15_3_5/libtooling/checker.cc index 6f65363100..803a9dccb8 100644 --- a/misra_cpp_2008/rule_15_3_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_3_5/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_3_5/libtooling/checker.h" @@ -55,7 +67,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_3_5/libtooling/checker.h b/misra_cpp_2008/rule_15_3_5/libtooling/checker.h index 6ada343929..685af1ecca 100644 --- a/misra_cpp_2008/rule_15_3_5/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_3_5/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_3_5_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_3_5/libtooling/main.cc b/misra_cpp_2008/rule_15_3_5/libtooling/main.cc index 0cb46e4d83..85179eb79e 100644 --- a/misra_cpp_2008/rule_15_3_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_3_5/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_15_3_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_15_4_1/libtooling/checker.cc b/misra_cpp_2008/rule_15_4_1/libtooling/checker.cc index 084bb0629b..4e79468568 100644 --- a/misra_cpp_2008/rule_15_4_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_4_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_15_4_1/libtooling/checker.h" @@ -43,18 +55,17 @@ namespace libtooling { struct ExceptionSpecInfo { string file; int linenum; - std::set exceptions; + std::set exceptions; }; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl().bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* d = result.Nodes.getNodeAs("d"); string name = d->getQualifiedNameAsString(); auto excepts = d->getType() @@ -92,11 +103,11 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_infos_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_15_4_1/libtooling/checker.h b/misra_cpp_2008/rule_15_4_1/libtooling/checker.h index 22a1c1cc06..7f8c0f3a92 100644 --- a/misra_cpp_2008/rule_15_4_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_15_4_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_15_4_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_15_4_1/libtooling/main.cc b/misra_cpp_2008/rule_15_4_1/libtooling/main.cc index 9e71bfc4cd..e78fd066c9 100644 --- a/misra_cpp_2008/rule_15_4_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_4_1/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_15_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_15_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_15_5_2/libtooling/checker.cc index 73ca7d04cb..6b0641b37f 100644 --- a/misra_cpp_2008/rule_15_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_15_5_2/libtooling/checker.cc @@ -33,10 +33,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_15_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -47,7 +46,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd = result.Nodes.getNodeAs("decl"); const Expr* s = result.Nodes.getNodeAs("throw_type"); diff --git a/misra_cpp_2008/rule_15_5_2/libtooling/main.cc b/misra_cpp_2008/rule_15_5_2/libtooling/main.cc index 2b3ad23fff..1081133a36 100644 --- a/misra_cpp_2008/rule_15_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_15_5_2/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_15_5_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_16_0_3/libtooling/checker.cc b/misra_cpp_2008/rule_16_0_3/libtooling/checker.cc index fdf21ad718..6137c7c28f 100644 --- a/misra_cpp_2008/rule_16_0_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_16_0_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_16_0_3/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_16_0_3/libtooling/checker.h b/misra_cpp_2008/rule_16_0_3/libtooling/checker.h index 92c1e7f260..9392cb98cc 100644 --- a/misra_cpp_2008/rule_16_0_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_16_0_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_16_0_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_16_0_3/libtooling/main.cc b/misra_cpp_2008/rule_16_0_3/libtooling/main.cc index 87862c6fe8..217c32f11d 100644 --- a/misra_cpp_2008/rule_16_0_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_16_0_3/libtooling/main.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include @@ -37,7 +49,7 @@ int rule_16_0_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_16_0_4/libtooling/checker.cc b/misra_cpp_2008/rule_16_0_4/libtooling/checker.cc index 0c592c6f1b..636b091602 100644 --- a/misra_cpp_2008/rule_16_0_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_16_0_4/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_16_0_4/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_16_0_4/libtooling/checker.h b/misra_cpp_2008/rule_16_0_4/libtooling/checker.h index f2ac40bc85..3a03fbb83d 100644 --- a/misra_cpp_2008/rule_16_0_4/libtooling/checker.h +++ b/misra_cpp_2008/rule_16_0_4/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_16_0_4_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_16_0_4/libtooling/main.cc b/misra_cpp_2008/rule_16_0_4/libtooling/main.cc index 1c3f71be3e..6e74a0c716 100644 --- a/misra_cpp_2008/rule_16_0_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_16_0_4/libtooling/main.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include @@ -37,7 +49,7 @@ int rule_16_0_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_16_0_6/libtooling/checker.cc b/misra_cpp_2008/rule_16_0_6/libtooling/checker.cc index fd01569445..1de55dde85 100644 --- a/misra_cpp_2008/rule_16_0_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_16_0_6/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_16_0_6/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_16_0_6/libtooling/checker.h b/misra_cpp_2008/rule_16_0_6/libtooling/checker.h index f9b78342c6..04bd6b82be 100644 --- a/misra_cpp_2008/rule_16_0_6/libtooling/checker.h +++ b/misra_cpp_2008/rule_16_0_6/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_16_0_6_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_16_0_6/libtooling/main.cc b/misra_cpp_2008/rule_16_0_6/libtooling/main.cc index d2fa341c36..446ffcbcd6 100644 --- a/misra_cpp_2008/rule_16_0_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_16_0_6/libtooling/main.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include @@ -37,13 +49,13 @@ int rule_16_0_6(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_17_0_1/libtooling/checker.cc b/misra_cpp_2008/rule_17_0_1/libtooling/checker.cc index f93f50286a..5d31193d29 100644 --- a/misra_cpp_2008/rule_17_0_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_17_0_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_17_0_1/libtooling/checker.h" @@ -92,7 +104,7 @@ void VarDeclVisitor::Init(analyzer::proto::ResultsList* results_list, bool VarDeclVisitor::VisitVarDecl(clang::VarDecl* vd) { if (source_manager_->isInSystemHeader(vd->getBeginLoc())) return true; // skip system header - std::string name = vd->getNameAsString(); + string name = vd->getNameAsString(); if (objects_.find(name) != objects_.end()) { auto loc = vd->getBeginLoc(); string path = diff --git a/misra_cpp_2008/rule_17_0_1/libtooling/checker.h b/misra_cpp_2008/rule_17_0_1/libtooling/checker.h index 2bd4359306..4c664e2c4f 100644 --- a/misra_cpp_2008/rule_17_0_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_17_0_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_17_0_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_17_0_1/libtooling/main.cc b/misra_cpp_2008/rule_17_0_1/libtooling/main.cc index d82e8edd11..94c3945b91 100644 --- a/misra_cpp_2008/rule_17_0_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_17_0_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_17_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_17_0_2/libtooling/checker.cc b/misra_cpp_2008/rule_17_0_2/libtooling/checker.cc index 1333cd42c4..85f915adc5 100644 --- a/misra_cpp_2008/rule_17_0_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_17_0_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_17_0_2/libtooling/checker.h" @@ -137,7 +149,7 @@ void VarDeclVisitor::Init(analyzer::proto::ResultsList* results_list, bool VarDeclVisitor::VisitVarDecl(clang::VarDecl* vd) { if (source_manager_->isInSystemHeader(vd->getBeginLoc())) return true; // skip system header - std::string name = vd->getNameAsString(); + string name = vd->getNameAsString(); if (objects_.find(name) != objects_.end()) { auto loc = vd->getBeginLoc(); string path = diff --git a/misra_cpp_2008/rule_17_0_2/libtooling/checker.h b/misra_cpp_2008/rule_17_0_2/libtooling/checker.h index 4852444cde..2c98c45125 100644 --- a/misra_cpp_2008/rule_17_0_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_17_0_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_17_0_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_17_0_2/libtooling/main.cc b/misra_cpp_2008/rule_17_0_2/libtooling/main.cc index d14f889379..462819c917 100644 --- a/misra_cpp_2008/rule_17_0_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_17_0_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_17_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_0_2/libtooling/checker.cc b/misra_cpp_2008/rule_18_0_2/libtooling/checker.cc index 789e610280..fddf654e3c 100644 --- a/misra_cpp_2008/rule_18_0_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_0_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_0_2/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用库 中的库函数 atof、atoi 和 atol"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,16 +43,14 @@ namespace misra_cpp_2008 { namespace rule_18_0_2 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -60,10 +69,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_0_2/libtooling/checker.h b/misra_cpp_2008/rule_18_0_2/libtooling/checker.h index bb9b7e7075..25832456df 100644 --- a/misra_cpp_2008/rule_18_0_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_0_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_0_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_0_2/libtooling/main.cc b/misra_cpp_2008/rule_18_0_2/libtooling/main.cc index 4433f08593..d01c071776 100644 --- a/misra_cpp_2008/rule_18_0_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_0_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_0_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_0_3/libtooling/checker.cc b/misra_cpp_2008/rule_18_0_3/libtooling/checker.cc index 12724bc5eb..4ec9ab94da 100644 --- a/misra_cpp_2008/rule_18_0_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_0_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_0_3/libtooling/checker.h" @@ -23,8 +35,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用库 中的库函数 abort、exit、getenv 和 system"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -33,16 +44,14 @@ namespace misra_cpp_2008 { namespace rule_18_0_3 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -71,10 +80,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_0_3/libtooling/checker.h b/misra_cpp_2008/rule_18_0_3/libtooling/checker.h index 4a60a00a31..4a6f2fe596 100644 --- a/misra_cpp_2008/rule_18_0_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_0_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_0_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_0_3/libtooling/main.cc b/misra_cpp_2008/rule_18_0_3/libtooling/main.cc index 03d1dd99f7..ff13dcf004 100644 --- a/misra_cpp_2008/rule_18_0_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_0_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_0_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_0_4/libtooling/checker.cc b/misra_cpp_2008/rule_18_0_4/libtooling/checker.cc index f594df0e31..4611f3ecc8 100644 --- a/misra_cpp_2008/rule_18_0_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_0_4/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_0_4/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用库 的时间处理功能"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,16 +43,14 @@ namespace misra_cpp_2008 { namespace rule_18_0_4 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -62,10 +71,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_0_4/libtooling/checker.h b/misra_cpp_2008/rule_18_0_4/libtooling/checker.h index e769bf16b9..0d632cbeec 100644 --- a/misra_cpp_2008/rule_18_0_4/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_0_4/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_0_4_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_0_4/libtooling/main.cc b/misra_cpp_2008/rule_18_0_4/libtooling/main.cc index 7e3093dd90..e2be7593e3 100644 --- a/misra_cpp_2008/rule_18_0_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_0_4/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_0_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_0_5/libtooling/checker.cc b/misra_cpp_2008/rule_18_0_5/libtooling/checker.cc index 30d9a8d4ea..412d054f98 100644 --- a/misra_cpp_2008/rule_18_0_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_0_5/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_0_5/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用库 的无边界限制函数"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,16 +43,14 @@ namespace misra_cpp_2008 { namespace rule_18_0_5 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -63,10 +72,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_0_5/libtooling/checker.h b/misra_cpp_2008/rule_18_0_5/libtooling/checker.h index 241909bc33..c1dc7642ba 100644 --- a/misra_cpp_2008/rule_18_0_5/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_0_5/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_0_5_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_0_5/libtooling/main.cc b/misra_cpp_2008/rule_18_0_5/libtooling/main.cc index b770f45b34..eb4e42a892 100644 --- a/misra_cpp_2008/rule_18_0_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_0_5/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_0_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_2_1/libtooling/checker.cc b/misra_cpp_2008/rule_18_2_1/libtooling/checker.cc index cfb745eb68..9706a5274c 100644 --- a/misra_cpp_2008/rule_18_2_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_2_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_2_1/libtooling/checker.h" @@ -20,8 +32,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用宏 offsetof"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,15 +43,13 @@ namespace libtooling { const internal::VariadicDynCastAllOfMatcher offsetOfExpr; -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(offsetOfExpr().bind("offsetof_expr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const OffsetOfExpr* offsetof_expr = result.Nodes.getNodeAs("offsetof_expr"); ReportError( @@ -53,10 +62,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_2_1/libtooling/checker.h b/misra_cpp_2008/rule_18_2_1/libtooling/checker.h index 107ad971fe..d338045d8a 100644 --- a/misra_cpp_2008/rule_18_2_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_2_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_2_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_2_1/libtooling/main.cc b/misra_cpp_2008/rule_18_2_1/libtooling/main.cc index e57e068a35..e7efe823cd 100644 --- a/misra_cpp_2008/rule_18_2_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_2_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_4_1/libtooling/checker.cc b/misra_cpp_2008/rule_18_4_1/libtooling/checker.cc index 64cf680051..b8db95a85f 100644 --- a/misra_cpp_2008/rule_18_4_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_4_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_4_1/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用动态堆内存分配"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,18 +43,16 @@ namespace misra_cpp_2008 { namespace rule_18_4_1 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxNewExpr().bind("new"), this); finder->addMatcher(cxxDeleteExpr().bind("delete"), this); finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXNewExpr* new_expr = result.Nodes.getNodeAs("new"); const CXXDeleteExpr* delete_expr = result.Nodes.getNodeAs("delete"); @@ -82,10 +91,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_4_1/libtooling/checker.h b/misra_cpp_2008/rule_18_4_1/libtooling/checker.h index 19b95302de..75e66f96aa 100644 --- a/misra_cpp_2008/rule_18_4_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_4_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_4_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_4_1/libtooling/main.cc b/misra_cpp_2008/rule_18_4_1/libtooling/main.cc index 990909d99a..1aae8ba63a 100644 --- a/misra_cpp_2008/rule_18_4_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_4_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_18_7_1/libtooling/checker.cc b/misra_cpp_2008/rule_18_7_1/libtooling/checker.cc index 34a675e021..38fea25fd5 100644 --- a/misra_cpp_2008/rule_18_7_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_18_7_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_18_7_1/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用 的信号处理设施"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,16 +43,14 @@ namespace misra_cpp_2008 { namespace rule_18_7_1 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -60,10 +69,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_18_7_1/libtooling/checker.h b/misra_cpp_2008/rule_18_7_1/libtooling/checker.h index d733285169..996a86f73c 100644 --- a/misra_cpp_2008/rule_18_7_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_18_7_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_18_7_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_18_7_1/libtooling/main.cc b/misra_cpp_2008/rule_18_7_1/libtooling/main.cc index 876f7b6e72..e65f6a6abc 100644 --- a/misra_cpp_2008/rule_18_7_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_18_7_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_18_7_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_19_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_19_3_1/libtooling/checker.cc index 1fa2ce793c..7b29a3e720 100644 --- a/misra_cpp_2008/rule_19_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_19_3_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_19_3_1/libtooling/checker.h" @@ -22,8 +34,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应使用错误指示符 errno"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -32,16 +43,14 @@ namespace misra_cpp_2008 { namespace rule_19_3_1 { namespace libtooling { -class SpecificFunctionUsageCallback - : public ast_matchers::MatchFinder::MatchCallback { +class SpecificFunctionUsageCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declRefExpr(hasType(functionType())).bind("func_ptr"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const DeclRefExpr* func_ptr = result.Nodes.getNodeAs("func_ptr"); @@ -60,10 +69,10 @@ class SpecificFunctionUsageCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new SpecificFunctionUsageCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_19_3_1/libtooling/checker.h b/misra_cpp_2008/rule_19_3_1/libtooling/checker.h index 5db2bfacde..8b87a8f42a 100644 --- a/misra_cpp_2008/rule_19_3_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_19_3_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_19_3_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_19_3_1/libtooling/main.cc b/misra_cpp_2008/rule_19_3_1/libtooling/main.cc index 1e42044d63..2a968d0496 100644 --- a/misra_cpp_2008/rule_19_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_19_3_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_19_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_1_0_1/libtooling/checker.cc b/misra_cpp_2008/rule_1_0_1/libtooling/checker.cc index 550ea4a8fc..859895e659 100644 --- a/misra_cpp_2008/rule_1_0_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_1_0_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_1_0_1/libtooling/checker.hh" diff --git a/misra_cpp_2008/rule_1_0_1/libtooling/checker.hh b/misra_cpp_2008/rule_1_0_1/libtooling/checker.hh index d5b23ee75a..10e34b865e 100644 --- a/misra_cpp_2008/rule_1_0_1/libtooling/checker.hh +++ b/misra_cpp_2008/rule_1_0_1/libtooling/checker.hh @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_1_0_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_1_0_1/libtooling/main.cc b/misra_cpp_2008/rule_1_0_1/libtooling/main.cc index 827ec7d8c8..97c761d2b4 100644 --- a/misra_cpp_2008/rule_1_0_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_1_0_1/libtooling/main.cc @@ -49,7 +49,7 @@ int rule_1_0_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_10_1/libtooling/checker.cc b/misra_cpp_2008/rule_2_10_1/libtooling/checker.cc index 11bcc882fd..4752be4a70 100644 --- a/misra_cpp_2008/rule_2_10_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_10_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_10_1/libtooling/checker.h" @@ -24,7 +36,7 @@ void ReportError(string path, int line_number, string previous_loc, string loc, ResultsList* results_list) { string error_message = "[misra_cpp_2008-2.10.1]: 不同的标识符不应有近似的字形"; - std::vector locations{previous_loc, loc}; + std::vector locations{previous_loc, loc}; AddMultipleLocationsResultToResultsList(results_list, path, line_number, error_message, locations); } @@ -113,14 +125,12 @@ class AmbiguousIdentifier { set name_decl_; -void CheckNameCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckNameCallback::Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(namedDecl().bind("name"), this); } -void CheckNameCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckNameCallback::run(const MatchFinder::MatchResult& result) { const NamedDecl* named_ = result.Nodes.getNodeAs("name"); if (misra::libtooling_utils::IsInSystemHeader(named_, result.Context)) { @@ -147,7 +157,7 @@ void CheckNameCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckNameCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_2_10_1/libtooling/checker.h b/misra_cpp_2008/rule_2_10_1/libtooling/checker.h index f807c8c8de..2704dd74b0 100644 --- a/misra_cpp_2008/rule_2_10_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_10_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_2_10_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_10_1/libtooling/main.cc b/misra_cpp_2008/rule_2_10_1/libtooling/main.cc index 67854bcb3e..1193b8cbbf 100644 --- a/misra_cpp_2008/rule_2_10_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_10_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_10_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_10_2/libtooling/checker.cc b/misra_cpp_2008/rule_2_10_2/libtooling/checker.cc index 17db8362a4..4a9d0d921d 100644 --- a/misra_cpp_2008/rule_2_10_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_10_2/libtooling/checker.cc @@ -123,7 +123,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result); private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; void Callback::Init(ResultsList* results_list, MatchFinder* finder) { @@ -148,7 +148,7 @@ void Callback::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list, &finder_); diff --git a/misra_cpp_2008/rule_2_10_2/libtooling/rule_2_10_2.cc b/misra_cpp_2008/rule_2_10_2/libtooling/rule_2_10_2.cc index 1ce93f5819..4408bf73fa 100644 --- a/misra_cpp_2008/rule_2_10_2/libtooling/rule_2_10_2.cc +++ b/misra_cpp_2008/rule_2_10_2/libtooling/rule_2_10_2.cc @@ -47,13 +47,13 @@ int rule_2_10_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& option_parser = expected_parser.get(); std::vector path_list = option_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(option_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_2_10_6/libtooling/checker.cc b/misra_cpp_2008/rule_2_10_6/libtooling/checker.cc index c23009c067..e71cfe67a4 100644 --- a/misra_cpp_2008/rule_2_10_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_10_6/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_10_6/libtooling/checker.h" @@ -35,14 +47,13 @@ namespace libtooling { map type_decl_; map other_decl_; -void CheckTagDeclCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckTagDeclCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(namedDecl().bind("name"), this); } -void CheckTagDeclCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckTagDeclCallback::run(const MatchFinder::MatchResult& result) { const NamedDecl* named_ = result.Nodes.getNodeAs("name"); if (misra::libtooling_utils::IsInSystemHeader(named_, result.Context)) { @@ -89,7 +100,7 @@ void CheckTagDeclCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckTagDeclCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_2_10_6/libtooling/checker.h b/misra_cpp_2008/rule_2_10_6/libtooling/checker.h index 532cb7f3ef..0af82c8b06 100644 --- a/misra_cpp_2008/rule_2_10_6/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_10_6/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_2_10_6_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_10_6/libtooling/main.cc b/misra_cpp_2008/rule_2_10_6/libtooling/main.cc index a9cf0ba9b5..d72722a241 100644 --- a/misra_cpp_2008/rule_2_10_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_10_6/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_10_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_13_2/libtooling/checker.cc b/misra_cpp_2008/rule_2_13_2/libtooling/checker.cc index af9649e211..d979024c9e 100644 --- a/misra_cpp_2008/rule_2_13_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_13_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_13_2/libtooling/checker.h" @@ -24,15 +36,14 @@ namespace misra_cpp_2008 { namespace rule_2_13_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(characterLiteral().bind("lit"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CharacterLiteral* lit = result.Nodes.getNodeAs("lit"); if (lit->getValue() == 0) { @@ -50,7 +61,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (source.length() < 3 || !std::isdigit(source[2])) { return; // not an octal } - std::string error_message = + string error_message = "不得使用八进制常量(除零以外)和八进制转义序列(除“\\0”以外)"; AddResultToResultsList( results_list_, @@ -60,10 +71,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_2_13_2/libtooling/checker.h b/misra_cpp_2008/rule_2_13_2/libtooling/checker.h index 868b2e22c3..f1bc5b2a9d 100644 --- a/misra_cpp_2008/rule_2_13_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_13_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_2_13_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_13_2/libtooling/main.cc b/misra_cpp_2008/rule_2_13_2/libtooling/main.cc index 984f6aa57f..8d5ad1e65b 100644 --- a/misra_cpp_2008/rule_2_13_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_13_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_13_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_13_3/libtooling/checker.cc b/misra_cpp_2008/rule_2_13_3/libtooling/checker.cc index 15c78292f4..55ab7e1b74 100644 --- a/misra_cpp_2008/rule_2_13_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_13_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_13_3/libtooling/checker.h" @@ -36,10 +48,9 @@ auto isOctal(StringRef num) -> bool { return num.startswith("0"); }; -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(integerLiteral(hasType(isUnsignedInteger())).bind("lit"), this); @@ -62,7 +73,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); // pretend to use integerLiteral as unsigned } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const IntegerLiteral* lit = result.Nodes.getNodeAs("lit"); clang::SourceRange range = SourceRange(result.SourceManager->getSpellingLoc(lit->getBeginLoc()), @@ -80,7 +91,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (source.endswith("U")) { return; // marked with U } - std::string error_message = + string error_message = "必须对所有八进制或十六进制的无符号整型字面量使用后缀“U”"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, diff --git a/misra_cpp_2008/rule_2_13_3/libtooling/checker.h b/misra_cpp_2008/rule_2_13_3/libtooling/checker.h index 853efff39b..977150bf0a 100644 --- a/misra_cpp_2008/rule_2_13_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_13_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_2_13_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_13_3/libtooling/main.cc b/misra_cpp_2008/rule_2_13_3/libtooling/main.cc index 16b34eb371..c6929e645d 100644 --- a/misra_cpp_2008/rule_2_13_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_13_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_13_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_13_4/libtooling/checker.cc b/misra_cpp_2008/rule_2_13_4/libtooling/checker.cc index c06552245b..71b90cc9a6 100644 --- a/misra_cpp_2008/rule_2_13_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_13_4/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_13_4/libtooling/checker.h" @@ -23,15 +35,14 @@ namespace misra_cpp_2008 { namespace rule_2_13_4 { namespace libtooling { -class IntCallback : public ast_matchers::MatchFinder::MatchCallback { +class IntCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(integerLiteral().bind("lit"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* lit = result.Nodes.getNodeAs("lit"); if (misra::libtooling_utils::IsInSystemHeader(lit, result.Context)) { return; @@ -44,7 +55,7 @@ class IntCallback : public ast_matchers::MatchFinder::MatchCallback { .str(); for (int i = source.length() - 1; i >= 0; i--) { if ((source[i] == 'u') || (source[i] == 'l') || (source[i] == 'z')) { - std::string error_message = "字面量后缀必须是大写字母"; + string error_message = "字面量后缀必须是大写字母"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, misra::libtooling_utils::GetFilename(lit, result.SourceManager), @@ -61,15 +72,14 @@ class IntCallback : public ast_matchers::MatchFinder::MatchCallback { analyzer::proto::ResultsList* results_list_; }; -class FloatCallback : public ast_matchers::MatchFinder::MatchCallback { +class FloatCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(floatLiteral().bind("lit"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* lit = result.Nodes.getNodeAs("lit"); if (misra::libtooling_utils::IsInSystemHeader(lit, result.Context)) { return; @@ -82,7 +92,7 @@ class FloatCallback : public ast_matchers::MatchFinder::MatchCallback { .str(); for (int i = source.length() - 1; i >= 0; i--) { if ((source[i] == 'l') || (source[i] == 'f')) { - std::string error_message = "字面量后缀必须是大写字母"; + string error_message = "字面量后缀必须是大写字母"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, misra::libtooling_utils::GetFilename(lit, result.SourceManager), diff --git a/misra_cpp_2008/rule_2_13_4/libtooling/checker.h b/misra_cpp_2008/rule_2_13_4/libtooling/checker.h index 10007503ad..68eaac3107 100644 --- a/misra_cpp_2008/rule_2_13_4/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_13_4/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_2_13_4_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_13_4/libtooling/main.cc b/misra_cpp_2008/rule_2_13_4/libtooling/main.cc index 8fdff38139..6623d26692 100644 --- a/misra_cpp_2008/rule_2_13_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_13_4/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_13_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_13_5/libtooling/checker.cc b/misra_cpp_2008/rule_2_13_5/libtooling/checker.cc index a61c28a646..448c8c201d 100644 --- a/misra_cpp_2008/rule_2_13_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_13_5/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_13_5/libtooling/checker.h" @@ -23,15 +35,14 @@ namespace misra_cpp_2008 { namespace rule_2_13_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(stringLiteral().bind("lit"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const StringLiteral* lit = result.Nodes.getNodeAs("lit"); unsigned int tok_num = lit->getNumConcatenated(); bool first_is_wide = @@ -41,7 +52,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { if (first_is_wide != SourceIsWide(lit->getStrTokenLoc(i), *result.SourceManager, result.Context->getLangOpts(), result.Context)) { - std::string error_message = "不得将宽字符串字面量和窄字符串字面量串接"; + string error_message = "不得将宽字符串字面量和窄字符串字面量串接"; analyzer::proto::Result* pb_result = AddResultToResultsList( results_list_, misra::libtooling_utils::GetFilename(lit, result.SourceManager), diff --git a/misra_cpp_2008/rule_2_13_5/libtooling/checker.h b/misra_cpp_2008/rule_2_13_5/libtooling/checker.h index 216249302c..cfd4ccb9bb 100644 --- a/misra_cpp_2008/rule_2_13_5/libtooling/checker.h +++ b/misra_cpp_2008/rule_2_13_5/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_2_13_5_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_13_5/libtooling/main.cc b/misra_cpp_2008/rule_2_13_5/libtooling/main.cc index 70f7cb4da3..de68d6a5d3 100644 --- a/misra_cpp_2008/rule_2_13_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_13_5/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_13_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_2_7_2/libtooling/checker.cc b/misra_cpp_2008/rule_2_7_2/libtooling/checker.cc index ee17765de1..55358240dd 100644 --- a/misra_cpp_2008/rule_2_7_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_2_7_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_2_7_2/libtooling/checker.hh" @@ -76,8 +88,7 @@ void CheckCommentConsumer::ReportError(ASTContext& context, loc, &context.getSourceManager()); std::string error_message = "不得使用C语言风格的注释将代码段“注释掉”"; analyzer::proto::Result* pb_result = - misra::proto_util::AddResultToResultsList(results_list_, path, line, - error_message); + AddResultToResultsList(results_list_, path, line, error_message); pb_result->set_error_kind( analyzer::proto::Result_ErrorKind_MISRA_CPP_2008_RULE_2_7_2); LOG(INFO) << absl::StrFormat("%s, path: %s, line: %d", error_message, path, diff --git a/misra_cpp_2008/rule_2_7_2/libtooling/checker.hh b/misra_cpp_2008/rule_2_7_2/libtooling/checker.hh index 1df6c5af5a..d84eff6820 100644 --- a/misra_cpp_2008/rule_2_7_2/libtooling/checker.hh +++ b/misra_cpp_2008/rule_2_7_2/libtooling/checker.hh @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_2_7_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_2_7_2/libtooling/main.cc b/misra_cpp_2008/rule_2_7_2/libtooling/main.cc index db8a735a87..ed356ee5ed 100644 --- a/misra_cpp_2008/rule_2_7_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_2_7_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_2_7_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_3_1_1/libtooling/checker.cc b/misra_cpp_2008/rule_3_1_1/libtooling/checker.cc index 689934a2b4..90f2aa81e0 100644 --- a/misra_cpp_2008/rule_3_1_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_1_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_1_1/libtooling/checker.h" @@ -33,15 +45,14 @@ namespace misra_cpp_2008 { namespace rule_3_1_1 { namespace libtooling { -void CheckFuncDeclCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckFuncDeclCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; auto matcher = anyOf(functionDecl(), varDecl(isDefinition())); finder->addMatcher(namedDecl(matcher).bind("named-decl"), this); } -void CheckFuncDeclCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckFuncDeclCallback::run(const MatchFinder::MatchResult& result) { const NamedDecl* nd = result.Nodes.getNodeAs("named-decl"); SourceManager* source_manager = result.SourceManager; if (misra::libtooling_utils::IsInSystemHeader(nd, result.Context)) { @@ -106,7 +117,7 @@ void CheckFuncDeclCallback::run( } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckFuncDeclCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_3_1_1/libtooling/checker.h b/misra_cpp_2008/rule_3_1_1/libtooling/checker.h index 1cb5f645aa..c84522999b 100644 --- a/misra_cpp_2008/rule_3_1_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_1_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_3_1_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_1_1/libtooling/main.cc b/misra_cpp_2008/rule_3_1_1/libtooling/main.cc index bd2bb996a9..7628b5f846 100644 --- a/misra_cpp_2008/rule_3_1_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_1_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_3_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_3_1_2/libtooling/checker.cc b/misra_cpp_2008/rule_3_1_2/libtooling/checker.cc index 984c2c4c18..288630c88a 100644 --- a/misra_cpp_2008/rule_3_1_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_1_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_1_2/libtooling/checker.h" @@ -32,16 +44,15 @@ namespace misra_cpp_2008 { namespace rule_3_1_2 { namespace libtooling { -void CheckFuncDeclCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckFuncDeclCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl(hasParent(declStmt(hasParent(compoundStmt())))).bind("func"), this); } -void CheckFuncDeclCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckFuncDeclCallback::run(const MatchFinder::MatchResult& result) { const FunctionDecl* func_ = result.Nodes.getNodeAs("func"); if (misra::libtooling_utils::IsInSystemHeader(func_, result.Context)) { @@ -54,7 +65,7 @@ void CheckFuncDeclCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckFuncDeclCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_3_1_2/libtooling/checker.h b/misra_cpp_2008/rule_3_1_2/libtooling/checker.h index 5a5d339f4f..4dcd11a561 100644 --- a/misra_cpp_2008/rule_3_1_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_1_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_3_1_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_1_2/libtooling/main.cc b/misra_cpp_2008/rule_3_1_2/libtooling/main.cc index 66a17dfbb0..648b6923a0 100644 --- a/misra_cpp_2008/rule_3_1_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_1_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_3_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_3_1_3/libtooling/checker.cc b/misra_cpp_2008/rule_3_1_3/libtooling/checker.cc index c5ae7746dd..909613901d 100644 --- a/misra_cpp_2008/rule_3_1_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_1_3/libtooling/checker.cc @@ -30,15 +30,14 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_3_1_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl(hasType(arrayType())).bind("vd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const VarDecl* vd = result.Nodes.getNodeAs("vd"); if (misra::libtooling_utils::IsInSystemHeader(vd, result.Context)) { return; diff --git a/misra_cpp_2008/rule_3_1_3/libtooling/main.cc b/misra_cpp_2008/rule_3_1_3/libtooling/main.cc index 3107671498..3bbb756008 100644 --- a/misra_cpp_2008/rule_3_1_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_1_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_3_1_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_3_2_1/libtooling/checker.cc b/misra_cpp_2008/rule_3_2_1/libtooling/checker.cc index 7d199cd0e1..37058b593e 100644 --- a/misra_cpp_2008/rule_3_2_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_2_1/libtooling/checker.cc @@ -154,15 +154,14 @@ void ReportError(string loc, std::string other_loc, int line_number, namespace misra_cpp_2008 { namespace rule_3_2_1 { namespace libtooling { -class VarCallback : public ast_matchers::MatchFinder::MatchCallback { +class VarCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl().bind("var"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; SourceManager* sm = result.SourceManager; const VarDecl* var_decl = result.Nodes.getNodeAs("var"); @@ -194,14 +193,13 @@ class VarCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::unordered_map name_info_; }; -class FuncCallback : public ast_matchers::MatchFinder::MatchCallback { +class FuncCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl().bind("func"), this); } @@ -211,7 +209,7 @@ class FuncCallback : public ast_matchers::MatchFinder::MatchCallback { // 1. if params list is identical, return type is also identical, skip // 2. if params list is not the same, skip // otherwise, report - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; SourceManager* sm = result.SourceManager; const FunctionDecl* func_decl = @@ -263,11 +261,11 @@ class FuncCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::unordered_map name_info_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { var_callback_ = new VarCallback; var_callback_->Init(result_list, &finder_); func_callback_ = new FuncCallback; diff --git a/misra_cpp_2008/rule_3_2_1/libtooling/main.cc b/misra_cpp_2008/rule_3_2_1/libtooling/main.cc index ce7ab3b426..7e709e279c 100644 --- a/misra_cpp_2008/rule_3_2_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_2_1/libtooling/main.cc @@ -50,13 +50,13 @@ int rule_3_2_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_3_2_2/libtooling/checker.cc b/misra_cpp_2008/rule_3_2_2/libtooling/checker.cc index 7fc4f0e986..1e6291d948 100644 --- a/misra_cpp_2008/rule_3_2_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_2_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_2_2/libtooling/checker.h" @@ -184,15 +196,14 @@ void CheckIdentOnFunctionDecl(const FunctionDecl* d, SourceManager* sm, } } -class RecordCallback : public ast_matchers::MatchFinder::MatchCallback { +class RecordCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(recordDecl(isDefinition()).bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const NamedDecl* d = result.Nodes.getNodeAs("d"); if (d->getQualifiedNameAsString() == "(anonymous)") { return; @@ -202,19 +213,18 @@ class RecordCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_infos_; }; -class ClassTemplateCallback : public ast_matchers::MatchFinder::MatchCallback { +class ClassTemplateCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(classTemplateDecl().bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ClassTemplateDecl* d = result.Nodes.getNodeAs("d"); if (d->isThisDeclarationADefinition()) { CheckIdentOnNameDecl(d, result.SourceManager, result.Context, name_infos_, @@ -223,14 +233,13 @@ class ClassTemplateCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_infos_; }; -class FunctionCallback : public ast_matchers::MatchFinder::MatchCallback { +class FunctionCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl(isDefinition(), @@ -239,7 +248,7 @@ class FunctionCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* d = result.Nodes.getNodeAs("d"); if (d->isThisDeclarationADefinition()) { if (d->isInlineSpecified()) { @@ -253,50 +262,48 @@ class FunctionCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; map_t name_parms_infos_; }; -class VarCallback : public ast_matchers::MatchFinder::MatchCallback { +class VarCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( varDecl(isDefinition(), hasExternalFormalLinkage()).bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const NamedDecl* d = result.Nodes.getNodeAs("d"); CheckUniqueOnNameDecl(d, result.SourceManager, result.Context, name_infos_, results_list_); } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_infos_; }; -class TypedefCallback : public ast_matchers::MatchFinder::MatchCallback { +class TypedefCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(typedefDecl().bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const NamedDecl* d = result.Nodes.getNodeAs("d"); CheckIdentOnNameDecl(d, result.SourceManager, result.Context, name_infos_, results_list_); } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_infos_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; rd_callback_ = new RecordCallback; ct_callback_ = new ClassTemplateCallback; diff --git a/misra_cpp_2008/rule_3_2_2/libtooling/checker.h b/misra_cpp_2008/rule_3_2_2/libtooling/checker.h index 72005c25b5..dfec135b13 100644 --- a/misra_cpp_2008/rule_3_2_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_2_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_3_2_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_2_2/libtooling/main.cc b/misra_cpp_2008/rule_3_2_2/libtooling/main.cc index eb70bdbf2e..e3ffd60f73 100644 --- a/misra_cpp_2008/rule_3_2_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_2_2/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_3_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_3_2_3/libtooling/checker.cc b/misra_cpp_2008/rule_3_2_3/libtooling/checker.cc index 65d95b7d2e..b8163d671f 100644 --- a/misra_cpp_2008/rule_3_2_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_2_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_2_3/libtooling/checker.h" @@ -50,8 +62,7 @@ void CheckUniqueOnNamedDecl( ResultsList* results_list) { string name = nd->getQualifiedNameAsString(); SourceLocation spelling_loc = sm->getSpellingLoc(nd->getLocation()); - std::string file = - misra::libtooling_utils::GetLocationFilename(spelling_loc, sm); + string file = misra::libtooling_utils::GetLocationFilename(spelling_loc, sm); int line = misra::libtooling_utils::GetLocationLine(spelling_loc, sm); string fileline = absl::StrFormat("%s:%d", file, line); string mainfile = sm->getNonBuiltinFilenameForID(sm->getMainFileID())->str(); @@ -72,16 +83,15 @@ void CheckUniqueOnNamedDecl( } } -class NamedCallback : public ast_matchers::MatchFinder::MatchCallback { +class NamedCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(varDecl().bind("nd"), this); finder->addMatcher(functionDecl().bind("nd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const NamedDecl* nd = result.Nodes.getNodeAs("nd"); if (misra::libtooling_utils::IsInSystemHeader(nd, result.Context)) { return; @@ -98,19 +108,18 @@ class NamedCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_filelines_; }; -class RecordCallback : public ast_matchers::MatchFinder::MatchCallback { +class RecordCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(recordDecl().bind("rd"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const RecordDecl* rd = result.Nodes.getNodeAs("rd"); if (misra::libtooling_utils::IsInSystemHeader(rd, result.Context)) { return; @@ -130,11 +139,11 @@ class RecordCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; unordered_map name_filelines_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; nd_callback_ = new NamedCallback; rd_callback_ = new RecordCallback; diff --git a/misra_cpp_2008/rule_3_2_3/libtooling/checker.h b/misra_cpp_2008/rule_3_2_3/libtooling/checker.h index baeb0a8505..b62eca501c 100644 --- a/misra_cpp_2008/rule_3_2_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_2_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_3_2_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_2_3/libtooling/main.cc b/misra_cpp_2008/rule_3_2_3/libtooling/main.cc index e6efa0c4d3..ac04b0704b 100644 --- a/misra_cpp_2008/rule_3_2_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_2_3/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_3_2_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_3_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_3_3_1/libtooling/checker.cc index f8a7a1fe2a..067732c1af 100644 --- a/misra_cpp_2008/rule_3_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_3_1/libtooling/checker.cc @@ -44,7 +44,7 @@ namespace misra_cpp_2008 { namespace rule_3_3_1 { namespace libtooling { -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; finder_.addMatcher( namedDecl(anyOf(varDecl(), functionDecl()), hasExternalFormalLinkage()) diff --git a/misra_cpp_2008/rule_3_3_1/libtooling/main.cc b/misra_cpp_2008/rule_3_3_1/libtooling/main.cc index fc238596be..466eb5d9e8 100644 --- a/misra_cpp_2008/rule_3_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_3_1/libtooling/main.cc @@ -49,7 +49,7 @@ int rule_3_3_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_3_4_1/libtooling/checker.cc b/misra_cpp_2008/rule_3_4_1/libtooling/checker.cc index 3052d21dcb..8367e2de53 100644 --- a/misra_cpp_2008/rule_3_4_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_4_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_4_1/libtooling/checker.h" @@ -84,7 +96,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_3_4_1/libtooling/checker.h b/misra_cpp_2008/rule_3_4_1/libtooling/checker.h index 98fb03fff1..2cfc8d6caa 100644 --- a/misra_cpp_2008/rule_3_4_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_4_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_3_4_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_4_1/libtooling/main.cc b/misra_cpp_2008/rule_3_4_1/libtooling/main.cc index b3756d07fe..5d7c1fc075 100644 --- a/misra_cpp_2008/rule_3_4_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_4_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_3_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_3_9_1/libtooling/checker.cc b/misra_cpp_2008/rule_3_9_1/libtooling/checker.cc index 8c1eeef0ed..95a02f92c9 100644 --- a/misra_cpp_2008/rule_3_9_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_3_9_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_3_9_1/libtooling/checker.h" @@ -41,7 +53,7 @@ class FDCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd = result.Nodes.getNodeAs("fd"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(fd, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(fd, result.SourceManager); @@ -67,7 +79,7 @@ class FDCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; bool CheckAndReport(const FunctionDecl* fd, const FunctionDecl* other_fd, const MatchFinder::MatchResult& result) { - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(fd, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(fd, result.SourceManager); @@ -100,7 +112,7 @@ class VDCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const VarDecl* vd = result.Nodes.getNodeAs("vd"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(vd, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(vd, result.SourceManager); diff --git a/misra_cpp_2008/rule_3_9_1/libtooling/checker.h b/misra_cpp_2008/rule_3_9_1/libtooling/checker.h index 2d18e41ead..17775fe85c 100644 --- a/misra_cpp_2008/rule_3_9_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_3_9_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_3_9_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_3_9_1/libtooling/main.cc b/misra_cpp_2008/rule_3_9_1/libtooling/main.cc index 489a751f51..7e94e7d9f1 100644 --- a/misra_cpp_2008/rule_3_9_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_3_9_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_3_9_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/BUILD b/misra_cpp_2008/rule_4_10_1/libtooling/BUILD index e69b70f166..a9a4ea5521 100644 --- a/misra_cpp_2008/rule_4_10_1/libtooling/BUILD +++ b/misra_cpp_2008/rule_4_10_1/libtooling/BUILD @@ -1,41 +1,15 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_library( - name = "checker", - srcs = ["checker.cc"], - hdrs = ["checker.h"], - deps = [ - "//analyzer/proto:analyzer_cc_proto", - "//misra:proto_util", - "//misra/libtooling_utils", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings", - "@llvm-project//clang:tooling", - ], -) - cc_library( name = "rule_4_10_1_lib", - srcs = ["main.cc"], - hdrs = ["lib.h"], + srcs = ["checker.cc"], visibility = ["//visibility:public"], - deps = [ - ":checker", - "//libtooling_includes:cmd_options", - "//misra:proto_util", - "//misra/libtooling_utils", - "//podman_image/bigmain:suffix_rule", - "@com_github_google_glog//:glog", - "@llvm-project//clang:tooling", - ], + deps = ["//sdk/checker"], alwayslink = True, ) cc_binary( name = "rule_4_10_1", - srcs = ["realmain.cc"], deps = [ ":rule_4_10_1_lib", - "//libtooling_includes:cmd_options", + "//podman_image/bigmain", ], ) diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/checker.cc b/misra_cpp_2008/rule_4_10_1/libtooling/checker.cc index 1141bb708e..625f8b29eb 100644 --- a/misra_cpp_2008/rule_4_10_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_4_10_1/libtooling/checker.cc @@ -1,6 +1,6 @@ /* NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. +Copyright (C) 2022-2023 Naive Systems Ltd. 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 @@ -16,54 +16,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "misra_cpp_2008/rule_4_10_1/libtooling/checker.h" +#include -#include +#include "sdk/checker/define_expr_checker.h" -#include "absl/strings/str_format.h" -#include "misra/libtooling_utils/libtooling_utils.h" - -using namespace misra::proto_util; using namespace clang::ast_matchers; -using analyzer::proto::ResultsList; -using std::string; - -namespace misra_cpp_2008 { -namespace rule_4_10_1 { -namespace libtooling { - -class Callback : public MatchFinder::MatchCallback { - public: - void Init(ResultsList* results_list, MatchFinder* finder) { - results_list_ = results_list; - finder->addMatcher( - implicitCastExpr(hasSourceExpression(expr(gnuNullExpr())), - hasImplicitDestinationType(isInteger()), - unless(isExpansionInSystemHeader())) - .bind("cast"), - this); - } - - void run(const MatchFinder::MatchResult& result) override { - const Expr* expr = result.Nodes.getNodeAs("cast"); - string error_message = "NULL不得用作整型值"; - string path = - misra::libtooling_utils::GetFilename(expr, result.SourceManager); - int line = misra::libtooling_utils::GetLine(expr, result.SourceManager); - analyzer::proto::Result* pb_result = - AddResultToResultsList(results_list_, path, line, error_message); - } - - private: - ResultsList* results_list_; -}; +namespace { -void Checker::Init(analyzer::proto::ResultsList* result_list) { - callback_ = new Callback; - callback_->Init(result_list, &finder_); -} +sdk::checker::DefineExprChecker _( + "misra_cpp_2008/rule_4_10_1", "NULL不得用作整型值", + implicitCastExpr(hasSourceExpression(expr(gnuNullExpr())), + hasImplicitDestinationType(isInteger()), + unless(isExpansionInSystemHeader())) + .bind("cast"), + "cast"); -} // namespace libtooling -} // namespace rule_4_10_1 -} // namespace misra_cpp_2008 +} // namespace diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/checker.h b/misra_cpp_2008/rule_4_10_1/libtooling/checker.h deleted file mode 100644 index 1c846b38ee..0000000000 --- a/misra_cpp_2008/rule_4_10_1/libtooling/checker.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#ifndef ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_CHECKER_H_ -#define ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_CHECKER_H_ - -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include "misra/proto_util.h" - -using namespace clang; - -namespace misra_cpp_2008 { -namespace rule_4_10_1 { -namespace libtooling { -class Callback; - -class Checker { - public: - void Init(analyzer::proto::ResultsList* results_list); - ast_matchers::MatchFinder* GetMatchFinder() { return &finder_; } - - private: - Callback* callback_; - ast_matchers::MatchFinder finder_; - analyzer::proto::ResultsList* results_list_; -}; - -} // namespace libtooling -} // namespace rule_4_10_1 -} // namespace misra_cpp_2008 - -#endif // ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/main.cc b/misra_cpp_2008/rule_4_10_1/libtooling/main.cc deleted file mode 100644 index 45db9a4a09..0000000000 --- a/misra_cpp_2008/rule_4_10_1/libtooling/main.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#include -#include -#include -#include - -#include "absl/strings/match.h" -#include "misra/libtooling_utils/libtooling_utils.h" -#include "misra/proto_util.h" -#include "misra_cpp_2008/rule_4_10_1/libtooling/checker.h" -#include "misra_cpp_2008/rule_4_10_1/libtooling/lib.h" -#include "podman_image/bigmain/suffix_rule.h" - -using namespace clang; -using namespace llvm; - -extern cl::OptionCategory ns_libtooling_checker; -extern cl::opt results_path; - -namespace misra_cpp_2008 { -namespace rule_4_10_1 { -namespace libtooling { - -int rule_4_10_1(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - gflags::AllowCommandLineReparsing(); - int gflag_argc = argc; - int libtooling_argc = argc; - misra::libtooling_utils::SplitArg(&gflag_argc, &libtooling_argc, argc, argv); - const char** const_argv = const_cast(argv); - gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); - - auto ep = tooling::CommonOptionsParser::create( - libtooling_argc, &const_argv[argc - libtooling_argc], - ns_libtooling_checker); - if (!ep) { - errs() << ep.takeError(); - return 1; - } - tooling::CommonOptionsParser& op = ep.get(); - tooling::ClangTool tool(op.getCompilations(), op.getSourcePathList()); - - analyzer::proto::ResultsList all_results; - misra_cpp_2008::rule_4_10_1::libtooling::Checker checker; - checker.Init(&all_results); - int status = tool.run( - tooling::newFrontendActionFactory(checker.GetMatchFinder()).get()); - LOG(INFO) << "libtooling status: " << status; - if (misra::proto_util::GenerateProtoFile(all_results, results_path).ok()) { - LOG(INFO) << "rule 4.10.1 check done"; - } - return 0; -} - -} // namespace libtooling -} // namespace rule_4_10_1 -} // namespace misra_cpp_2008 - -namespace { - -podman_image::bigmain::SuffixRule _( - "misra_cpp_2008/rule_4_10_1", - misra_cpp_2008::rule_4_10_1::libtooling::rule_4_10_1); - -} // namespace diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/BUILD b/misra_cpp_2008/rule_4_10_2/libtooling/BUILD index e4fc9f8da2..bbb3740696 100644 --- a/misra_cpp_2008/rule_4_10_2/libtooling/BUILD +++ b/misra_cpp_2008/rule_4_10_2/libtooling/BUILD @@ -1,41 +1,19 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_library( - name = "checker", - srcs = ["checker.cc"], - hdrs = ["checker.h"], - deps = [ - "//analyzer/proto:analyzer_cc_proto", - "//misra:proto_util", - "//misra/libtooling_utils", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings", - "@llvm-project//clang:tooling", - ], -) - cc_library( name = "rule_4_10_2_lib", - srcs = ["main.cc"], - hdrs = ["lib.h"], + srcs = ["checker.cc"], visibility = ["//visibility:public"], deps = [ - ":checker", - "//libtooling_includes:cmd_options", "//misra:proto_util", "//misra/libtooling_utils", - "//podman_image/bigmain:suffix_rule", - "@com_github_google_glog//:glog", - "@llvm-project//clang:tooling", + "//sdk/checker", ], alwayslink = True, ) cc_binary( name = "rule_4_10_2", - srcs = ["realmain.cc"], deps = [ ":rule_4_10_2_lib", - "//libtooling_includes:cmd_options", + "//podman_image/bigmain", ], ) diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/checker.cc b/misra_cpp_2008/rule_4_10_2/libtooling/checker.cc index aa4d2ed6ac..c45e5a8b2a 100644 --- a/misra_cpp_2008/rule_4_10_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_4_10_2/libtooling/checker.cc @@ -1,6 +1,6 @@ /* NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. +Copyright (C) 2022-2023 Naive Systems Ltd. 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 @@ -16,24 +16,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "misra_cpp_2008/rule_4_10_2/libtooling/checker.h" - -#include - -#include "absl/strings/str_format.h" #include "misra/libtooling_utils/libtooling_utils.h" +#include "misra/proto_util.h" +#include "sdk/checker/ast_checker.h" +#include "sdk/checker/define_ast_checker.h" -using namespace clang; using namespace clang::ast_matchers; -using namespace llvm; -namespace misra_cpp_2008 { -namespace rule_4_10_2 { -namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +namespace { + +class Callback : public sdk::checker::ASTCheckerCallback { public: void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + MatchFinder* finder) override { results_list_ = results_list; finder->addMatcher(castExpr(hasCastKind(CK_NullToPointer), hasSourceExpression(integerLiteral(equals(0)))) @@ -41,7 +36,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* e = result.Nodes.getNodeAs("cast"); if (misra::libtooling_utils::IsInSystemHeader(e, result.Context)) { return; @@ -60,10 +55,6 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { analyzer::proto::ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { - callback_ = new Callback; - callback_->Init(result_list, &finder_); -} -} // namespace libtooling -} // namespace rule_4_10_2 -} // namespace misra_cpp_2008 +sdk::checker::DefineASTChecker _("misra_cpp_2008/rule_4_10_2"); + +} // namespace diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/checker.h b/misra_cpp_2008/rule_4_10_2/libtooling/checker.h deleted file mode 100644 index f9f0f3142c..0000000000 --- a/misra_cpp_2008/rule_4_10_2/libtooling/checker.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#ifndef ANALYZER_MISRA_CPP_2008_RULE_4_10_2_LIBTOOLING_CHECKER_H_ -#define ANALYZER_MISRA_CPP_2008_RULE_4_10_2_LIBTOOLING_CHECKER_H_ - -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include "misra/proto_util.h" - -using namespace clang; - -namespace misra_cpp_2008 { -namespace rule_4_10_2 { -namespace libtooling { -class Callback; - -class Checker { - public: - void Init(analyzer::proto::ResultsList* results_list); - ast_matchers::MatchFinder* GetMatchFinder() { return &finder_; } - - private: - Callback* callback_; - ast_matchers::MatchFinder finder_; - analyzer::proto::ResultsList* results_list_; -}; -} // namespace libtooling -} // namespace rule_4_10_2 -} // namespace misra_cpp_2008 - -#endif // ANALYZER_MISRA_CPP_2008_RULE_4_10_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/main.cc b/misra_cpp_2008/rule_4_10_2/libtooling/main.cc deleted file mode 100644 index ef21c1f4ac..0000000000 --- a/misra_cpp_2008/rule_4_10_2/libtooling/main.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#include -#include -#include -#include - -#include "absl/strings/match.h" -#include "misra/libtooling_utils/libtooling_utils.h" -#include "misra/proto_util.h" -#include "misra_cpp_2008/rule_4_10_2/libtooling/checker.h" -#include "misra_cpp_2008/rule_4_10_2/libtooling/lib.h" -#include "podman_image/bigmain/suffix_rule.h" - -using namespace clang; -using namespace llvm; - -extern cl::OptionCategory ns_libtooling_checker; -extern cl::opt results_path; - -namespace misra_cpp_2008 { -namespace rule_4_10_2 { -namespace libtooling { -int rule_4_10_2(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - gflags::AllowCommandLineReparsing(); - int gflag_argc = argc; - int libtooling_argc = argc; - misra::libtooling_utils::SplitArg(&gflag_argc, &libtooling_argc, argc, argv); - const char** const_argv = const_cast(argv); - gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); - - auto ep = tooling::CommonOptionsParser::create( - libtooling_argc, &const_argv[argc - libtooling_argc], - ns_libtooling_checker); - if (!ep) { - llvm::errs() << ep.takeError(); - return 1; - } - tooling::CommonOptionsParser& op = ep.get(); - tooling::ClangTool tool(op.getCompilations(), op.getSourcePathList()); - - analyzer::proto::ResultsList all_results; - misra_cpp_2008::rule_4_10_2::libtooling::Checker checker; - checker.Init(&all_results); - int status = tool.run( - tooling::newFrontendActionFactory(checker.GetMatchFinder()).get()); - LOG(INFO) << "libtooling status: " << status; - if (misra::proto_util::GenerateProtoFile(all_results, results_path).ok()) { - LOG(INFO) << "rule 4.10.2 check done"; - } - return 0; -} -} // namespace libtooling -} // namespace rule_4_10_2 -} // namespace misra_cpp_2008 - -namespace { - -podman_image::bigmain::SuffixRule _( - "misra_cpp_2008/rule_4_10_2", - misra_cpp_2008::rule_4_10_2::libtooling::rule_4_10_2); - -} // namespace diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/realmain.cc b/misra_cpp_2008/rule_4_10_2/libtooling/realmain.cc deleted file mode 100644 index 2cdb503ad4..0000000000 --- a/misra_cpp_2008/rule_4_10_2/libtooling/realmain.cc +++ /dev/null @@ -1,23 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#include "libtooling_includes/cmd_options.h" -#include "misra_cpp_2008/rule_4_10_2/libtooling/lib.h" -int main(int argc, char** argv) { - return misra_cpp_2008::rule_4_10_2::libtooling::rule_4_10_2(argc, argv); -} diff --git a/misra_cpp_2008/rule_4_5_1/libtooling/checker.cc b/misra_cpp_2008/rule_4_5_1/libtooling/checker.cc index 407572b0c1..db318a3ddd 100644 --- a/misra_cpp_2008/rule_4_5_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_4_5_1/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_4_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator(hasEitherOperand(castExpr( @@ -49,7 +48,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* e = result.Nodes.getNodeAs("op"); string error_message = "bool类型的表达式不得用作内建运算符的操作数,除了赋值运算符=,逻辑运算符&&、||、!,相等运算符==、!=,一元运算符&和条件运算符"; diff --git a/misra_cpp_2008/rule_4_5_1/libtooling/main.cc b/misra_cpp_2008/rule_4_5_1/libtooling/main.cc index 9e877bee37..95fc7742a7 100644 --- a/misra_cpp_2008/rule_4_5_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_4_5_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_4_5_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_4_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_4_5_2/libtooling/checker.cc index 02d9a393db..b043dd7a42 100644 --- a/misra_cpp_2008/rule_4_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_4_5_2/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_4_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -50,7 +49,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* e = result.Nodes.getNodeAs("op"); string error_message = "Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=."; diff --git a/misra_cpp_2008/rule_4_5_2/libtooling/main.cc b/misra_cpp_2008/rule_4_5_2/libtooling/main.cc index a4f48a8d4e..dae222b5be 100644 --- a/misra_cpp_2008/rule_4_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_4_5_2/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_4_5_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_4_5_3/libtooling/checker.cc b/misra_cpp_2008/rule_4_5_3/libtooling/checker.cc index d8018296ea..1f2184ab90 100644 --- a/misra_cpp_2008/rule_4_5_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_4_5_3/libtooling/checker.cc @@ -31,10 +31,9 @@ namespace misra_cpp_2008 { namespace rule_4_5_3 { namespace libtooling { const int zero_char = 48; -class OPCallback : public ast_matchers::MatchFinder::MatchCallback { +class OPCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -84,7 +83,7 @@ class OPCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* e = result.Nodes.getNodeAs("op"); if (misra::libtooling_utils::IsInSystemHeader(e, result.Context)) { return; @@ -104,10 +103,9 @@ class OPCallback : public ast_matchers::MatchFinder::MatchCallback { analyzer::proto::ResultsList* results_list_; }; -class AddCallback : public ast_matchers::MatchFinder::MatchCallback { +class AddCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -127,7 +125,7 @@ class AddCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; const BinaryOperator* add_op = result.Nodes.getNodeAs("addOp"); diff --git a/misra_cpp_2008/rule_4_5_3/libtooling/main.cc b/misra_cpp_2008/rule_4_5_3/libtooling/main.cc index aa53dbe4f4..b6fd39b7aa 100644 --- a/misra_cpp_2008/rule_4_5_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_4_5_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_4_5_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_10/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_10/libtooling/checker.cc index 02aaff2c05..5bebe32d83 100644 --- a/misra_cpp_2008/rule_5_0_10/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_10/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_0_10/libtooling/checker.h" @@ -35,10 +47,9 @@ namespace misra_cpp_2008 { namespace rule_5_0_10 { namespace libtooling { -class OpCallback : public ast_matchers::MatchFinder::MatchCallback { +class OpCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -62,7 +73,7 @@ class OpCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const BinaryOperator* bo = result.Nodes.getNodeAs("bo"); const UnaryOperator* uo = result.Nodes.getNodeAs("uo"); if (bo) { @@ -82,10 +93,10 @@ class OpCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new OpCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_5_0_10/libtooling/checker.h b/misra_cpp_2008/rule_5_0_10/libtooling/checker.h index fe6f50f03e..558db0e886 100644 --- a/misra_cpp_2008/rule_5_0_10/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_0_10/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_5_0_10_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_0_10/libtooling/main.cc b/misra_cpp_2008/rule_5_0_10/libtooling/main.cc index b51fe9158e..a2cb3ce18c 100644 --- a/misra_cpp_2008/rule_5_0_10/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_10/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_0_10(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_0_11/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_11/libtooling/checker.cc index f26fc9e56e..3e73e8a39e 100644 --- a/misra_cpp_2008/rule_5_0_11/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_11/libtooling/checker.cc @@ -32,10 +32,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_0_11 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( implicitCastExpr(allOf(hasType(asString("char")), @@ -45,7 +44,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; ImplicitCastExpr const* cast = result.Nodes.getNodeAs("cast"); diff --git a/misra_cpp_2008/rule_5_0_11/libtooling/main.cc b/misra_cpp_2008/rule_5_0_11/libtooling/main.cc index 993a8a1f1e..e0aa3955fa 100644 --- a/misra_cpp_2008/rule_5_0_11/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_11/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_11(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_12/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_12/libtooling/checker.cc index 13e3ec1154..60deae9a43 100644 --- a/misra_cpp_2008/rule_5_0_12/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_12/libtooling/checker.cc @@ -33,10 +33,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_0_12 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( implicitCastExpr( @@ -48,7 +47,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; ImplicitCastExpr const* cast = result.Nodes.getNodeAs("cast"); diff --git a/misra_cpp_2008/rule_5_0_12/libtooling/main.cc b/misra_cpp_2008/rule_5_0_12/libtooling/main.cc index d2ec9fa539..6ede79056e 100644 --- a/misra_cpp_2008/rule_5_0_12/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_12/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_12(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_13/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_13/libtooling/checker.cc index d9c6cc1dab..9306d5e788 100644 --- a/misra_cpp_2008/rule_5_0_13/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_13/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_5_0_13 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto impcast = implicitCastExpr(unless(hasSourceExpression(hasType(booleanType()))), @@ -62,7 +61,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Stmt* s = result.Nodes.getNodeAs("stmt"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { return; diff --git a/misra_cpp_2008/rule_5_0_13/libtooling/main.cc b/misra_cpp_2008/rule_5_0_13/libtooling/main.cc index 53ada19199..28540dfcf9 100644 --- a/misra_cpp_2008/rule_5_0_13/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_13/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_13(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_14/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_14/libtooling/checker.cc index 08942e8e7a..5bb53e8c41 100644 --- a/misra_cpp_2008/rule_5_0_14/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_14/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_0_14 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( conditionalOperator(hasCondition( @@ -45,7 +44,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { .bind("condition"))), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* condition = result.Nodes.getNodeAs("condition"); condition->dump(); diff --git a/misra_cpp_2008/rule_5_0_14/libtooling/main.cc b/misra_cpp_2008/rule_5_0_14/libtooling/main.cc index a418e81cec..89664326f9 100644 --- a/misra_cpp_2008/rule_5_0_14/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_14/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_14(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_15/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_15/libtooling/checker.cc index 93b67c1a80..cb36850932 100644 --- a/misra_cpp_2008/rule_5_0_15/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_15/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_0_15/libtooling/checker.h" diff --git a/misra_cpp_2008/rule_5_0_15/libtooling/checker.h b/misra_cpp_2008/rule_5_0_15/libtooling/checker.h index 2feaef9d2f..90dd7b6f96 100644 --- a/misra_cpp_2008/rule_5_0_15/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_0_15/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_5_0_15_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_0_15/libtooling/main.cc b/misra_cpp_2008/rule_5_0_15/libtooling/main.cc index fb5a376160..50b05799e9 100644 --- a/misra_cpp_2008/rule_5_0_15/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_15/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_0_15(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_0_3/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_3/libtooling/checker.cc index 9023b5f8b2..dfc8522955 100644 --- a/misra_cpp_2008/rule_5_0_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_0_3/libtooling/checker.h" @@ -33,9 +45,8 @@ namespace misra_cpp_2008 { namespace rule_5_0_3 { namespace libtooling { -void CheckCvalueImplicitCallback::Init( - analyzer::proto::ResultsList* results_list, - clang::ast_matchers::MatchFinder* finder) { +void CheckCvalueImplicitCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; auto cvalue_range = @@ -86,8 +97,7 @@ void CheckCvalueImplicitCallback::Init( finder->addMatcher(parm_matcher, this); } -void CheckCvalueImplicitCallback::run( - const clang::ast_matchers::MatchFinder::MatchResult& result) { +void CheckCvalueImplicitCallback::run(const MatchFinder::MatchResult& result) { const ASTContext& ctx = *result.Context; const ImplicitCastExpr* cast_expr = result.Nodes.getNodeAs("impl_cast"); @@ -128,7 +138,7 @@ bool CheckCvalueImplicitCallback::check503( return true; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; implicit_callback_ = new CheckCvalueImplicitCallback; implicit_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_5_0_3/libtooling/checker.h b/misra_cpp_2008/rule_5_0_3/libtooling/checker.h index 5c1ee4ef16..df8b767b88 100644 --- a/misra_cpp_2008/rule_5_0_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_0_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_5_0_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_0_3/libtooling/main.cc b/misra_cpp_2008/rule_5_0_3/libtooling/main.cc index ee01edbf42..0b84e8b4b4 100644 --- a/misra_cpp_2008/rule_5_0_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_0_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_0_4/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_4/libtooling/checker.cc index 081ade2ca4..d952104b25 100644 --- a/misra_cpp_2008/rule_5_0_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_4/libtooling/checker.cc @@ -45,7 +45,7 @@ void ReportError(string filename, int line, filename, line); } -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { class QualTypeExt : public QualType { public: QualTypeExt(QualType qual_type) : QualType(qual_type){}; @@ -55,8 +55,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { }; public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // Case 1: when the expression is used as the argument when calling a // function that is declared with T2 as parameter @@ -120,7 +119,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { return type; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto report = [&result, this](const Stmt* stmt) { std::string filename = misra::libtooling_utils::GetFilename(stmt, result.SourceManager); diff --git a/misra_cpp_2008/rule_5_0_4/libtooling/main.cc b/misra_cpp_2008/rule_5_0_4/libtooling/main.cc index 1588d59d07..f2d8831b3d 100644 --- a/misra_cpp_2008/rule_5_0_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_4/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_5/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_5/libtooling/checker.cc index ccd3bd85ce..ec56ee6fa0 100644 --- a/misra_cpp_2008/rule_5_0_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_5/libtooling/checker.cc @@ -29,10 +29,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_0_5 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( implicitCastExpr( @@ -49,7 +48,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Stmt* implicitCast = result.Nodes.getNodeAs("implicitCast"); if (!implicitCast) { diff --git a/misra_cpp_2008/rule_5_0_5/libtooling/main.cc b/misra_cpp_2008/rule_5_0_5/libtooling/main.cc index 317396111a..76c740da5a 100644 --- a/misra_cpp_2008/rule_5_0_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_5/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_5(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_6/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_6/libtooling/checker.cc index 6f7da7df8f..547229f373 100644 --- a/misra_cpp_2008/rule_5_0_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_6/libtooling/checker.cc @@ -60,10 +60,9 @@ namespace misra_cpp_2008 { namespace rule_5_0_6 { namespace libtooling { -class IntegerCallback : public ast_matchers::MatchFinder::MatchCallback { +class IntegerCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( implicitCastExpr( @@ -78,7 +77,7 @@ class IntegerCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; ImplicitCastExpr const* cast = result.Nodes.getNodeAs("cast"); @@ -132,10 +131,9 @@ class IntegerCallback : public ast_matchers::MatchFinder::MatchCallback { analyzer::proto::ResultsList* results_list_; }; -class FloatCallback : public ast_matchers::MatchFinder::MatchCallback { +class FloatCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( implicitCastExpr( @@ -147,7 +145,7 @@ class FloatCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; ImplicitCastExpr const* cast = result.Nodes.getNodeAs("cast"); diff --git a/misra_cpp_2008/rule_5_0_6/libtooling/main.cc b/misra_cpp_2008/rule_5_0_6/libtooling/main.cc index 8d7ef124fc..cafa97f469 100644 --- a/misra_cpp_2008/rule_5_0_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_6/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_0_6(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_0_8/libtooling/checker.cc b/misra_cpp_2008/rule_5_0_8/libtooling/checker.cc index 9076c0fc5d..8b73ff6352 100644 --- a/misra_cpp_2008/rule_5_0_8/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_0_8/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_0_8/libtooling/checker.h" @@ -63,9 +75,8 @@ auto explicitCastForCValue(const T& matcher) { .bind("cast_expr")); } -void CheckCvalueCallback::Init(std::string rule_name, - analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckCvalueCallback::Init(string rule_name, ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; check_name = rule_name; @@ -102,8 +113,7 @@ void CheckCvalueCallback::Init(std::string rule_name, this); } -void CheckCvalueCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckCvalueCallback::run(const MatchFinder::MatchResult& result) { const ASTContext& ctx = *result.Context; const ExplicitCastExpr* cast_expr_ = result.Nodes.getNodeAs("cast_expr"); @@ -174,8 +184,7 @@ bool CheckCvalueCallback::check509(const clang::QualType dest_type, return false; } -void Checker::Init(std::string rule_name, - analyzer::proto::ResultsList* result_list) { +void Checker::Init(string rule_name, ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckCvalueCallback; record_callback_->Init(rule_name, result_list, &finder_); diff --git a/misra_cpp_2008/rule_5_0_8/libtooling/checker.h b/misra_cpp_2008/rule_5_0_8/libtooling/checker.h index ee3736a12f..1a899f5b63 100644 --- a/misra_cpp_2008/rule_5_0_8/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_0_8/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_5_0_8_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_0_8/libtooling/main.cc b/misra_cpp_2008/rule_5_0_8/libtooling/main.cc index a008f8af4d..fa9b92a55f 100644 --- a/misra_cpp_2008/rule_5_0_8/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_0_8/libtooling/main.cc @@ -51,7 +51,7 @@ int rule_5_0_8(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_2_1/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_1/libtooling/checker.cc index 577452d0fe..e609d36e14 100644 --- a/misra_cpp_2008/rule_5_2_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_2_1/libtooling/checker.h" @@ -55,9 +67,8 @@ StringRef getBinOpName(const Expr* binOp_) { return ""; } -void CheckLogicOperatorCallback::Init( - analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckLogicOperatorCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; // binaryOperation matches: @@ -74,8 +85,7 @@ void CheckLogicOperatorCallback::Init( this); } -void CheckLogicOperatorCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckLogicOperatorCallback::run(const MatchFinder::MatchResult& result) { const Expr* binOp_ = result.Nodes.getNodeAs("operation"); const Expr* child_ = result.Nodes.getNodeAs("child"); @@ -96,7 +106,7 @@ void CheckLogicOperatorCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckLogicOperatorCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_5_2_1/libtooling/checker.h b/misra_cpp_2008/rule_5_2_1/libtooling/checker.h index ee03f6c182..bd512f5724 100644 --- a/misra_cpp_2008/rule_5_2_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_2_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_5_2_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_2_1/libtooling/main.cc b/misra_cpp_2008/rule_5_2_1/libtooling/main.cc index 336b809ba1..d9ba0dcaa5 100644 --- a/misra_cpp_2008/rule_5_2_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_2_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_2_11/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_11/libtooling/checker.cc index f7324bd7d0..29a33f2bf0 100644 --- a/misra_cpp_2008/rule_5_2_11/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_11/libtooling/checker.cc @@ -32,10 +32,9 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_2_11 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl(hasOverloadedOperatorName(",")).bind("operator"), this); @@ -45,7 +44,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { functionDecl(hasOverloadedOperatorName("||")).bind("operator"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; FunctionDecl const* op = result.Nodes.getNodeAs("operator"); diff --git a/misra_cpp_2008/rule_5_2_11/libtooling/main.cc b/misra_cpp_2008/rule_5_2_11/libtooling/main.cc index f08fbe8bad..796e24a308 100644 --- a/misra_cpp_2008/rule_5_2_11/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_11/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_2_11(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_2_12/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_12/libtooling/checker.cc index 28d8c45591..615b43d0ef 100644 --- a/misra_cpp_2008/rule_5_2_12/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_12/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_2_12/libtooling/checker.h" @@ -36,7 +48,7 @@ class Callback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const Expr* decayed_arg = result.Nodes.getNodeAs("decayed_arg"); if (misra::libtooling_utils::IsInSystemHeader(decayed_arg, result.Context)) { diff --git a/misra_cpp_2008/rule_5_2_12/libtooling/checker.h b/misra_cpp_2008/rule_5_2_12/libtooling/checker.h index 7f564bcfb9..a3f82ce160 100644 --- a/misra_cpp_2008/rule_5_2_12/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_2_12/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_5_2_12_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_2_12/libtooling/main.cc b/misra_cpp_2008/rule_5_2_12/libtooling/main.cc index ca7c71545a..93f27fe602 100644 --- a/misra_cpp_2008/rule_5_2_12/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_12/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_2_12(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_2_2/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_2/libtooling/checker.cc index 348f52230c..b1b7f6951e 100644 --- a/misra_cpp_2008/rule_5_2_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_2_2/libtooling/checker.h" @@ -33,8 +45,8 @@ namespace misra_cpp_2008 { namespace rule_5_2_2 { namespace libtooling { -void CheckClassCastCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckClassCastCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; auto matcher = explicitCastExpr( unless(isExpansionInSystemHeader()), unless(cxxDynamicCastExpr()), @@ -49,8 +61,7 @@ void CheckClassCastCallback::Init(analyzer::proto::ResultsList* results_list, finder->addMatcher(matcher.bind("cast"), this); } -void CheckClassCastCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckClassCastCallback::run(const MatchFinder::MatchResult& result) { if (const auto* explicit_ = result.Nodes.getNodeAs("cast")) { ReportError( @@ -60,7 +71,7 @@ void CheckClassCastCallback::run( } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckClassCastCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_5_2_2/libtooling/checker.h b/misra_cpp_2008/rule_5_2_2/libtooling/checker.h index 73a2d2b071..0d51ad0abc 100644 --- a/misra_cpp_2008/rule_5_2_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_2_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_5_2_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_2_2/libtooling/main.cc b/misra_cpp_2008/rule_5_2_2/libtooling/main.cc index fd497a9eb3..6ada60cd6c 100644 --- a/misra_cpp_2008/rule_5_2_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_2_4/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_4/libtooling/checker.cc index f14d8eb71d..e234c5d8a4 100644 --- a/misra_cpp_2008/rule_5_2_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_4/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_2_4/libtooling/checker.h" @@ -35,8 +47,7 @@ namespace libtooling { AST_MATCHER(QualType, isVoid) { return Node->isVoidType(); } -void CheckCastCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckCastCallback::Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( explicitCastExpr( @@ -47,8 +58,7 @@ void CheckCastCallback::Init(analyzer::proto::ResultsList* results_list, this); } -void CheckCastCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckCastCallback::run(const MatchFinder::MatchResult& result) { const ExplicitCastExpr* cast_ = result.Nodes.getNodeAs("cast"); @@ -62,7 +72,7 @@ void CheckCastCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckCastCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_5_2_4/libtooling/checker.h b/misra_cpp_2008/rule_5_2_4/libtooling/checker.h index 839aa55b0d..5107fc7c69 100644 --- a/misra_cpp_2008/rule_5_2_4/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_2_4/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_5_2_4_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_2_4/libtooling/main.cc b/misra_cpp_2008/rule_5_2_4/libtooling/main.cc index 8f6e423ab7..7460e12c3e 100644 --- a/misra_cpp_2008/rule_5_2_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_4/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_2_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_2_6/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_6/libtooling/checker.cc index b7574d8610..60f1b29bcb 100644 --- a/misra_cpp_2008/rule_5_2_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_6/libtooling/checker.cc @@ -47,10 +47,9 @@ void ReportError(string loc, int line_number, ResultsList* results_list) { namespace misra_cpp_2008 { namespace rule_5_2_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(castExpr(hasSourceExpression(hasType(pointerType( pointee(ignoringParens(functionType())))))) @@ -58,7 +57,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CastExpr* ce = result.Nodes.getNodeAs("typeFromFuncPointer"); @@ -70,10 +69,10 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_5_2_6/libtooling/main.cc b/misra_cpp_2008/rule_5_2_6/libtooling/main.cc index 975a26c7f4..e1cfae0be5 100644 --- a/misra_cpp_2008/rule_5_2_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_6/libtooling/main.cc @@ -50,13 +50,13 @@ int rule_5_2_6(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& options_parser = ep.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } tooling::ClangTool tool( diff --git a/misra_cpp_2008/rule_5_2_8/libtooling/checker.cc b/misra_cpp_2008/rule_5_2_8/libtooling/checker.cc index 562c6975d0..36d10f3a0a 100644 --- a/misra_cpp_2008/rule_5_2_8/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_2_8/libtooling/checker.cc @@ -86,7 +86,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_5_2_8/libtooling/main.cc b/misra_cpp_2008/rule_5_2_8/libtooling/main.cc index 8ca50e8dab..bb20c3475b 100644 --- a/misra_cpp_2008/rule_5_2_8/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_2_8/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_2_8(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_5_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_5_3_1/libtooling/checker.cc index 1440093075..34e8557630 100644 --- a/misra_cpp_2008/rule_5_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_3_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_3_1/libtooling/checker.h" @@ -59,7 +71,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_5_3_1/libtooling/checker.h b/misra_cpp_2008/rule_5_3_1/libtooling/checker.h index c51d73cbb7..eea089fd96 100644 --- a/misra_cpp_2008/rule_5_3_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_3_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_5_3_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_3_1/libtooling/main.cc b/misra_cpp_2008/rule_5_3_1/libtooling/main.cc index 79231ba856..19bb22615f 100644 --- a/misra_cpp_2008/rule_5_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_3_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_3_2/libtooling/checker.cc b/misra_cpp_2008/rule_5_3_2/libtooling/checker.cc index 4623a4b6cc..dbf78182be 100644 --- a/misra_cpp_2008/rule_5_3_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_3_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_5_3_2/libtooling/checker.h" @@ -53,7 +65,7 @@ class Callback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new Callback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_5_3_2/libtooling/checker.h b/misra_cpp_2008/rule_5_3_2/libtooling/checker.h index e32b6454aa..c53eb7eb2a 100644 --- a/misra_cpp_2008/rule_5_3_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_5_3_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_5_3_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_5_3_2/libtooling/main.cc b/misra_cpp_2008/rule_5_3_2/libtooling/main.cc index b1e621c176..b7a21b0469 100644 --- a/misra_cpp_2008/rule_5_3_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_3_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_5_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_5_3_3/libtooling/checker.cc b/misra_cpp_2008/rule_5_3_3/libtooling/checker.cc index 0799891616..ced1f27537 100644 --- a/misra_cpp_2008/rule_5_3_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_5_3_3/libtooling/checker.cc @@ -32,16 +32,15 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_5_3_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( functionDecl(hasOverloadedOperatorName("&")).bind("operator&"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { ASTContext* context = result.Context; FunctionDecl const* op = result.Nodes.getNodeAs("operator&"); diff --git a/misra_cpp_2008/rule_5_3_3/libtooling/main.cc b/misra_cpp_2008/rule_5_3_3/libtooling/main.cc index 324ef5e2e3..9a2117132d 100644 --- a/misra_cpp_2008/rule_5_3_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_5_3_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_5_3_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_2_2/libtooling/checker.cc b/misra_cpp_2008/rule_6_2_2/libtooling/checker.cc index e6aee054d2..9b772224e3 100644 --- a/misra_cpp_2008/rule_6_2_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_2_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_6_2_2/libtooling/checker.h" @@ -20,8 +32,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不得直接或间接地对浮点表达式进行相等性或不等性测试"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -30,9 +41,8 @@ namespace misra_cpp_2008 { namespace rule_6_2_2 { namespace libtooling { -void CheckFloatComparisonCallback::Init( - analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckFloatComparisonCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperator( @@ -46,8 +56,7 @@ void CheckFloatComparisonCallback::Init( this); } -void CheckFloatComparisonCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckFloatComparisonCallback::run(const MatchFinder::MatchResult& result) { auto op_ = result.Nodes.getNodeAs("comparison"); auto lhs_type_ = result.Nodes.getNodeAs("lhs_type"); auto rhs_type_ = result.Nodes.getNodeAs("rhs_type"); @@ -69,7 +78,7 @@ void CheckFloatComparisonCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new CheckFloatComparisonCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_6_2_2/libtooling/checker.h b/misra_cpp_2008/rule_6_2_2/libtooling/checker.h index c16f9e1212..fbe35d5ca2 100644 --- a/misra_cpp_2008/rule_6_2_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_6_2_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_6_2_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_6_2_2/libtooling/main.cc b/misra_cpp_2008/rule_6_2_2/libtooling/main.cc index 4213692fd8..0dc75a5e28 100644 --- a/misra_cpp_2008/rule_6_2_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_2_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_6_2_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_6_4_6/libtooling/checker.cc b/misra_cpp_2008/rule_6_4_6/libtooling/checker.cc index ec75874873..08f00c3c39 100644 --- a/misra_cpp_2008/rule_6_4_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_4_6/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_6_4_6/libtooling/checker.h" @@ -23,8 +35,8 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list, string external_message = "") { string error_message = "switch语句的最后一个子句必须是default子句"; - auto result = misra::proto_util::AddResultToResultsList( - results_list, path, line_number, error_message); + auto result = + AddResultToResultsList(results_list, path, line_number, error_message); if (!external_message.empty()) { result->set_external_message(external_message); @@ -45,11 +57,9 @@ AST_MATCHER(Stmt, isNotBreakStmt) { return Stmt::StmtClass::BreakStmtClass != Node.getStmtClass(); } -class InappropriateSwitchCallback - : public ast_matchers::MatchFinder::MatchCallback { +class InappropriateSwitchCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( switchStmt( @@ -64,7 +74,7 @@ class InappropriateSwitchCallback .bind("switch_stmt"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto switch_stmt = result.Nodes.getNodeAs("switch_stmt"); if (misra::libtooling_utils::IsInSystemHeader(switch_stmt, @@ -107,10 +117,10 @@ class InappropriateSwitchCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new InappropriateSwitchCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_6_4_6/libtooling/checker.h b/misra_cpp_2008/rule_6_4_6/libtooling/checker.h index e7c525e93d..609ca7e012 100644 --- a/misra_cpp_2008/rule_6_4_6/libtooling/checker.h +++ b/misra_cpp_2008/rule_6_4_6/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_6_4_6_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_6_4_6/libtooling/main.cc b/misra_cpp_2008/rule_6_4_6/libtooling/main.cc index a02ce5e7fd..72831c1901 100644 --- a/misra_cpp_2008/rule_6_4_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_4_6/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_6_4_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_6_5_1/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_1/libtooling/checker.cc index c68c030d6c..05ebad45a0 100644 --- a/misra_cpp_2008/rule_6_5_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_6_5_1/libtooling/checker.h" @@ -41,10 +53,9 @@ namespace misra_cpp_2008 { namespace rule_6_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_counter_matcher = @@ -57,7 +68,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ForStmt* for_stmt_without_counter = result.Nodes.getNodeAs("for_stmt_without_counter"); const ForStmt* for_stmt_with_counter = @@ -98,13 +109,13 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; std::unordered_map > var_set; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_6_5_1/libtooling/checker.h b/misra_cpp_2008/rule_6_5_1/libtooling/checker.h index 0d4691836f..bf4fefd270 100644 --- a/misra_cpp_2008/rule_6_5_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_6_5_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_6_5_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_6_5_1/libtooling/main.cc b/misra_cpp_2008/rule_6_5_1/libtooling/main.cc index f35eba4164..47b38678cc 100644 --- a/misra_cpp_2008/rule_6_5_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_6_5_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_6_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_2/libtooling/checker.cc index d7fdd6a478..dfc4ea6996 100644 --- a/misra_cpp_2008/rule_6_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_2/libtooling/checker.cc @@ -32,10 +32,9 @@ namespace misra_cpp_2008 { namespace rule_6_5_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_counter_matcher = CreateLoopCounterMatcher( @@ -44,7 +43,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(forStmt(loop_counter_matcher).bind("for_stmt"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ForStmt* for_stmt = result.Nodes.getNodeAs("for_stmt"); if (misra::libtooling_utils::IsInSystemHeader(for_stmt, result.Context)) { return; diff --git a/misra_cpp_2008/rule_6_5_2/libtooling/main.cc b/misra_cpp_2008/rule_6_5_2/libtooling/main.cc index ccd07ea3c4..5a48daec62 100644 --- a/misra_cpp_2008/rule_6_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_2/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_6_5_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_5_3/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_3/libtooling/checker.cc index 79c8347717..e9afbc68b1 100644 --- a/misra_cpp_2008/rule_6_5_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_3/libtooling/checker.cc @@ -31,10 +31,9 @@ using namespace misra::libtooling_utils; namespace misra_cpp_2008 { namespace rule_6_5_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_counter_matcher = @@ -48,7 +47,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ForStmt* for_stmt = result.Nodes.getNodeAs("for_stmt"); if (misra::libtooling_utils::IsInSystemHeader(for_stmt, result.Context)) { return; diff --git a/misra_cpp_2008/rule_6_5_3/libtooling/main.cc b/misra_cpp_2008/rule_6_5_3/libtooling/main.cc index 01924f9df1..3a64845916 100644 --- a/misra_cpp_2008/rule_6_5_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_6_5_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_5_4/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_4/libtooling/checker.cc index 259bf1a932..f87277b662 100644 --- a/misra_cpp_2008/rule_6_5_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_4/libtooling/checker.cc @@ -31,10 +31,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_6_5_4 { namespace libtooling { -class ForStmtCallback : public ast_matchers::MatchFinder::MatchCallback { +class ForStmtCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // match illegal loop-counter assignment @@ -118,7 +117,7 @@ class ForStmtCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Stmt* for_stmt = result.Nodes.getNodeAs("for_stmt"); const DeclRefExpr* modify_expr = result.Nodes.getNodeAs("modify_expr"); diff --git a/misra_cpp_2008/rule_6_5_4/libtooling/main.cc b/misra_cpp_2008/rule_6_5_4/libtooling/main.cc index 0b49ef1627..f2ff01b651 100644 --- a/misra_cpp_2008/rule_6_5_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_4/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_6_5_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_5_5/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_5/libtooling/checker.cc index c837291767..5e06194298 100644 --- a/misra_cpp_2008/rule_6_5_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_5/libtooling/checker.cc @@ -31,10 +31,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_6_5_5 { namespace libtooling { -class ForStmtCallback : public ast_matchers::MatchFinder::MatchCallback { +class ForStmtCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_counter_matcher = @@ -55,7 +54,7 @@ class ForStmtCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Stmt* for_stmt = result.Nodes.getNodeAs("for_stmt"); const DeclRefExpr* var_ref = result.Nodes.getNodeAs("var_ref"); @@ -83,10 +82,9 @@ class ForStmtCallback : public ast_matchers::MatchFinder::MatchCallback { analyzer::proto::ResultsList* results_list_; }; -class WhileStmtCallback : public ast_matchers::MatchFinder::MatchCallback { +class WhileStmtCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_var_matcher = @@ -105,7 +103,7 @@ class WhileStmtCallback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Stmt* while_stmt = result.Nodes.getNodeAs("while_stmt"); const DeclRefExpr* var_ref = result.Nodes.getNodeAs("var_ref"); diff --git a/misra_cpp_2008/rule_6_5_5/libtooling/main.cc b/misra_cpp_2008/rule_6_5_5/libtooling/main.cc index 41d1b69dfa..7ee27626d0 100644 --- a/misra_cpp_2008/rule_6_5_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_5/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_6_5_5(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_5_6/libtooling/checker.cc b/misra_cpp_2008/rule_6_5_6/libtooling/checker.cc index 137b7d2746..b8e346cf25 100644 --- a/misra_cpp_2008/rule_6_5_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_5_6/libtooling/checker.cc @@ -31,10 +31,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_6_5_6 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; auto loop_counter_matcher = @@ -49,7 +48,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ForStmt* s = result.Nodes.getNodeAs("forStmt"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { diff --git a/misra_cpp_2008/rule_6_5_6/libtooling/main.cc b/misra_cpp_2008/rule_6_5_6/libtooling/main.cc index bba680ced0..77d85b4712 100644 --- a/misra_cpp_2008/rule_6_5_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_5_6/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_6_5_6(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_6_6_3/libtooling/checker.cc b/misra_cpp_2008/rule_6_6_3/libtooling/checker.cc index c2fe6341d2..076a5c73b1 100644 --- a/misra_cpp_2008/rule_6_6_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_6_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_6_6_3/libtooling/checker.h" @@ -41,10 +53,9 @@ namespace misra_cpp_2008 { namespace rule_6_6_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // match loop counter (6.5.1) @@ -73,7 +84,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ForStmt* for_stmt_with_counter = result.Nodes.getNodeAs("for_stmt_with_counter"); const ForStmt* for_stmt_without_counter = @@ -119,7 +130,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; // the number of loop-counter declarations for each `ForStmt` std::unordered_map > @@ -128,7 +139,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { std::unordered_set continue_set; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { callback_ = new Callback; callback_->Init(result_list, &finder_); } diff --git a/misra_cpp_2008/rule_6_6_3/libtooling/checker.h b/misra_cpp_2008/rule_6_6_3/libtooling/checker.h index e57f0d01f5..204afe17d5 100644 --- a/misra_cpp_2008/rule_6_6_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_6_6_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_6_6_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_6_6_3/libtooling/main.cc b/misra_cpp_2008/rule_6_6_3/libtooling/main.cc index 749a72d47e..0ae40a9dd9 100644 --- a/misra_cpp_2008/rule_6_6_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_6_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_6_6_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_6_6_5/libtooling/checker.cc b/misra_cpp_2008/rule_6_6_5/libtooling/checker.cc index 0131350a33..be191cc81b 100644 --- a/misra_cpp_2008/rule_6_6_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_6_6_5/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_6_6_5/libtooling/checker.h" @@ -33,8 +45,8 @@ namespace misra_cpp_2008 { namespace rule_6_6_5 { namespace libtooling { -void CheckFuncReturnCallback::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckFuncReturnCallback::Init(ResultsList* results_list, + MatchFinder* finder) { results_list_ = results_list; // This rule essentially aims to report on function exits in the middle of the @@ -70,8 +82,7 @@ void CheckFuncReturnCallback::Init(analyzer::proto::ResultsList* results_list, finder->addMatcher(other_return_matcher, this); } -void CheckFuncReturnCallback::run( - const ast_matchers::MatchFinder::MatchResult& result) { +void CheckFuncReturnCallback::run(const MatchFinder::MatchResult& result) { const ReturnStmt* return_ = result.Nodes.getNodeAs("return"); if (misra::libtooling_utils::IsInSystemHeader(return_, result.Context)) { @@ -85,7 +96,7 @@ void CheckFuncReturnCallback::run( return; } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; record_callback_ = new CheckFuncReturnCallback; record_callback_->Init(result_list, &finder_); diff --git a/misra_cpp_2008/rule_6_6_5/libtooling/checker.h b/misra_cpp_2008/rule_6_6_5/libtooling/checker.h index 3bddd57913..becd3c8136 100644 --- a/misra_cpp_2008/rule_6_6_5/libtooling/checker.h +++ b/misra_cpp_2008/rule_6_6_5/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_6_6_5_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_6_6_5/libtooling/main.cc b/misra_cpp_2008/rule_6_6_5/libtooling/main.cc index dceaa2952c..db9f2f9fc4 100644 --- a/misra_cpp_2008/rule_6_6_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_6_6_5/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_6_6_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_1_1/libtooling/checker.cc b/misra_cpp_2008/rule_7_1_1/libtooling/checker.cc index a5901bd15a..4cef71706a 100644 --- a/misra_cpp_2008/rule_7_1_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_1_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_1_1/libtooling/checker.h" @@ -21,8 +33,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不修改的变量必须使用const修饰"; analyzer::proto::Result* pb_result = - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); pb_result->set_error_kind( analyzer::proto::Result_ErrorKind_MISRA_CPP_2008_RULE_7_1_1); auto message = absl::StrFormat("%s, path: %s, line: %d", error_message, path, @@ -35,11 +46,9 @@ namespace misra_cpp_2008 { namespace rule_7_1_1 { namespace libtooling { -class StaticOrConstMethodCallback - : public ast_matchers::MatchFinder::MatchCallback { +class StaticOrConstMethodCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { // This is different to 7.1.2 because we don't need to consider pointer // escaped, so the matcher is simpler. @@ -62,7 +71,7 @@ class StaticOrConstMethodCallback results_list_ = results_list; } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const VarDecl* var_decl = result.Nodes.getNodeAs("vd"); if (!var_decl) { return; @@ -82,10 +91,10 @@ class StaticOrConstMethodCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new StaticOrConstMethodCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_7_1_1/libtooling/checker.h b/misra_cpp_2008/rule_7_1_1/libtooling/checker.h index 4d56708d03..85d2231cb0 100644 --- a/misra_cpp_2008/rule_7_1_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_1_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_7_1_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_1_1/libtooling/main.cc b/misra_cpp_2008/rule_7_1_1/libtooling/main.cc index 8ffa9f70e2..a4eee30f53 100644 --- a/misra_cpp_2008/rule_7_1_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_1_1/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_7_1_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_7_1_2/libtooling/checker.cc b/misra_cpp_2008/rule_7_1_2/libtooling/checker.cc index 080de96da5..7eab19639e 100644 --- a/misra_cpp_2008/rule_7_1_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_1_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_1_2/libtooling/checker.h" @@ -36,7 +48,7 @@ namespace misra_cpp_2008 { namespace rule_7_1_2 { namespace libtooling { -std::unordered_map> +std::unordered_map> not_const_parm_map{}; std::unordered_set used_parm_map{}; @@ -85,8 +97,7 @@ std::unordered_set used_parm_map{}; // find the parameters should be const qualified(not modified and not escaped). class ReturnCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; // match A pointer or reference parameter in a function not be declared as // pointer to const or reference to const @@ -158,7 +169,7 @@ class ReturnCallback : public MatchFinder::MatchCallback { traverse(TK_IgnoreUnlessSpelledInSource, member_param_pointer), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ParmVarDecl* parm = result.Nodes.getNodeAs("not_const_func_parm"); const ParmVarDecl* used_param = @@ -179,7 +190,7 @@ class ReturnCallback : public MatchFinder::MatchCallback { if (misra::libtooling_utils::IsInSystemHeader(parm, result.Context)) { return; } - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(parm, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(parm, result.SourceManager); @@ -191,7 +202,7 @@ class ReturnCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; void Checker::checkFuncParmMapAndReport(void) { @@ -204,7 +215,7 @@ void Checker::checkFuncParmMapAndReport(void) { } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; returnCallback_ = new ReturnCallback; returnCallback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_7_1_2/libtooling/checker.h b/misra_cpp_2008/rule_7_1_2/libtooling/checker.h index 0bd995e26d..8ce07b2a81 100644 --- a/misra_cpp_2008/rule_7_1_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_1_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_1_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_1_2/libtooling/main.cc b/misra_cpp_2008/rule_7_1_2/libtooling/main.cc index c98aa1d3e4..a19234eb1e 100644 --- a/misra_cpp_2008/rule_7_1_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_1_2/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_7_1_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_7_2_1/libtooling/checker.cc b/misra_cpp_2008/rule_7_2_1/libtooling/checker.cc index 64a911b33e..2e85f74cd3 100644 --- a/misra_cpp_2008/rule_7_2_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_2_1/libtooling/checker.cc @@ -29,21 +29,20 @@ using namespace clang::ast_matchers; namespace misra_cpp_2008 { namespace rule_7_2_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: // check the case to find if we cast to an enum type // rule: 底层类型为enum的表达式的值必须与该枚举的枚举器相对应 // if the values not corresponding to the enumerators of the enumeration, // there must exists a type cast in CXX. - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( castExpr(unless(hasCastKind(CK_LValueToRValue))).bind("castToEnum"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Expr* cast = result.Nodes.getNodeAs("castToEnum"); if (!cast) { return; diff --git a/misra_cpp_2008/rule_7_2_1/libtooling/main.cc b/misra_cpp_2008/rule_7_2_1/libtooling/main.cc index 448f5f4cfb..3b215c6ee3 100644 --- a/misra_cpp_2008/rule_7_2_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_2_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_7_2_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_7_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_1/libtooling/checker.cc index ad1754ebea..48692bdc96 100644 --- a/misra_cpp_2008/rule_7_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_3_1/libtooling/checker.h" @@ -45,7 +57,7 @@ class Callback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const Decl* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(decl_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(decl_, result.SourceManager); diff --git a/misra_cpp_2008/rule_7_3_1/libtooling/checker.h b/misra_cpp_2008/rule_7_3_1/libtooling/checker.h index 09d96d3f26..d2132109ea 100644 --- a/misra_cpp_2008/rule_7_3_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_3_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_3_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_3_1/libtooling/main.cc b/misra_cpp_2008/rule_7_3_1/libtooling/main.cc index 5aeb8e1f6c..5abb3cb818 100644 --- a/misra_cpp_2008/rule_7_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_3_2/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_2/libtooling/checker.cc index d199f7634f..274024f9c9 100644 --- a/misra_cpp_2008/rule_7_3_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_3_2/libtooling/checker.h" @@ -44,7 +56,7 @@ class FDCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const FunctionDecl* fd_ = result.Nodes.getNodeAs("fd"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(fd_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(fd_, result.SourceManager); diff --git a/misra_cpp_2008/rule_7_3_2/libtooling/checker.h b/misra_cpp_2008/rule_7_3_2/libtooling/checker.h index f7f748b548..8bb6882747 100644 --- a/misra_cpp_2008/rule_7_3_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_3_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_3_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_3_2/libtooling/main.cc b/misra_cpp_2008/rule_7_3_2/libtooling/main.cc index 29ca58c49b..22ffac2043 100644 --- a/misra_cpp_2008/rule_7_3_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_3_3/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_3/libtooling/checker.cc index e0e1e35eb2..510fd08ff7 100644 --- a/misra_cpp_2008/rule_7_3_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_3_3/libtooling/checker.h" @@ -44,7 +56,7 @@ class NamespaceCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const NamespaceDecl* namespace_ = result.Nodes.getNodeAs("namespace"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(namespace_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(namespace_, result.SourceManager); diff --git a/misra_cpp_2008/rule_7_3_3/libtooling/checker.h b/misra_cpp_2008/rule_7_3_3/libtooling/checker.h index 5980e83de5..7a5e1cb229 100644 --- a/misra_cpp_2008/rule_7_3_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_3_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_3_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_3_3/libtooling/main.cc b/misra_cpp_2008/rule_7_3_3/libtooling/main.cc index 684f7e2762..729b44e8be 100644 --- a/misra_cpp_2008/rule_7_3_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_3_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_3_4/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_4/libtooling/checker.cc index 1bfbd2d43d..8a0e306de9 100644 --- a/misra_cpp_2008/rule_7_3_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_4/libtooling/checker.cc @@ -44,7 +44,7 @@ namespace misra_cpp_2008 { namespace rule_7_3_4 { namespace libtooling { -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; finder_.addMatcher(usingDirectiveDecl().bind("using"), this); } diff --git a/misra_cpp_2008/rule_7_3_4/libtooling/main.cc b/misra_cpp_2008/rule_7_3_4/libtooling/main.cc index 53c8cdfa96..37b638c8ee 100644 --- a/misra_cpp_2008/rule_7_3_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_4/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_7_3_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_7_3_5/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_5/libtooling/checker.cc index 80a84b234c..203bfd9826 100644 --- a/misra_cpp_2008/rule_7_3_5/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_5/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_3_5/libtooling/checker.h" @@ -74,7 +86,7 @@ class UsingCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const UsingDecl* using_ = result.Nodes.getNodeAs("using"); const NamedDecl* decl_ = result.Nodes.getNodeAs("decl"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(using_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(using_, result.SourceManager); diff --git a/misra_cpp_2008/rule_7_3_5/libtooling/checker.h b/misra_cpp_2008/rule_7_3_5/libtooling/checker.h index 07907d66a9..221497efdf 100644 --- a/misra_cpp_2008/rule_7_3_5/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_3_5/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_3_5_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_3_5/libtooling/main.cc b/misra_cpp_2008/rule_7_3_5/libtooling/main.cc index 8c172ea20d..a12a088d6b 100644 --- a/misra_cpp_2008/rule_7_3_5/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_5/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_3_5(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_3_6/libtooling/checker.cc b/misra_cpp_2008/rule_7_3_6/libtooling/checker.cc index 7299b49a86..c08a28402f 100644 --- a/misra_cpp_2008/rule_7_3_6/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_3_6/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_3_6/libtooling/checker.h" @@ -48,7 +60,7 @@ class UsingCallback : public MatchFinder::MatchCallback { void run(const MatchFinder::MatchResult& result) override { const NamedDecl* using_ = result.Nodes.getNodeAs("using"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(using_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(using_, result.SourceManager); diff --git a/misra_cpp_2008/rule_7_3_6/libtooling/checker.h b/misra_cpp_2008/rule_7_3_6/libtooling/checker.h index aeb823d8bd..f051be79b3 100644 --- a/misra_cpp_2008/rule_7_3_6/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_3_6/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_3_6_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_3_6/libtooling/main.cc b/misra_cpp_2008/rule_7_3_6/libtooling/main.cc index 4ef7eb838d..062538e38e 100644 --- a/misra_cpp_2008/rule_7_3_6/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_3_6/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_3_6(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_7_5_2/libtooling/checker.cc index 56f2a55257..bec45853d5 100644 --- a/misra_cpp_2008/rule_7_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_5_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_5_2/libtooling/checker.h" @@ -46,8 +58,7 @@ namespace libtooling { class AssignOpCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperation( @@ -61,10 +72,10 @@ class AssignOpCallback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const BinaryOperator* assign_op_ = result.Nodes.getNodeAs("assign_op"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(assign_op_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(assign_op_, result.SourceManager); @@ -99,15 +110,14 @@ class AssignOpCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; // To handle cases where the address of an object with local storage is returned // and assigned to another object as a function return value. class FuncAssignCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( binaryOperation( @@ -121,10 +131,10 @@ class FuncAssignCallback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const BinaryOperator* assign_op_ = result.Nodes.getNodeAs("assign_op"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(assign_op_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(assign_op_, result.SourceManager); @@ -136,14 +146,13 @@ class FuncAssignCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; // To handle 'throw' cases mentioned in Rationale of Rule 7-5-2 class ThrowCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxThrowExpr(has(unaryOperator(hasOperatorName("&"), @@ -153,9 +162,9 @@ class ThrowCallback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXThrowExpr* throw_ = result.Nodes.getNodeAs("throw"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(throw_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(throw_, result.SourceManager); @@ -165,10 +174,10 @@ class ThrowCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; assignOpCallback_ = new AssignOpCallback; assignOpCallback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_7_5_2/libtooling/checker.h b/misra_cpp_2008/rule_7_5_2/libtooling/checker.h index 20729c16de..ae8db3dcc0 100644 --- a/misra_cpp_2008/rule_7_5_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_5_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_5_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_5_2/libtooling/main.cc b/misra_cpp_2008/rule_7_5_2/libtooling/main.cc index 22a9edc918..a9fbf948b0 100644 --- a/misra_cpp_2008/rule_7_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_5_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_7_5_3/libtooling/checker.cc b/misra_cpp_2008/rule_7_5_3/libtooling/checker.cc index 0c0fe9218b..0003d1e906 100644 --- a/misra_cpp_2008/rule_7_5_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_7_5_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_7_5_3/libtooling/checker.h" @@ -38,8 +50,7 @@ namespace libtooling { class ReturnCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(forEachDescendant( returnStmt(hasDescendant(declRefExpr(to(parmVarDecl( @@ -48,9 +59,9 @@ class ReturnCallback : public MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const ReturnStmt* return_ = result.Nodes.getNodeAs("return"); - std::string path_ = + string path_ = misra::libtooling_utils::GetFilename(return_, result.SourceManager); int line_number_ = misra::libtooling_utils::GetLine(return_, result.SourceManager); @@ -60,10 +71,10 @@ class ReturnCallback : public MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; returnCallback_ = new ReturnCallback; returnCallback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_7_5_3/libtooling/checker.h b/misra_cpp_2008/rule_7_5_3/libtooling/checker.h index 5569183cf2..14f3709a7a 100644 --- a/misra_cpp_2008/rule_7_5_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_7_5_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_rule_7_5_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_7_5_3/libtooling/main.cc b/misra_cpp_2008/rule_7_5_3/libtooling/main.cc index a83c1f457c..49773bb6df 100644 --- a/misra_cpp_2008/rule_7_5_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_7_5_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_7_5_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_8_0_1/libtooling/checker.cc b/misra_cpp_2008/rule_8_0_1/libtooling/checker.cc index fc4739b34d..14e2605908 100644 --- a/misra_cpp_2008/rule_8_0_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_0_1/libtooling/checker.cc @@ -31,10 +31,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_8_0_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(declStmt(hasDescendant(varDecl())).bind("stmt"), this); @@ -45,7 +44,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { finder->addMatcher(fieldDecl().bind("decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Decl* decl = result.Nodes.getNodeAs("decl"); const DeclStmt* stmt = result.Nodes.getNodeAs("stmt"); diff --git a/misra_cpp_2008/rule_8_0_1/libtooling/main.cc b/misra_cpp_2008/rule_8_0_1/libtooling/main.cc index 1608368041..74aa7a7c62 100644 --- a/misra_cpp_2008/rule_8_0_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_0_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_8_0_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_8_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_8_3_1/libtooling/checker.cc index a9a92a8190..14b10ef6b5 100644 --- a/misra_cpp_2008/rule_8_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_3_1/libtooling/checker.cc @@ -76,11 +76,11 @@ class Callback : public MatchFinder::MatchCallback { auto base_char_range = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(base_param_arr[i]->getSourceRange()), *result.SourceManager, result.Context->getLangOpts()); - std::string cur_str = + string cur_str = Lexer::getSourceText(cur_char_range, *result.SourceManager, result.Context->getLangOpts()) .str(); - std::string base_str = + string base_str = Lexer::getSourceText(base_char_range, *result.SourceManager, result.Context->getLangOpts()) .str(); diff --git a/misra_cpp_2008/rule_8_3_1/libtooling/main.cc b/misra_cpp_2008/rule_8_3_1/libtooling/main.cc index ca43325215..a3fd31e869 100644 --- a/misra_cpp_2008/rule_8_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_3_1/libtooling/main.cc @@ -49,7 +49,7 @@ int rule_8_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_8_4_1/libtooling/checker.cc b/misra_cpp_2008/rule_8_4_1/libtooling/checker.cc index bb50f3a57b..4ae7c7a17b 100644 --- a/misra_cpp_2008/rule_8_4_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_4_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_8_4_1/libtooling/checker.h" @@ -20,8 +32,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "不应在函数定义中使用省略号"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -51,7 +62,7 @@ void FuncDefEllipsisCallback::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new FuncDefEllipsisCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_8_4_1/libtooling/checker.h b/misra_cpp_2008/rule_8_4_1/libtooling/checker.h index 41bb31e0ae..f2131ff8a1 100644 --- a/misra_cpp_2008/rule_8_4_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_8_4_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_8_4_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_8_4_1/libtooling/main.cc b/misra_cpp_2008/rule_8_4_1/libtooling/main.cc index a6b1aaf6a4..c79b66de67 100644 --- a/misra_cpp_2008/rule_8_4_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_4_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_8_4_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_8_4_2/libtooling/checker.cc b/misra_cpp_2008/rule_8_4_2/libtooling/checker.cc index 3cf6b87a63..0f596b9584 100644 --- a/misra_cpp_2008/rule_8_4_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_4_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_8_4_2/libtooling/checker.h" @@ -67,15 +79,14 @@ bool ok(string v1, string v2) { return (v1 == v2) || (v1 == empty) || (v2 == empty); } -class FunctionCallback : public ast_matchers::MatchFinder::MatchCallback { +class FunctionCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(functionDecl(unless(cxxMethodDecl())).bind("d"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const FunctionDecl* d = result.Nodes.getNodeAs("d"); if (misra::libtooling_utils::IsInSystemHeader(d, result.Context)) { return; @@ -114,19 +125,18 @@ class FunctionCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; map_t name_parms_infos_; }; -class CXXMethodCallback : public ast_matchers::MatchFinder::MatchCallback { +class CXXMethodCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(cxxMethodDecl().bind("md"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) { + void run(const MatchFinder::MatchResult& result) { const CXXMethodDecl* d = result.Nodes.getNodeAs("md"); if (misra::libtooling_utils::IsInSystemHeader(d, result.Context)) { return; @@ -162,11 +172,11 @@ class CXXMethodCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; map_t name_parms_infos_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; fun_callback_ = new FunctionCallback; method_callback_ = new CXXMethodCallback; diff --git a/misra_cpp_2008/rule_8_4_2/libtooling/checker.h b/misra_cpp_2008/rule_8_4_2/libtooling/checker.h index 96d5d0c80a..1c71f48d3f 100644 --- a/misra_cpp_2008/rule_8_4_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_8_4_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_8_4_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_8_4_2/libtooling/main.cc b/misra_cpp_2008/rule_8_4_2/libtooling/main.cc index 3ec173c82f..20f83ec252 100644 --- a/misra_cpp_2008/rule_8_4_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_4_2/libtooling/main.cc @@ -48,13 +48,13 @@ int rule_8_4_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); vector path_list = options_parser.getSourcePathList(); if (path_list.size() != 1) { - llvm::errs() << "The number of filepath is not equal to 1"; + errs() << "The number of filepath is not equal to 1"; return 1; } ClangTool tool(options_parser.getCompilations(), diff --git a/misra_cpp_2008/rule_8_4_4/libtooling/checker.cc b/misra_cpp_2008/rule_8_4_4/libtooling/checker.cc index eb7d2ff6ab..e60b5f9004 100644 --- a/misra_cpp_2008/rule_8_4_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_4_4/libtooling/checker.cc @@ -33,9 +33,8 @@ using analyzer::proto::ResultsList; namespace { -void ReportError(std::string filename, int line_number, - ResultsList* results_list) { - std::string error_message = +void ReportError(string filename, int line_number, ResultsList* results_list) { + string error_message = absl::StrFormat("函数标识符要么用于调用函数,要么以 & 开头"); analyzer::proto::Result* pb_result = AddResultToResultsList( results_list, filename, line_number, error_message); @@ -110,7 +109,7 @@ class FuncIdentifierCallback : public MatchFinder::MatchCallback { ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* results_list) { +void Checker::Init(ResultsList* results_list) { results_list_ = results_list; callback_ = new FuncIdentifierCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_8_4_4/libtooling/main.cc b/misra_cpp_2008/rule_8_4_4/libtooling/main.cc index 41aff15494..9cd6afea59 100644 --- a/misra_cpp_2008/rule_8_4_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_4_4/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_8_4_4(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& OptionsParser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_8_5_2/libtooling/checker.cc b/misra_cpp_2008/rule_8_5_2/libtooling/checker.cc index aa54f4f77f..911bdffd02 100644 --- a/misra_cpp_2008/rule_8_5_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_8_5_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_8_5_2/libtooling/checker.h" @@ -21,8 +33,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "在数组和结构的非零初始化中,应使用大括号来指示和匹配结构"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -31,7 +42,7 @@ namespace misra_cpp_2008 { namespace rule_8_5_2 { namespace libtooling { -class ListInitCallback : public ast_matchers::MatchFinder::MatchCallback { +class ListInitCallback : public MatchFinder::MatchCallback { enum ZeroInitializationType { NON_ZERO = 0, EMPTY_INIT, @@ -127,14 +138,13 @@ class ListInitCallback : public ast_matchers::MatchFinder::MatchCallback { } public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(initListExpr(unless(hasAncestor(initListExpr()))) .bind("top_level_init_list"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { auto top_level_init_list = result.Nodes.getNodeAs("top_level_init_list"); if (!isMatchableToDeclStructure(top_level_init_list)) { @@ -148,10 +158,10 @@ class ListInitCallback : public ast_matchers::MatchFinder::MatchCallback { } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new ListInitCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_8_5_2/libtooling/checker.h b/misra_cpp_2008/rule_8_5_2/libtooling/checker.h index 65054f260e..381006e290 100644 --- a/misra_cpp_2008/rule_8_5_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_8_5_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_8_5_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_8_5_2/libtooling/main.cc b/misra_cpp_2008/rule_8_5_2/libtooling/main.cc index 6b58de0757..e27479301a 100644 --- a/misra_cpp_2008/rule_8_5_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_8_5_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_8_5_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_9_3_1/libtooling/checker.cc b/misra_cpp_2008/rule_9_3_1/libtooling/checker.cc index 453002cbba..1faba4d2e5 100644 --- a/misra_cpp_2008/rule_9_3_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_3_1/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_9_3_1/libtooling/checker.h" @@ -20,8 +32,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "const 成员函数不应返回非 const 指针或对类数据的引用"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -30,8 +41,7 @@ namespace misra_cpp_2008 { namespace rule_9_3_1 { namespace libtooling { -void CheckConstFunction::Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { +void CheckConstFunction::Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxMethodDecl(isConst(), isDefinition(), @@ -59,7 +69,7 @@ void CheckConstFunction::run(const MatchFinder::MatchResult& result) { } } -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new CheckConstFunction; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_9_3_1/libtooling/checker.h b/misra_cpp_2008/rule_9_3_1/libtooling/checker.h index 30d86193fd..c18041f929 100644 --- a/misra_cpp_2008/rule_9_3_1/libtooling/checker.h +++ b/misra_cpp_2008/rule_9_3_1/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_9_3_1_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_9_3_1/libtooling/main.cc b/misra_cpp_2008/rule_9_3_1/libtooling/main.cc index fc8d1b7652..0707c5d28c 100644 --- a/misra_cpp_2008/rule_9_3_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_3_1/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_9_3_1(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_9_3_2/libtooling/checker.cc b/misra_cpp_2008/rule_9_3_2/libtooling/checker.cc index 5f24bb7e79..cb12432c77 100644 --- a/misra_cpp_2008/rule_9_3_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_3_2/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_9_3_2/libtooling/checker.h" @@ -20,8 +32,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "成员函数不应将非常量句柄返回到类数据"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -55,11 +66,9 @@ AST_MATCHER(FunctionDecl, hasReferReturnType) { return isReferenceType(returnType); } -class NonConstHandlesCallback - : public ast_matchers::MatchFinder::MatchCallback { +class NonConstHandlesCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxMethodDecl(allOf( @@ -77,7 +86,7 @@ class NonConstHandlesCallback .bind("return_stmt")))))), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ReturnStmt* return_stmt = result.Nodes.getNodeAs("return_stmt"); @@ -95,10 +104,10 @@ class NonConstHandlesCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new NonConstHandlesCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_9_3_2/libtooling/checker.h b/misra_cpp_2008/rule_9_3_2/libtooling/checker.h index 9f59efd9de..ce319cc092 100644 --- a/misra_cpp_2008/rule_9_3_2/libtooling/checker.h +++ b/misra_cpp_2008/rule_9_3_2/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_9_3_2_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_9_3_2/libtooling/main.cc b/misra_cpp_2008/rule_9_3_2/libtooling/main.cc index f9c7ca0345..be3f7d8d32 100644 --- a/misra_cpp_2008/rule_9_3_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_3_2/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_9_3_2(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_9_3_3/libtooling/checker.cc b/misra_cpp_2008/rule_9_3_3/libtooling/checker.cc index 902fee84a9..52f3ee4d88 100644 --- a/misra_cpp_2008/rule_9_3_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_3_3/libtooling/checker.cc @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #include "misra_cpp_2008/rule_9_3_3/libtooling/checker.h" @@ -21,8 +33,7 @@ namespace { void ReportError(string path, int line_number, ResultsList* results_list) { string error_message = "如果成员函数可以设为静态,则应设为静态,否则如果可设为 const,则应设为 const"; - misra::proto_util::AddResultToResultsList(results_list, path, line_number, - error_message); + AddResultToResultsList(results_list, path, line_number, error_message); } } // namespace @@ -44,11 +55,9 @@ AST_MATCHER(Expr, isMemberExpr) { } } -class StaticOrConstMethodCallback - : public ast_matchers::MatchFinder::MatchCallback { +class StaticOrConstMethodCallback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( cxxMethodDecl( @@ -70,7 +79,7 @@ class StaticOrConstMethodCallback .bind("const_method"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const CXXMethodDecl* static_method = result.Nodes.getNodeAs("static_method"); @@ -133,10 +142,10 @@ class StaticOrConstMethodCallback } private: - analyzer::proto::ResultsList* results_list_; + ResultsList* results_list_; }; -void Checker::Init(analyzer::proto::ResultsList* result_list) { +void Checker::Init(ResultsList* result_list) { results_list_ = result_list; callback_ = new StaticOrConstMethodCallback; callback_->Init(results_list_, &finder_); diff --git a/misra_cpp_2008/rule_9_3_3/libtooling/checker.h b/misra_cpp_2008/rule_9_3_3/libtooling/checker.h index d548f11da1..6a88c9c755 100644 --- a/misra_cpp_2008/rule_9_3_3/libtooling/checker.h +++ b/misra_cpp_2008/rule_9_3_3/libtooling/checker.h @@ -1,7 +1,19 @@ /* -Copyright 2022 Naive Systems Ltd. -This software contains information and intellectual property that is -confidential and proprietary to Naive Systems Ltd. and its affiliates. +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . */ #ifndef ANALYZER_MISRA_CPP_2008_RULE_9_3_3_LIBTOOLING_CHECKER_H_ diff --git a/misra_cpp_2008/rule_9_3_3/libtooling/main.cc b/misra_cpp_2008/rule_9_3_3/libtooling/main.cc index 145ed55553..3cc60adeaf 100644 --- a/misra_cpp_2008/rule_9_3_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_3_3/libtooling/main.cc @@ -48,7 +48,7 @@ int rule_9_3_3(int argc, char** argv) { ns_libtooling_checker); gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); if (!expected_parser) { - llvm::errs() << expected_parser.takeError(); + errs() << expected_parser.takeError(); return 1; } CommonOptionsParser& options_parser = expected_parser.get(); diff --git a/misra_cpp_2008/rule_9_5_1/libtooling/checker.cc b/misra_cpp_2008/rule_9_5_1/libtooling/checker.cc index 0aae271f22..0748fe2bbc 100644 --- a/misra_cpp_2008/rule_9_5_1/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_5_1/libtooling/checker.cc @@ -30,16 +30,15 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_9_5_1 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(tagDecl(isUnion()).bind("union"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Decl* s = result.Nodes.getNodeAs("union"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { diff --git a/misra_cpp_2008/rule_9_5_1/libtooling/main.cc b/misra_cpp_2008/rule_9_5_1/libtooling/main.cc index 82545a1ce2..13d132cd46 100644 --- a/misra_cpp_2008/rule_9_5_1/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_5_1/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_9_5_1(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_9_6_2/libtooling/checker.cc b/misra_cpp_2008/rule_9_6_2/libtooling/checker.cc index f5ffe6f127..f03bb76078 100644 --- a/misra_cpp_2008/rule_9_6_2/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_6_2/libtooling/checker.cc @@ -32,16 +32,15 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_9_6_2 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher(fieldDecl(isBitField()).bind("decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Decl* s = result.Nodes.getNodeAs("decl"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { diff --git a/misra_cpp_2008/rule_9_6_2/libtooling/main.cc b/misra_cpp_2008/rule_9_6_2/libtooling/main.cc index 1637ddbbf2..14444403fc 100644 --- a/misra_cpp_2008/rule_9_6_2/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_6_2/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_9_6_2(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_9_6_3/libtooling/checker.cc b/misra_cpp_2008/rule_9_6_3/libtooling/checker.cc index b9de96fff2..3bbf2f9326 100644 --- a/misra_cpp_2008/rule_9_6_3/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_6_3/libtooling/checker.cc @@ -30,17 +30,16 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_9_6_3 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( fieldDecl(allOf(hasType(enumType()), isBitField())).bind("decl"), this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const Decl* s = result.Nodes.getNodeAs("decl"); if (misra::libtooling_utils::IsInSystemHeader(s, result.Context)) { diff --git a/misra_cpp_2008/rule_9_6_3/libtooling/main.cc b/misra_cpp_2008/rule_9_6_3/libtooling/main.cc index 4bb6e61339..4a1d876d74 100644 --- a/misra_cpp_2008/rule_9_6_3/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_6_3/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_9_6_3(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/misra_cpp_2008/rule_9_6_4/libtooling/checker.cc b/misra_cpp_2008/rule_9_6_4/libtooling/checker.cc index 50d23bd75c..a0aff2e616 100644 --- a/misra_cpp_2008/rule_9_6_4/libtooling/checker.cc +++ b/misra_cpp_2008/rule_9_6_4/libtooling/checker.cc @@ -30,10 +30,9 @@ using namespace llvm; namespace misra_cpp_2008 { namespace rule_9_6_4 { namespace libtooling { -class Callback : public ast_matchers::MatchFinder::MatchCallback { +class Callback : public MatchFinder::MatchCallback { public: - void Init(analyzer::proto::ResultsList* results_list, - ast_matchers::MatchFinder* finder) { + void Init(analyzer::proto::ResultsList* results_list, MatchFinder* finder) { results_list_ = results_list; finder->addMatcher( @@ -41,7 +40,7 @@ class Callback : public ast_matchers::MatchFinder::MatchCallback { this); } - void run(const ast_matchers::MatchFinder::MatchResult& result) override { + void run(const MatchFinder::MatchResult& result) override { const ValueDecl* s = result.Nodes.getNodeAs("decl"); // check if it is signed integer type diff --git a/misra_cpp_2008/rule_9_6_4/libtooling/main.cc b/misra_cpp_2008/rule_9_6_4/libtooling/main.cc index 53cac87504..54fc68b859 100644 --- a/misra_cpp_2008/rule_9_6_4/libtooling/main.cc +++ b/misra_cpp_2008/rule_9_6_4/libtooling/main.cc @@ -50,7 +50,7 @@ int rule_9_6_4(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); diff --git a/podman_image/Containerfile.misrac100k4 b/podman_image/Containerfile.misrac100k4 index ff9a679b9c..4acf4048d7 100644 --- a/podman_image/Containerfile.misrac100k4 +++ b/podman_image/Containerfile.misrac100k4 @@ -1,4 +1,4 @@ -FROM fedora:36 +FROM fedora:37 # Install build dependencies. RUN dnf install -y \ @@ -10,6 +10,7 @@ clang \ clang-devel \ clang-tools-extra \ cmake \ +coccinelle \ diffutils \ expat-devel \ file \ @@ -42,30 +43,31 @@ wget \ zlib-devel # Install Bear -COPY bear-3.0.21-2.fc36.x86_64.rpm /bear/bear-3.0.21-2.fc36.x86_64.rpm -RUN cd bear/ && dnf install -y bear-3.0.21-2.fc36.x86_64.rpm +COPY bear-3.1.3-2.fc37.x86_64.rpm /bear/bear-3.1.3-2.fc37.x86_64.rpm +RUN cd bear/ && dnf install -y bear-3.1.3-2.fc37.x86_64.rpm # Install Infer -COPY infer /infer -RUN ln -s /infer/bin/infer /usr/local/bin/infer +COPY infer /opt/naivesystems/infer # Install Cppcheck -COPY cppcheck /cppcheck +COPY cppcheck /opt/naivesystems/cppcheck # Install ProjectConverter RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ lxml==4.9.1 RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ jinja2 -COPY ProjectConverter /ProjectConverter +COPY ProjectConverter /opt/naivesystems/projectconverter # Install Cpplint -RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ flake8>=4.0.1 +RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ flake8 RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ flake8-polyfill -RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ pylint>=2.11.0 -RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ tox>=3.0.0 +RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ pylint +RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ tox RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ tox-pyenv -RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ importlib-metadata>=0.12 +RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ importlib-metadata COPY cpplint.py /opt/naivesystems/cpplint.py +RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ semgrep + COPY "clang" "/opt/naivesystems/clang" COPY "clang-extdef-mapping" "/opt/naivesystems/clang-extdef-mapping" COPY "clang-query" "/opt/naivesystems/clang-query" diff --git a/podman_image/Makefile b/podman_image/Makefile index 22dde0861a..52b0fc7b37 100644 --- a/podman_image/Makefile +++ b/podman_image/Makefile @@ -1,6 +1,8 @@ include ../scripts/Makefile.lib -LIMIT = 0 +LIMIT := 10000 +NUM_WORKERS := 2 + DEBUG ?= 0 ifeq ($(DEBUG), 0) BAZELBUILD = bazel build $(BAZEL_OPTS) -c opt @@ -47,7 +49,7 @@ build-base: $(MAKE) bigmain_misra_c_2012 cp ../bazel-bin/podman_image/bigmain/bigmain_misra_c_2012 ./tmpWorkSpace cp ../misra/analyzer/cmd/misra_analyzer ./tmpWorkSpace - cp bear/f36/bear-3.0.21-2.fc36.x86_64.rpm ./tmpWorkSpace + cp bear/f37/bear-3.1.3-2.fc37.x86_64.rpm ./tmpWorkSpace cp clang ./tmpWorkSpace cp clang-extdef-mapping ./tmpWorkSpace cp clang-query ./tmpWorkSpace @@ -62,11 +64,11 @@ build-base: .PHONY: build build: - $(MAKE) build-base LIMIT=100000 NUM_WORKERS=4 LANG="zh" IMAGE_NAME="naive.systems/analyzer/misra:dev" + $(MAKE) build-base LIMIT=$(LIMIT) NUM_WORKERS=$(NUM_WORKERS) LANG="zh" IMAGE_NAME="naive.systems/analyzer/misra:dev" .PHONY: build-en build-en: - $(MAKE) build-base LIMIT=100000 NUM_WORKERS=4 LANG="en" IMAGE_NAME="naive.systems/analyzer/misra:dev_en" + $(MAKE) build-base LIMIT=$(LIMIT) NUM_WORKERS=$(NUM_WORKERS) LANG="en" IMAGE_NAME="naive.systems/analyzer/misra:dev_en" .PHONY: build-googlecpp-en build-googlecpp-en: @@ -99,7 +101,7 @@ build-toy-rules-en: build-misra-cpp-en: $(MAKE) build $(MAKE) clean - make -C ../misra/analyzer/cmd/ LIMIT=300000 NUM_WORKERS=0 LANG="en" + make -C ../misra/analyzer/cmd/ LIMIT=$(LIMIT) NUM_WORKERS=$(NUM_WORKERS) LANG="en" mkdir -p tmpWorkSpace cp ../misra/analyzer/cmd/misra_analyzer ./tmpWorkSpace $(MAKE) bigmain_misra_cpp_2008 diff --git a/podman_image/bear/f36/bear-3.0.21-2.fc36.x86_64.rpm b/podman_image/bear/f36/bear-3.0.21-2.fc36.x86_64.rpm deleted file mode 100644 index d0450e63ce..0000000000 Binary files a/podman_image/bear/f36/bear-3.0.21-2.fc36.x86_64.rpm and /dev/null differ diff --git a/podman_image/bear/f37/bear-3.1.3-2.fc37.x86_64.rpm b/podman_image/bear/f37/bear-3.1.3-2.fc37.x86_64.rpm new file mode 100644 index 0000000000..e398624a15 Binary files /dev/null and b/podman_image/bear/f37/bear-3.1.3-2.fc37.x86_64.rpm differ diff --git a/podman_image/bigmain/BUILD b/podman_image/bigmain/BUILD index a4db4f58de..dcceec04b0 100644 --- a/podman_image/bigmain/BUILD +++ b/podman_image/bigmain/BUILD @@ -460,11 +460,11 @@ cc_library( ], ) -cc_binary( - name = "bigmain_misra_c_2012", +cc_library( + name = "bigmain", srcs = ["main.cc"], + visibility = ["//visibility:public"], deps = [ - ":misra_deps", ":rule", "//libtooling_includes:cmd_options", "@com_github_google_glog//:glog", @@ -472,54 +472,57 @@ cc_binary( ], ) +cc_binary( + name = "bigmain_ce", + deps = [ + ":autosar_deps", + ":bigmain", + ":googlecpp_deps", + ":misra_cpp_2008_deps", + ":misra_deps", + ], +) + +cc_binary( + name = "bigmain_misra_c_2012", + deps = [ + ":bigmain", + ":misra_deps", + ], +) + cc_binary( name = "bigmain_misra_cpp_2008", - srcs = ["main.cc"], deps = [ + ":bigmain", ":misra_cpp_2008_deps", ":misra_deps", - ":rule", - "//libtooling_includes:cmd_options", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings:str_format", ], ) cc_binary( name = "bigmain_googlecpp", - srcs = ["main.cc"], deps = [ + ":bigmain", ":googlecpp_deps", - ":rule", - "//libtooling_includes:cmd_options", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings:str_format", ], ) cc_binary( name = "bigmain_autosar", - srcs = ["main.cc"], deps = [ ":autosar_deps", + ":bigmain", ":misra_cpp_2008_deps", ":misra_deps", - ":rule", - "//libtooling_includes:cmd_options", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings:str_format", ], ) cc_binary( name = "bigmain_toy_rules", - srcs = ["main.cc"], deps = [ - ":rule", + ":bigmain", ":toy_rules_deps", - "//libtooling_includes:cmd_options", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings:str_format", ], ) diff --git a/podman_image/bigmain/main.cc b/podman_image/bigmain/main.cc index add86a9a45..23ace6b528 100644 --- a/podman_image/bigmain/main.cc +++ b/podman_image/bigmain/main.cc @@ -26,6 +26,9 @@ using Rule = podman_image::bigmain::Rule; int main(int argc, char** argv) { std::vector& all_rules = Rule::GetAllRules(); + if (all_rules.size() == 1) { + return all_rules[0]->Run(argc, argv); + } for (Rule* rule : all_rules) { int r; if (rule->Entrypoint(argc, argv, &r)) return r; diff --git a/podman_image/bigmain/rule.h b/podman_image/bigmain/rule.h index 6d317df017..56d956d700 100644 --- a/podman_image/bigmain/rule.h +++ b/podman_image/bigmain/rule.h @@ -26,6 +26,8 @@ namespace bigmain { class Rule { public: + virtual ~Rule() {} + static std::vector& GetAllRules() { static std::vector* all_rules = new std::vector(); return *all_rules; @@ -35,9 +37,12 @@ class Rule { // Returns true if this rule is handled virtual bool Entrypoint(int argc, char** argv, int* return_value) = 0; + + // Unconditionally run this rule. + virtual int Run(int argc, char** argv) = 0; }; } // namespace bigmain } // namespace podman_image -#endif +#endif // ANALYZER_PODMAN_IMAGE_BIGMAIN_RULE_H_ diff --git a/podman_image/bigmain/suffix_rule.cc b/podman_image/bigmain/suffix_rule.cc index e2db04c23e..7d9ba820f0 100644 --- a/podman_image/bigmain/suffix_rule.cc +++ b/podman_image/bigmain/suffix_rule.cc @@ -25,7 +25,7 @@ namespace bigmain { bool SuffixRule::Entrypoint(int argc, char** argv, int* return_value) { if (!absl::EndsWith(argv[0], suffix_)) return false; - *return_value = fn_(argc, argv); + *return_value = Run(argc, argv); return true; } diff --git a/podman_image/bigmain/suffix_rule.h b/podman_image/bigmain/suffix_rule.h index 44eba3b443..b4c6f5fb78 100644 --- a/podman_image/bigmain/suffix_rule.h +++ b/podman_image/bigmain/suffix_rule.h @@ -19,6 +19,7 @@ along with this program. If not, see . #ifndef ANALYZER_PODMAN_IMAGE_BIGMAIN_SUFFIX_RULE_H_ #define ANALYZER_PODMAN_IMAGE_BIGMAIN_SUFFIX_RULE_H_ +#include #include #include "podman_image/bigmain/rule.h" @@ -28,12 +29,14 @@ namespace bigmain { class SuffixRule : Rule { public: - typedef int (*Fn)(int, char**); + typedef std::function Fn; SuffixRule(std::string suffix, Fn fn) : suffix_(suffix), fn_(fn) {} bool Entrypoint(int argc, char** argv, int* return_value) override; + int Run(int argc, char** argv) override { return fn_(argc, argv); } + private: std::string suffix_; Fn fn_; @@ -42,4 +45,4 @@ class SuffixRule : Rule { } // namespace bigmain } // namespace podman_image -#endif +#endif // ANALYZER_PODMAN_IMAGE_BIGMAIN_SUFFIX_RULE_H_ diff --git a/sdk/checker/BUILD b/sdk/checker/BUILD new file mode 100644 index 0000000000..dd3467e600 --- /dev/null +++ b/sdk/checker/BUILD @@ -0,0 +1,29 @@ +cc_library( + name = "checker", + srcs = [ + "ast_checker.cc", + "decl_checker.cc", + "define_decl_checker.cc", + "define_expr_checker.cc", + "expr_checker.cc", + ], + hdrs = [ + "ast_checker.h", + "checker.h", + "decl_checker.h", + "define_ast_checker.h", + "define_decl_checker.h", + "define_expr_checker.h", + "expr_checker.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//analyzer/proto:analyzer_cc_proto", + "//misra:proto_util", + "//misra/libtooling_utils", + "//podman_image/bigmain:suffix_rule", + "@com_github_google_glog//:glog", + "@com_google_absl//absl/strings", + "@llvm-project//clang:tooling", + ], +) diff --git a/googlecpp/g1159/libtooling/g1159.cc b/sdk/checker/ast_checker.cc similarity index 65% rename from googlecpp/g1159/libtooling/g1159.cc rename to sdk/checker/ast_checker.cc index 0d22c6ca75..775c97b8f7 100644 --- a/googlecpp/g1159/libtooling/g1159.cc +++ b/sdk/checker/ast_checker.cc @@ -16,15 +16,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "sdk/checker/ast_checker.h" + #include #include #include +#include -#include "googlecpp/g1159/libtooling/checker.h" -#include "googlecpp/g1159/libtooling/lib.h" #include "misra/libtooling_utils/libtooling_utils.h" #include "misra/proto_util.h" -#include "podman_image/bigmain/suffix_rule.h" using namespace clang; using namespace llvm; @@ -32,10 +32,10 @@ using namespace llvm; extern cl::OptionCategory ns_libtooling_checker; extern cl::opt results_path; -namespace googlecpp { -namespace g1159 { -namespace libtooling { -int g1159(int argc, char** argv) { +namespace sdk { +namespace checker { + +int ASTChecker::Run(int argc, char** argv) { google::InitGoogleLogging(argv[0]); gflags::AllowCommandLineReparsing(); int gflag_argc = argc; @@ -48,32 +48,20 @@ int g1159(int argc, char** argv) { libtooling_argc, &const_argv[argc - libtooling_argc], ns_libtooling_checker); if (!ep) { - llvm::errs() << ep.takeError(); + errs() << ep.takeError(); return 1; } tooling::CommonOptionsParser& op = ep.get(); tooling::ClangTool tool(op.getCompilations(), op.getSourcePathList()); - analyzer::proto::ResultsList all_results; - - googlecpp::g1159::libtooling::Checker checker; - checker.Init(&all_results); - int status = tool.run( - tooling::newFrontendActionFactory(checker.GetMatchFinder()).get()); - LOG(INFO) << "libtooling status: " << status; - - if (misra::proto_util::GenerateProtoFile(all_results, results_path).ok()) { - LOG(INFO) << "g1159 check done"; + callback_->Init(&results_list_, &finder_); + int status = tool.run(tooling::newFrontendActionFactory(&finder_).get()); + LOG(INFO) << name_ << " libtooling status: " << status; + if (misra::proto_util::GenerateProtoFile(results_list_, results_path).ok()) { + LOG(INFO) << name_ << " check done"; } return 0; } -} // namespace libtooling -} // namespace g1159 -} // namespace googlecpp - -namespace { - -podman_image::bigmain::SuffixRule _("googlecpp/g1159", - googlecpp::g1159::libtooling::g1159); -} // namespace +} // namespace checker +} // namespace sdk diff --git a/sdk/checker/ast_checker.h b/sdk/checker/ast_checker.h new file mode 100644 index 0000000000..4184a490a2 --- /dev/null +++ b/sdk/checker/ast_checker.h @@ -0,0 +1,65 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#ifndef ANALYZER_SDK_CHECKER_AST_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_AST_CHECKER_H_ + +#include + +#include + +#include "analyzer/proto/results.pb.h" +#include "sdk/checker/checker.h" + +namespace sdk { +namespace checker { + +using analyzer::proto::ResultsList; +using clang::ast_matchers::MatchFinder; + +class ASTCheckerCallback : public MatchFinder::MatchCallback { + public: + virtual ~ASTCheckerCallback() {} + + virtual void Init(ResultsList* results_list, MatchFinder* finder) = 0; + + virtual void run(const MatchFinder::MatchResult& Result) = 0; +}; + +class ASTChecker : public Checker { + public: + virtual ~ASTChecker() {} + + void Init(std::string name, ASTCheckerCallback* callback) { + name_ = name; + callback_ = callback; + } + + int Run(int argc, char** argv) override; + + private: + ResultsList results_list_; + MatchFinder finder_; + std::string name_; + ASTCheckerCallback* callback_; +}; + +} // namespace checker +} // namespace sdk + +#endif // ANALYZER_SDK_CHECKER_AST_CHECKER_H_ diff --git a/googlecpp/g1159/libtooling/lib.h b/sdk/checker/checker.h similarity index 70% rename from googlecpp/g1159/libtooling/lib.h rename to sdk/checker/checker.h index 445773440e..90a3ec2471 100644 --- a/googlecpp/g1159/libtooling/lib.h +++ b/sdk/checker/checker.h @@ -16,17 +16,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_GOOGLECPP_G1159_LIBTOOLING_LIB_H_ -#define ANALYZER_GOOGLECPP_G1159_LIBTOOLING_LIB_H_ +#ifndef ANALYZER_SDK_CHECKER_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_CHECKER_H_ -namespace googlecpp { -namespace g1159 { -namespace libtooling { +namespace sdk { +namespace checker { -int g1159(int argc, char** argv); +class Checker { + public: + virtual ~Checker() {} -} -} // namespace g1159 -} // namespace googlecpp + virtual int Run(int argc, char** argv) = 0; +}; -#endif // ANALYZER_GOOGLECPP_G1159_LIBTOOLING_LIB_H_ +} // namespace checker +} // namespace sdk + +#endif // ANALYZER_SDK_CHECKER_CHECKER_H_ diff --git a/sdk/checker/decl_checker.cc b/sdk/checker/decl_checker.cc new file mode 100644 index 0000000000..ae5dc454f8 --- /dev/null +++ b/sdk/checker/decl_checker.cc @@ -0,0 +1,72 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#include "sdk/checker/decl_checker.h" + +#include +#include + +#include "misra/libtooling_utils/libtooling_utils.h" +#include "misra/proto_util.h" + +using analyzer::proto::ResultsList; +using clang::ast_matchers::DeclarationMatcher; +using clang::ast_matchers::MatchFinder; +using std::string; + +namespace { + +class Callback : public sdk::checker::ASTCheckerCallback { + public: + Callback(string message, DeclarationMatcher matcher, string bind_id) + : message_(message), matcher_(matcher), bind_id_(bind_id) {} + + void Init(ResultsList* results_list, MatchFinder* finder) override { + results_list_ = results_list; + finder->addMatcher(matcher_, this); + } + + void run(const MatchFinder::MatchResult& result) override { + const clang::Decl* decl = result.Nodes.getNodeAs(bind_id_); + string path = + misra::libtooling_utils::GetFilename(decl, result.SourceManager); + int line = misra::libtooling_utils::GetLine(decl, result.SourceManager); + misra::proto_util::AddResultToResultsList(results_list_, path, line, + message_); + } + + private: + string message_; + DeclarationMatcher matcher_; + string bind_id_; + ResultsList* results_list_; +}; + +} // namespace + +namespace sdk { +namespace checker { + +void DeclChecker::Init(string name, string message, DeclarationMatcher matcher, + string bind_id) { + callback_ = new Callback(message, matcher, bind_id); + ASTChecker::Init(name, callback_); +} + +} // namespace checker +} // namespace sdk diff --git a/toy_rules/rule_1/libtooling/checker.h b/sdk/checker/decl_checker.h similarity index 56% rename from toy_rules/rule_1/libtooling/checker.h rename to sdk/checker/decl_checker.h index 4fa84f7aa6..f7b918a6c7 100644 --- a/toy_rules/rule_1/libtooling/checker.h +++ b/sdk/checker/decl_checker.h @@ -16,32 +16,29 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_TOY_RULES_1_LIBTOOLING_CHECKER_H_ -#define ANALYZER_TOY_RULES_1_LIBTOOLING_CHECKER_H_ +#ifndef ANALYZER_SDK_CHECKER_DECL_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_DECL_CHECKER_H_ #include -#include "misra/proto_util.h" +#include -namespace toy_rules { -namespace rule_1 { -namespace libtooling { +#include "sdk/checker/ast_checker.h" -class Callback; +namespace sdk { +namespace checker { -class Checker { +class DeclChecker : public ASTChecker { public: - void Init(analyzer::proto::ResultsList* results_list); - clang::ast_matchers::MatchFinder* GetMatchFinder() { return &finder_; } + void Init(std::string name, std::string message, + clang::ast_matchers::DeclarationMatcher matcher, + std::string bind_id); private: - Callback* callback_; - clang::ast_matchers::MatchFinder finder_; - analyzer::proto::ResultsList* results_list_; + ASTCheckerCallback* callback_; }; -} // namespace libtooling -} // namespace rule_1 -} // namespace toy_rules +} // namespace checker +} // namespace sdk -#endif // ANALYZER_TOY_RULES_1_LIBTOOLING_CHECKER_H_ +#endif // ANALYZER_SDK_CHECKER_DECL_CHECKER_H_ diff --git a/sdk/checker/define_ast_checker.h b/sdk/checker/define_ast_checker.h new file mode 100644 index 0000000000..04b3182284 --- /dev/null +++ b/sdk/checker/define_ast_checker.h @@ -0,0 +1,49 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#ifndef ANALYZER_SDK_CHECKER_DEFINE_AST_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_DEFINE_AST_CHECKER_H_ + +#include + +#include "podman_image/bigmain/suffix_rule.h" +#include "sdk/checker/ast_checker.h" + +namespace sdk { +namespace checker { + +template +class DefineASTChecker { + public: + // TODO(xjia): separate ruleset name and rule name + explicit DefineASTChecker(std::string suffix) + : suffix_rule_(suffix, [suffix](int argc, char** argv) { + CallbackT callback; + sdk::checker::ASTChecker checker; + checker.Init(suffix, &callback); + return checker.Run(argc, argv); + }) {} + + private: + podman_image::bigmain::SuffixRule suffix_rule_; +}; + +} // namespace checker +} // namespace sdk + +#endif // ANALYZER_SDK_CHECKER_DEFINE_AST_CHECKER_H_ diff --git a/sdk/checker/define_decl_checker.cc b/sdk/checker/define_decl_checker.cc new file mode 100644 index 0000000000..687107619b --- /dev/null +++ b/sdk/checker/define_decl_checker.cc @@ -0,0 +1,41 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#include "sdk/checker/define_decl_checker.h" + +#include + +#include + +#include "sdk/checker/decl_checker.h" + +namespace sdk { +namespace checker { + +DefineDeclChecker::DefineDeclChecker( + std::string suffix, std::string message, + clang::ast_matchers::DeclarationMatcher matcher, std::string bind_id) + : suffix_rule_(suffix, + [suffix, message, matcher, bind_id](int argc, char** argv) { + sdk::checker::DeclChecker checker; + checker.Init(suffix, message, matcher, bind_id); + return checker.Run(argc, argv); + }) {} + +} // namespace checker +} // namespace sdk diff --git a/sdk/checker/define_decl_checker.h b/sdk/checker/define_decl_checker.h new file mode 100644 index 0000000000..6cf6fcc325 --- /dev/null +++ b/sdk/checker/define_decl_checker.h @@ -0,0 +1,44 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#ifndef ANALYZER_SDK_CHECKER_DEFINE_DECL_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_DEFINE_DECL_CHECKER_H_ + +#include + +#include + +#include "podman_image/bigmain/suffix_rule.h" + +namespace sdk { +namespace checker { + +class DefineDeclChecker { + public: + DefineDeclChecker(std::string suffix, std::string message, + clang::ast_matchers::DeclarationMatcher matcher, + std::string bind_id); + + private: + podman_image::bigmain::SuffixRule suffix_rule_; +}; + +} // namespace checker +} // namespace sdk + +#endif // ANALYZER_SDK_CHECKER_DEFINE_DECL_CHECKER_H_ diff --git a/sdk/checker/define_expr_checker.cc b/sdk/checker/define_expr_checker.cc new file mode 100644 index 0000000000..77857fca7b --- /dev/null +++ b/sdk/checker/define_expr_checker.cc @@ -0,0 +1,41 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#include "sdk/checker/define_expr_checker.h" + +#include + +#include + +#include "sdk/checker/expr_checker.h" + +namespace sdk { +namespace checker { + +DefineExprChecker::DefineExprChecker( + std::string suffix, std::string message, + clang::ast_matchers::StatementMatcher matcher, std::string bind_id) + : suffix_rule_(suffix, + [suffix, message, matcher, bind_id](int argc, char** argv) { + sdk::checker::ExprChecker checker; + checker.Init(suffix, message, matcher, bind_id); + return checker.Run(argc, argv); + }) {} + +} // namespace checker +} // namespace sdk diff --git a/googlecpp/g1159/libtooling/checker.h b/sdk/checker/define_expr_checker.h similarity index 52% rename from googlecpp/g1159/libtooling/checker.h rename to sdk/checker/define_expr_checker.h index 2c38b0b0a9..f6abc65951 100644 --- a/googlecpp/g1159/libtooling/checker.h +++ b/sdk/checker/define_expr_checker.h @@ -16,32 +16,29 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_GOOGLECPP_G1159_LIBTOOLING_CHECKER_H_ -#define ANALYZER_GOOGLECPP_G1159_LIBTOOLING_CHECKER_H_ +#ifndef ANALYZER_SDK_CHECKER_DEFINE_EXPR_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_DEFINE_EXPR_CHECKER_H_ -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include "misra/proto_util.h" +#include -using namespace clang; +#include -namespace googlecpp { -namespace g1159 { -namespace libtooling { -class Callback; +#include "podman_image/bigmain/suffix_rule.h" -class Checker { +namespace sdk { +namespace checker { + +class DefineExprChecker { public: - void Init(analyzer::proto::ResultsList* results_list); - ast_matchers::MatchFinder* GetMatchFinder() { return &finder_; } + explicit DefineExprChecker(std::string suffix, std::string message, + clang::ast_matchers::StatementMatcher matcher, + std::string bind_id); private: - Callback* callback_; - ast_matchers::MatchFinder finder_; - analyzer::proto::ResultsList* results_list_; + podman_image::bigmain::SuffixRule suffix_rule_; }; -} // namespace libtooling -} // namespace g1159 -} // namespace googlecpp +} // namespace checker +} // namespace sdk -#endif // ANALYZER_GOOGLECPP_G1159_LIBTOOLING_CHECKER_H_ +#endif // ANALYZER_SDK_CHECKER_DEFINE_EXPR_CHECKER_H_ diff --git a/sdk/checker/expr_checker.cc b/sdk/checker/expr_checker.cc new file mode 100644 index 0000000000..34f419359f --- /dev/null +++ b/sdk/checker/expr_checker.cc @@ -0,0 +1,72 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +#include "sdk/checker/expr_checker.h" + +#include +#include + +#include "misra/libtooling_utils/libtooling_utils.h" +#include "misra/proto_util.h" + +using analyzer::proto::ResultsList; +using clang::ast_matchers::MatchFinder; +using clang::ast_matchers::StatementMatcher; +using std::string; + +namespace { + +class Callback : public sdk::checker::ASTCheckerCallback { + public: + Callback(string message, StatementMatcher matcher, string bind_id) + : message_(message), matcher_(matcher), bind_id_(bind_id) {} + + void Init(ResultsList* results_list, MatchFinder* finder) override { + results_list_ = results_list; + finder->addMatcher(matcher_, this); + } + + void run(const MatchFinder::MatchResult& result) override { + const clang::Expr* expr = result.Nodes.getNodeAs(bind_id_); + string path = + misra::libtooling_utils::GetFilename(expr, result.SourceManager); + int line = misra::libtooling_utils::GetLine(expr, result.SourceManager); + misra::proto_util::AddResultToResultsList(results_list_, path, line, + message_); + } + + private: + string message_; + StatementMatcher matcher_; + string bind_id_; + ResultsList* results_list_; +}; + +} // namespace + +namespace sdk { +namespace checker { + +void ExprChecker::Init(string name, string message, StatementMatcher matcher, + string bind_id) { + callback_ = new Callback(message, matcher, bind_id); + ASTChecker::Init(name, callback_); +} + +} // namespace checker +} // namespace sdk diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/lib.h b/sdk/checker/expr_checker.h similarity index 56% rename from misra_cpp_2008/rule_4_10_1/libtooling/lib.h rename to sdk/checker/expr_checker.h index 87a3f70ecb..2711cc5847 100644 --- a/misra_cpp_2008/rule_4_10_1/libtooling/lib.h +++ b/sdk/checker/expr_checker.h @@ -16,17 +16,28 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_LIB_H_ -#define ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_LIB_H_ +#ifndef ANALYZER_SDK_CHECKER_EXPR_CHECKER_H_ +#define ANALYZER_SDK_CHECKER_EXPR_CHECKER_H_ -namespace misra_cpp_2008 { -namespace rule_4_10_1 { -namespace libtooling { +#include -int rule_4_10_1(int argc, char** argv); +#include -} // namespace libtooling -} // namespace rule_4_10_1 -} // namespace misra_cpp_2008 +#include "sdk/checker/ast_checker.h" -#endif // ANALYZER_MISRA_CPP_2008_RULE_4_10_1_LIBTOOLING_LIB_H_ +namespace sdk { +namespace checker { + +class ExprChecker : public ASTChecker { + public: + void Init(std::string name, std::string message, + clang::ast_matchers::StatementMatcher matcher, std::string bind_id); + + private: + ASTCheckerCallback* callback_; +}; + +} // namespace checker +} // namespace sdk + +#endif // ANALYZER_SDK_CHECKER_EXPR_CHECKER_H_ diff --git a/sdk/testcase/testcase.go b/sdk/testcase/testcase.go new file mode 100644 index 0000000000..8278e36516 --- /dev/null +++ b/sdk/testcase/testcase.go @@ -0,0 +1,139 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2022-2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package testcase + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" + pb "naive.systems/analyzer/analyzer/proto" + "naive.systems/analyzer/cruleslib/options" + "naive.systems/analyzer/cruleslib/testlib" +) + +type TestCase struct { + t *testing.T + Srcdir string + Options *options.CheckOptions +} + +func New(t *testing.T, dirname string) TestCase { + srcdir, err := filepath.Abs(dirname) + if err != nil { + t.Fatalf("filepath.Abs(%s): %v", dirname, err) + } + // Note that testlib.MakeTestOption is location sensitive. + options, err := testlib.MakeTestOption(srcdir) + if err != nil { + t.Fatalf("failed to init testing env: %v", err) + } + return TestCase{t, srcdir, options} +} + +func NewWithSystemHeader(t *testing.T, dirname string) TestCase { + srcdir, err := filepath.Abs(dirname) + if err != nil { + t.Fatalf("filepath.Abs(%s): %v", dirname, err) + } + // Note that testlib.MakeTestOption is location sensitive. + options, err := testlib.MakeTestOption(srcdir) + if err != nil { + t.Fatalf("failed to init testing env: %v", err) + } + testlib.AddSystemHeader(options) + return TestCase{t, srcdir, options} +} + +func NewWithoutOptions(t *testing.T, dirname string) TestCase { + srcdir, err := filepath.Abs(dirname) + if err != nil { + t.Fatalf("filepath.Abs(%s): %v", dirname, err) + } + options := options.CheckOptions{} + return TestCase{t, srcdir, &options} +} + +func (tc *TestCase) expectedEquals(actual *pb.ResultsList) bool { + path := filepath.Join(tc.Srcdir, "expected.textproto") + bytes, err := os.ReadFile(path) + if err != nil { + tc.t.Fatalf("os.ReadFile(%s): %v", path, err) + } + expected := &pb.ResultsList{} + err = prototext.Unmarshal(bytes, expected) + if err != nil { + tc.t.Fatalf("prototext.Unmarshal(%s): %v", path, err) + } + // ignore misra fields + cleaned_actual := &pb.ResultsList{} + for _, result := range actual.Results { + cleaned_result := &pb.Result{} + cleaned_result.Path = result.Path + cleaned_result.LineNumber = result.LineNumber + cleaned_result.Locations = result.Locations + // TODO(r/13482): remove this hack and compare the whole error message + cleaned_result.ErrorMessage, _, _ = strings.Cut(result.ErrorMessage, "\n") + cleaned_result.FalsePositive = result.FalsePositive + cleaned_actual.Results = append(cleaned_actual.Results, cleaned_result) + } + for _, result := range expected.Results { + result.Path = filepath.Join(tc.Srcdir, result.Path) + } + return proto.Equal(expected, cleaned_actual) +} + +func (tc *TestCase) dumpProto(m proto.Message) { + bytes, err := prototext.Marshal(m) + if err == nil { + tc.t.Log(string(bytes)) + } else { + tc.t.Errorf("prototext.Marshal: %v", err) + } +} + +func (tc *TestCase) ExpectOK(actual *pb.ResultsList, err error) { + if err != nil { + tc.t.Fatalf("checker returned error: %v", err) + } + if !tc.expectedEquals(actual) { + tc.dumpProto(actual) + tc.t.Fatal("checker is expected to be OK") + } +} + +func (tc *TestCase) ExpectFailure(actual *pb.ResultsList, err error) { + if err != nil { + tc.t.Fatalf("checker returned error: %v", err) + } + if tc.expectedEquals(actual) { + tc.dumpProto(actual) + tc.t.Fatal("checker is expected to fail") + } +} + +func (tc *TestCase) ExpectError(_ *pb.ResultsList, err error) { + if err == nil { + tc.t.Fatal("checker is expected to return an error") + } + tc.t.Logf("checker returned error: %v", err) +} diff --git a/semgrep/double_free/_bad0001/expected.textproto b/semgrep/double_free/_bad0001/expected.textproto new file mode 100644 index 0000000000..7cb9f08aa2 --- /dev/null +++ b/semgrep/double_free/_bad0001/expected.textproto @@ -0,0 +1,5 @@ +results { + path: "test.c" + line_number: 5 + error_message: "[double-free]: Variable 'a' was freed twice. This can lead to undefined behavior." +} diff --git a/semgrep/double_free/_bad0001/test.c b/semgrep/double_free/_bad0001/test.c new file mode 100644 index 0000000000..233b09bb66 --- /dev/null +++ b/semgrep/double_free/_bad0001/test.c @@ -0,0 +1,6 @@ +int f(unsigned int x) +{ + int* a = (int*)malloc(16); + free(a); + free(a); +} diff --git a/semgrep/double_free/_good0001/expected.textproto b/semgrep/double_free/_good0001/expected.textproto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/semgrep/double_free/_good0001/test.c b/semgrep/double_free/_good0001/test.c new file mode 100644 index 0000000000..ae23ed2f4f --- /dev/null +++ b/semgrep/double_free/_good0001/test.c @@ -0,0 +1,5 @@ +int f(unsigned int x) +{ + int* a = (int*)malloc(16); + free(a); +} diff --git a/semgrep/double_free/double_free.semgrep b/semgrep/double_free/double_free.semgrep new file mode 100644 index 0000000000..928ef84bd3 --- /dev/null +++ b/semgrep/double_free/double_free.semgrep @@ -0,0 +1,27 @@ +rules: + - id: double-free + patterns: + - pattern-not: | + free($VAR); + ... + $VAR = NULL; + ... + free($VAR); + - pattern-not: | + free($VAR); + ... + $VAR = malloc(...); + ... + free($VAR); + - pattern-inside: | + free($VAR); + ... + $FREE($VAR); + - metavariable-pattern: + metavariable: $FREE + pattern: free + - focus-metavariable: $FREE + message: Variable '$VAR' was freed twice. This can lead to undefined behavior. + languages: + - c + severity: ERROR diff --git a/semgrep/double_free/double_free_test.go b/semgrep/double_free/double_free_test.go new file mode 100644 index 0000000000..71bfdc0274 --- /dev/null +++ b/semgrep/double_free/double_free_test.go @@ -0,0 +1,38 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package double_free + +import ( + "path/filepath" + "testing" + + "naive.systems/analyzer/cruleslib/runner" + "naive.systems/analyzer/cruleslib/testlib" + "naive.systems/analyzer/sdk/testcase" +) + +func TestGood0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_good0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunSemgrep(tc.Srcdir, filepath.Dir(tc.Srcdir), testlib.GetSemgrepBinPath()))) +} + +func TestBad0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_bad0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunSemgrep(tc.Srcdir, filepath.Dir(tc.Srcdir), testlib.GetSemgrepBinPath()))) +} diff --git a/semgrep/double_free/semgrep_rules b/semgrep/double_free/semgrep_rules new file mode 100644 index 0000000000..358c7ce6a9 --- /dev/null +++ b/semgrep/double_free/semgrep_rules @@ -0,0 +1 @@ +double_free.semgrep diff --git a/semgrep/dynamic_heap_mem/_bad0001/expected.textproto b/semgrep/dynamic_heap_mem/_bad0001/expected.textproto new file mode 100644 index 0000000000..f8f24c7c66 --- /dev/null +++ b/semgrep/dynamic_heap_mem/_bad0001/expected.textproto @@ -0,0 +1,11 @@ +results { + path: "test.cc" + line_number: 3 + error_message: "[dynamic-heap-memory]: Dynamic heap memory allocation shall not be used." +} + +results { + path: "test.cc" + line_number: 4 + error_message: "[dynamic-heap-memory]: Dynamic heap memory allocation shall not be used." +} diff --git a/semgrep/dynamic_heap_mem/_bad0001/test.cc b/semgrep/dynamic_heap_mem/_bad0001/test.cc new file mode 100644 index 0000000000..114782a735 --- /dev/null +++ b/semgrep/dynamic_heap_mem/_bad0001/test.cc @@ -0,0 +1,6 @@ +int main() +{ + int *p = new int; + delete p; + return 0; +} diff --git a/semgrep/dynamic_heap_mem/_good0001/expected.textproto b/semgrep/dynamic_heap_mem/_good0001/expected.textproto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/semgrep/dynamic_heap_mem/_good0001/test.cc b/semgrep/dynamic_heap_mem/_good0001/test.cc new file mode 100644 index 0000000000..47b1fbc286 --- /dev/null +++ b/semgrep/dynamic_heap_mem/_good0001/test.cc @@ -0,0 +1,13 @@ +#include +#define new 1 +#define free(a) (printf(#a)) + +void malloc() {} + +int main() +{ + int x = new; + free(x); + malloc(); + return 0; +} diff --git a/semgrep/dynamic_heap_mem/dynamic_heap_mem.semgrep b/semgrep/dynamic_heap_mem/dynamic_heap_mem.semgrep new file mode 100644 index 0000000000..5a9d023d19 --- /dev/null +++ b/semgrep/dynamic_heap_mem/dynamic_heap_mem.semgrep @@ -0,0 +1,9 @@ +rules: +- id: dynamic-heap-memory + patterns: + - pattern-either: + - pattern: new $TYPE; + - pattern: delete $POINT; + message: Dynamic heap memory allocation shall not be used. + languages: [cpp] + severity: ERROR diff --git a/semgrep/dynamic_heap_mem/dynamic_heap_mem_test.go b/semgrep/dynamic_heap_mem/dynamic_heap_mem_test.go new file mode 100644 index 0000000000..d1aee81a94 --- /dev/null +++ b/semgrep/dynamic_heap_mem/dynamic_heap_mem_test.go @@ -0,0 +1,38 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package dynamic_heap_memory + +import ( + "path/filepath" + "testing" + + "naive.systems/analyzer/cruleslib/runner" + "naive.systems/analyzer/cruleslib/testlib" + "naive.systems/analyzer/sdk/testcase" +) + +func TestGood0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_good0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunSemgrep(tc.Srcdir, filepath.Dir(tc.Srcdir), testlib.GetSemgrepBinPath()))) +} + +func TestBad0001(t *testing.T) { + tc := testcase.NewWithoutOptions(t, "_bad0001") + tc.ExpectOK(testlib.ToTestResult(runner.RunSemgrep(tc.Srcdir, filepath.Dir(tc.Srcdir), testlib.GetSemgrepBinPath()))) +} diff --git a/semgrep/dynamic_heap_mem/semgrep_rules b/semgrep/dynamic_heap_mem/semgrep_rules new file mode 100644 index 0000000000..8e76867c9a --- /dev/null +++ b/semgrep/dynamic_heap_mem/semgrep_rules @@ -0,0 +1 @@ +dynamic_heap_mem.semgrep diff --git a/telemetry/client/sender/sender.go b/telemetry/client/sender/sender.go new file mode 100644 index 0000000000..9d73c3985a --- /dev/null +++ b/telemetry/client/sender/sender.go @@ -0,0 +1,323 @@ +/* +NaiveSystems Analyze - A tool for static code analysis +Copyright (C) 2023 Naive Systems Ltd. + +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 3 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, see . +*/ + +package sender + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "net/http" + "os" + "path/filepath" + "runtime" + "strings" + "sync" + "syscall" + "time" + + "github.com/golang/glog" + "github.com/google/uuid" +) + +const ( + receiverURL = "https://naivesystems.com/receiver.php" + maxRetries = 3 + retryDelay = 5 * time.Second +) + +type jsonObject = map[string]any + +var q = make(chan jsonObject, 1000) + +var pendingMessages sync.WaitGroup + +var ( + waitStartMutex sync.Mutex + waitStarted bool + waitStartTime time.Time +) + +var initData = jsonObject{} + +var sessionID = uuid.NewString() + +func initUtsname() { + var utsname syscall.Utsname + + err := syscall.Uname(&utsname) + if err != nil { + return + } + + initData["utsname"] = jsonObject{ + "sysname": charArrayToString(utsname.Sysname[:]), + "nodename": charArrayToString(utsname.Nodename[:]), + "release": charArrayToString(utsname.Release[:]), + "version": charArrayToString(utsname.Version[:]), + "machine": charArrayToString(utsname.Machine[:]), + "domainname": charArrayToString(utsname.Domainname[:]), + } +} + +// extractCPUModelName reads /proc/cpuinfo and extracts the CPU model name. +func extractCPUModelName() (string, error) { + file, err := os.Open("/proc/cpuinfo") + if err != nil { + return "", err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + if strings.HasPrefix(line, "model name") { + parts := strings.SplitN(line, ":", 2) + if len(parts) == 2 { + return strings.TrimSpace(parts[1]), nil + } + } + } + + if err := scanner.Err(); err != nil { + return "", err + } + + return "", nil // No model name found +} + +func initCPUInfo() { + cpuModelName, err := extractCPUModelName() + if err != nil { + return + } + + // Ensure the nested maps exist + if _, ok := initData["proc"]; !ok { + initData["proc"] = make(jsonObject) + } + procInfo, _ := initData["proc"].(jsonObject) + + if _, ok := procInfo["cpuinfo"]; !ok { + procInfo["cpuinfo"] = make(jsonObject) + } + cpuInfo, _ := procInfo["cpuinfo"].(jsonObject) + + // Add model name to the map + cpuInfo["model name"] = cpuModelName +} + +func initDMIInfo() { + baseDir := "/sys/class/dmi/id/" + + entries, err := os.ReadDir(baseDir) + if err != nil { + return + } + + // Ensure the nested maps exist + if _, ok := initData["sys"]; !ok { + initData["sys"] = make(jsonObject) + } + sysInfo, _ := initData["sys"].(jsonObject) + + if _, ok := sysInfo["class"]; !ok { + sysInfo["class"] = make(jsonObject) + } + classInfo, _ := sysInfo["class"].(jsonObject) + + if _, ok := classInfo["dmi"]; !ok { + classInfo["dmi"] = make(jsonObject) + } + dmiInfo, _ := classInfo["dmi"].(jsonObject) + + if _, ok := dmiInfo["id"]; !ok { + dmiInfo["id"] = make(jsonObject) + } + idInfo, _ := dmiInfo["id"].(jsonObject) + + for _, entry := range entries { + if entry.IsDir() { + // Skip directories + continue + } + + filePath := filepath.Join(baseDir, entry.Name()) + + content, err := os.ReadFile(filePath) + if err != nil { + // Skip files that cannot be read (e.g., due to permissions) + continue + } + + // Trim space and add to map + idInfo[entry.Name()] = strings.TrimSpace(string(content)) + } +} + +func newHTTPClient() *http.Client { + return &http.Client{ + Transport: &http.Transport{ + TLSHandshakeTimeout: retryDelay, + DisableKeepAlives: true, + MaxIdleConns: 1, + MaxConnsPerHost: 1, + IdleConnTimeout: 1 * time.Millisecond, + ResponseHeaderTimeout: retryDelay, + }, + Timeout: 30 * time.Second, + } +} + +func init() { + hostname, err := os.Hostname() + if err == nil { + initData["hostname"] = hostname + } + + if runtime.GOOS == "linux" { + initUtsname() + initCPUInfo() + initDMIInfo() + } + + go func() { + firstMessage := true + client := newHTTPClient() + + for data := range q { + if firstMessage { + for key, value := range initData { + data[key] = value + } + } + + jsonData, err := json.Marshal(data) + if err != nil { + continue + } + + retryCount := 0 + + for { + if hasWaitedTooLong() { + break + } + + // Attempt to send POST request. + err := sendPostRequest(client, jsonData) + client.CloseIdleConnections() + if err == nil { + // If successful, break the loop. + firstMessage = false + break + } + + // Create a new client if an error occurred. + client = newHTTPClient() + + retryCount++ + if retryCount >= maxRetries { + // If max retries exceeded, give up on this message. + break + } + + // Wait for a bit before retrying. + time.Sleep(retryDelay) + } + + pendingMessages.Done() + } + }() +} + +func sendPostRequest(client *http.Client, jsonData []byte) error { + // Create a new POST request with jsonData as body. + req, err := http.NewRequest("POST", receiverURL, bytes.NewBuffer(jsonData)) + if err != nil { + return err + } + req.Header.Set("Content-Type", "application/json") + + // Send the request. + resp, err := client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode >= 400 { + return fmt.Errorf("resp status %d %s", resp.StatusCode, resp.Status) + } + + return nil +} + +func charArrayToString(ca []int8) string { + var bs []byte + for _, c := range ca { + if c == 0 { + break + } + bs = append(bs, byte(c)) + } + return string(bs) +} + +func Send(msg string, args ...interface{}) { + // Initialize a map to hold the key-value pairs. + data := jsonObject{ + "session_id": sessionID, + "id": uuid.NewString(), + "msg": msg, + } + + // Iterate over the args to populate the map. + // Assume that args are provided in key-value pairs. + for i := 0; i < len(args); i += 2 { + key, ok := args[i].(string) + if !ok || i+1 >= len(args) { + glog.Errorf("invalid argument at position %d", i) + return + } + data[key] = args[i+1] + } + + // Send the JSON to the channel. + pendingMessages.Add(1) + q <- data +} + +func Wait() { + setWaitStarted() + pendingMessages.Wait() +} + +func setWaitStarted() { + waitStartMutex.Lock() + defer waitStartMutex.Unlock() + waitStarted = true + waitStartTime = time.Now() +} + +func hasWaitedTooLong() bool { + waitStartMutex.Lock() + defer waitStartMutex.Unlock() + return waitStarted && time.Since(waitStartTime) > 1*time.Minute +} diff --git a/third_party/cppcheck/addons/misra.py b/third_party/cppcheck/addons/misra.py index 13944b01d6..b245cb82e7 100755 --- a/third_party/cppcheck/addons/misra.py +++ b/third_party/cppcheck/addons/misra.py @@ -401,6 +401,20 @@ def isStdLibId(id_, standard='c99'): 'alignas', 'alignof', 'noreturn', 'static_assert' } +# See C specification C11 - Annex K, page 578 +FACILITES_OF_ANNEX_K = { + 'tmpfile_s', 'tmpnam_s', 'fopen_s', 'freopen_s', 'fprintf_s', 'fscanf_s', 'printf_s', 'scanf_s', + 'snprintf_s', 'sprintf_s', 'sscanf_s', 'vfprintf_s', 'vfscanf_s', 'vprintf_s', 'vscanf_s', + 'vsnprintf_s', 'vsprintf_s', 'vsscanf_s', 'gets_s', 'set_constraint_handler_s', 'abort_handler_s', + 'ignore_handler_s', 'getenv_s', 'bsearch_s', 'qsort_s', 'wctomb_s', 'mbstowcs_s', 'wcstombs_s', + 'memcpy_s', 'memmove_s', 'strcpy_s', 'strncpy_s', 'strcat_s', 'strncat_s', 'strtok_s', 'memset_s', + 'strerror_s', 'strerrorlen_s', 'strnlen_s', 'asctime_s', 'ctime_s', 'gmtime_s', 'localtime_s', + 'fwprintf_s', 'fwscanf_s', 'snwprintf_s', 'swprintf_s', 'swscanf_s', 'vfwprintf_s', 'vfwscanf_s', + 'vsnwprintf_s', 'vswprintf_s', 'vswscanf_s', 'vwprintf_s', 'vwscanf_s', 'wprintf_s', 'wscanf_s', + 'wcscpy_s', 'wcsncpy_s', 'wmemcpy_s', 'wmemmove_s', 'wcscat_s', 'wcsncat_s', 'wcstok_s', 'wcsnlen_s', + 'wcrtomb_s', 'mbsrtowcs_s', 'wcsrtombs_s' +} + def isKeyword(keyword, standard='c99'): kw_set = {} if standard == 'c89': @@ -1770,6 +1784,16 @@ def __init__(self, path, line_num, err_msg, other_locations = None): for loc in other_locations: self.locations.append(ErrorLocation(loc.file, loc.linenr)) +class ToyRuleResult: + def __init__(self, path, line_num, err_msg, other_locations = None): + self.path = path + self.line_number = line_num + self.error_message = f'{err_msg}' + self.locations = [ErrorLocation(path, line_num)] + if other_locations is not None: + for loc in other_locations: + self.locations.append(ErrorLocation(loc.file, loc.linenr)) + class MisraSettings(object): """Hold settings for misra.py script.""" @@ -1973,23 +1997,24 @@ def _save_ctu_summary_usage(self, dumpfile, cfg): def misra_1_4(self, cfg, rawTokens): for token in rawTokens: - if token.str in ('', ''): + if token.str in ('', '', '', ''): self.reportError(token, 1, 4) for token in cfg.tokenlist: if token.str in ('_Atomic', '_Noreturn', '_Generic', '_Thread_local', '_Alignas', '_Alignof', '__alignas_is_defined', '__alignof_is_defined'): self.reportError(token, 1, 4) if token.str.endswith('_s') and isFunctionCall(token.next): - # See C specification C11 - Annex K, page 578 - if token.str in ('tmpfile_s', 'tmpnam_s', 'fopen_s', 'freopen_s', 'fprintf_s', 'fscanf_s', 'printf_s', 'scanf_s', - 'snprintf_s', 'sprintf_s', 'sscanf_s', 'vfprintf_s', 'vfscanf_s', 'vprintf_s', 'vscanf_s', - 'vsnprintf_s', 'vsprintf_s', 'vsscanf_s', 'gets_s', 'set_constraint_handler_s', 'abort_handler_s', - 'ignore_handler_s', 'getenv_s', 'bsearch_s', 'qsort_s', 'wctomb_s', 'mbstowcs_s', 'wcstombs_s', - 'memcpy_s', 'memmove_s', 'strcpy_s', 'strncpy_s', 'strcat_s', 'strncat_s', 'strtok_s', 'memset_s', - 'strerror_s', 'strerrorlen_s', 'strnlen_s', 'asctime_s', 'ctime_s', 'gmtime_s', 'localtime_s', - 'fwprintf_s', 'fwscanf_s', 'snwprintf_s', 'swprintf_s', 'swscanf_s', 'vfwprintf_s', 'vfwscanf_s', - 'vsnwprintf_s', 'vswprintf_s', 'vswscanf_s', 'vwprintf_s', 'vwscanf_s', 'wprintf_s', 'wscanf_s', - 'wcscpy_s', 'wcsncpy_s', 'wmemcpy_s', 'wmemmove_s', 'wcscat_s', 'wcsncat_s', 'wcstok_s', 'wcsnlen_s', - 'wcrtomb_s', 'mbsrtowcs_s', 'wcsrtombs_s'): + if token.str in FACILITES_OF_ANNEX_K: + self.reportError(token, 1, 4) + + def misra_1_4_amd3(self, cfg, rawTokens): # rule 1.4 for MISRA:2023 + for token in rawTokens: + if token.str in ('', ''): + self.reportError(token, 1, 4) + for token in cfg.tokenlist: + if token.str in ('_Atomic', '_Thread_local'): + self.reportError(token, 1, 4) + if token.str.endswith('_s') and isFunctionCall(token.next): + if token.str in FACILITES_OF_ANNEX_K: self.reportError(token, 1, 4) def misra_2_3(self, dumpfile, typedefInfo): @@ -4774,6 +4799,11 @@ def misra_21_12(self, data): 'fetestexcept')): self.reportError(token, 21, 12) + def misra_21_12_amd3(self, data): + directive = findInclude(data.directives, '') + if directive: + self.reportError(directive, 21, 12) + def misra_21_14(self, data): # buffers used in strcpy/strlen/etc function calls string_buffers = [] @@ -5357,6 +5387,7 @@ def isInSameScope(directive1, directive2): # report error for unmatched #define for directive in defined_macros.values(): self.reportGJBError(directive, 1, 1, 6, gjb_type = '8114') + def gjb8114_1_1_7(self, data): def reportErrorFunc(directive): self.reportGJBError(directive, 1, 1, 7, gjb_type='8114') @@ -6621,6 +6652,12 @@ def rule_A18_0_3(self, cfg): if name and name == token.str: self.reportAUTOSARError(token, 18, 0, 3) + def toy_rule_2(self, data): + """Refer from func misra_15_1""" + for token in data.tokenlist: + if token.str == "goto": + self.reportToyRuleError(token, 2) + def get_verify_expected(self): """Return the list of expected violations in the verify test""" return self.verify_expected @@ -7067,6 +7104,23 @@ def reportAUTOSARError(self, location, num1, num2, num3, other_locations = None) self.violations[autosar_severity] = [] self.violations[autosar_severity].append('autosar' + "-" + errorId) + def reportToyRuleError(self, location, rule_num, other_locations = None): + if self.settings.verify: + self.verify_actual.append('%s:%d %d.%d.%d' % (location.file, location.linenr, rule_num)) + else: + errorId = f"Rule-{rule_num}" + toyrule_severity = 'Required' + this_violation = '{}-{}-{}-{}'.format(location.file, location.linenr, location.column, rule_num) + # If this is new violation then record it and show it. If not then + # skip it since it has already been displayed. + if not this_violation in self.existing_violations: + self.existing_violations.add(this_violation) + self.current_json_list.append(ToyRuleResult(location.file, location.linenr, errorId, other_locations)) + cppcheckdata.reportError(location, toyrule_severity, "", "toy", errorId) + if toyrule_severity not in self.violations: + self.violations[toyrule_severity] = [] + self.violations[toyrule_severity].append('toy' + "-" + errorId) + def loadRuleTexts(self, filename): num1 = 0 num2 = 0 @@ -7213,6 +7267,9 @@ def executeNaiveSystemsCheck(self, check_function, *args): def executeAUTOSARCheck(self, check_function, *args): check_function(*args) + def executeToyRuleCheck(self, check_function, *args): + check_function(*args) + def parseDump(self, dumpfile, check_rules, output_dir, create_dump_error=None): global _checkRule_2_4, _checkRule_2_5, _checkRule_5_7 def fillVerifyExpected(verify_expected, tok): @@ -7275,6 +7332,8 @@ def fillVerifyExpected(verify_expected, tok): scope.setIsBooleanEnumTrue() if "misra_c_2012/rule_1_4" in rules_list or check_rules == "all": self.executeCheck(104, self.misra_1_4, cfg, data.rawTokens) + if "misra_c_2012/rule_1_4_amd3" in rules_list or check_rules == "all": + self.executeCheck(104, self.misra_1_4_amd3, cfg, data.rawTokens) if "misra_c_2012/rule_2_3" in rules_list or check_rules == "all": self.executeCheck(203, self.misra_2_3, dumpfile, cfg.typedefInfo) if "misra_c_2012/rule_2_4" in rules_list or check_rules == "all": @@ -7540,6 +7599,8 @@ def fillVerifyExpected(verify_expected, tok): self.executeCheck(2111, self.misra_21_11, cfg) if "misra_c_2012/rule_21_12" in rules_list or check_rules == "all": self.executeCheck(2112, self.misra_21_12, cfg) + if "misra_c_2012/rule_21_12_amd3" in rules_list or check_rules == "all": + self.executeCheck(2112, self.misra_21_12_amd3, cfg) if "misra_c_2012/rule_21_14" in rules_list or check_rules == "all": self.executeCheck(2114, self.misra_21_14, cfg) if "misra_c_2012/rule_21_15" in rules_list or check_rules == "all": @@ -7719,6 +7780,9 @@ def fillVerifyExpected(verify_expected, tok): if "autosar/rule_A18_0_3" in rules_list or check_rules == "all": self.executeAUTOSARCheck(self.rule_A18_0_3, cfg) + if "toy_rules/rule_2" in rules_list or check_rules == "all": + self.executeToyRuleCheck(self.toy_rule_2, cfg) + def analyse_ctu_info(self, ctu_info_files): all_typedef_info = [] all_tagname_info = [] diff --git a/third_party/github.com/BurntSushi/toml/METADATA.json b/third_party/github.com/BurntSushi/toml/METADATA.json index 9224446c00..125cfbbdaa 100644 --- a/third_party/github.com/BurntSushi/toml/METADATA.json +++ b/third_party/github.com/BurntSushi/toml/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.4.1" } } \ No newline at end of file diff --git a/third_party/github.com/bmatcuk/doublestar.v4/METADATA.json b/third_party/github.com/bmatcuk/doublestar.v4/METADATA.json index 4e56b6b408..bc13cab1c7 100644 --- a/third_party/github.com/bmatcuk/doublestar.v4/METADATA.json +++ b/third_party/github.com/bmatcuk/doublestar.v4/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v4.0.2" } } diff --git a/third_party/github.com/davecgh/go-spew/METADATA.json b/third_party/github.com/davecgh/go-spew/METADATA.json index 1e5d587c6f..dbb9cc5880 100644 --- a/third_party/github.com/davecgh/go-spew/METADATA.json +++ b/third_party/github.com/davecgh/go-spew/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "ISC", "version": "v1.1.1" } } \ No newline at end of file diff --git a/third_party/github.com/go-enry/go-enry.v2/METADATA.json b/third_party/github.com/go-enry/go-enry.v2/METADATA.json index 026b3e4155..655799b9be 100644 --- a/third_party/github.com/go-enry/go-enry.v2/METADATA.json +++ b/third_party/github.com/go-enry/go-enry.v2/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "Apache-2.0", "version": "v2.7.2" } } diff --git a/third_party/github.com/go-enry/go-oniguruma/METADATA.json b/third_party/github.com/go-enry/go-oniguruma/METADATA.json index 52035fc4c0..8948204c46 100644 --- a/third_party/github.com/go-enry/go-oniguruma/METADATA.json +++ b/third_party/github.com/go-enry/go-oniguruma/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.2.1" } } diff --git a/third_party/github.com/golang/glog/METADATA.json b/third_party/github.com/golang/glog/METADATA.json index 3f4101ed7e..6ae8faff5c 100644 --- a/third_party/github.com/golang/glog/METADATA.json +++ b/third_party/github.com/golang/glog/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "Apache-2.0", "version": "v1.0.0" } } diff --git a/third_party/github.com/golang/protobuf/METADATA.json b/third_party/github.com/golang/protobuf/METADATA.json index 527764328e..a735d85862 100644 --- a/third_party/github.com/golang/protobuf/METADATA.json +++ b/third_party/github.com/golang/protobuf/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v1.5.2" } } diff --git a/third_party/github.com/google/go-cmp/METADATA.json b/third_party/github.com/google/go-cmp/METADATA.json index 9a001e9a46..5d4a4d392c 100644 --- a/third_party/github.com/google/go-cmp/METADATA.json +++ b/third_party/github.com/google/go-cmp/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.5.6" } } \ No newline at end of file diff --git a/third_party/github.com/google/shlex/METADATA.json b/third_party/github.com/google/shlex/METADATA.json index 0f1929acf2..3ed607ab2d 100644 --- a/third_party/github.com/google/shlex/METADATA.json +++ b/third_party/github.com/google/shlex/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "Apache-2.0", "version": "v0.0.0-20191202100458-e7afc7fbc510" } } diff --git a/third_party/github.com/google/uuid/METADATA.json b/third_party/github.com/google/uuid/METADATA.json index f7ea51821b..0d2bcfc26d 100644 --- a/third_party/github.com/google/uuid/METADATA.json +++ b/third_party/github.com/google/uuid/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v1.3.0" } } \ No newline at end of file diff --git a/third_party/github.com/gookit/color/METADATA.json b/third_party/github.com/gookit/color/METADATA.json index 4831a414ab..76b382e7d8 100644 --- a/third_party/github.com/gookit/color/METADATA.json +++ b/third_party/github.com/gookit/color/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.5.1" } } \ No newline at end of file diff --git a/third_party/github.com/hhatto/gocloc/METADATA.json b/third_party/github.com/hhatto/gocloc/METADATA.json index a889cf067e..4089130879 100644 --- a/third_party/github.com/hhatto/gocloc/METADATA.json +++ b/third_party/github.com/hhatto/gocloc/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.4.2" } } diff --git a/third_party/github.com/jessevdk/go-flags/METADATA.json b/third_party/github.com/jessevdk/go-flags/METADATA.json index 42773a1c99..4c724bb780 100644 --- a/third_party/github.com/jessevdk/go-flags/METADATA.json +++ b/third_party/github.com/jessevdk/go-flags/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v1.4.0" } } diff --git a/third_party/github.com/lib/pq/METADATA.json b/third_party/github.com/lib/pq/METADATA.json index 06af70ba68..ea6895da66 100644 --- a/third_party/github.com/lib/pq/METADATA.json +++ b/third_party/github.com/lib/pq/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.10.6" } } \ No newline at end of file diff --git a/third_party/github.com/libgit2/git2go.v33/METADATA.json b/third_party/github.com/libgit2/git2go.v33/METADATA.json index 1e7d7a8609..bcbd70f650 100644 --- a/third_party/github.com/libgit2/git2go.v33/METADATA.json +++ b/third_party/github.com/libgit2/git2go.v33/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v33.0.7" } } diff --git a/third_party/github.com/nbutton23/zxcvbn-go/METADATA.json b/third_party/github.com/nbutton23/zxcvbn-go/METADATA.json index 43e5a76217..0c5cd6ff59 100644 --- a/third_party/github.com/nbutton23/zxcvbn-go/METADATA.json +++ b/third_party/github.com/nbutton23/zxcvbn-go/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.0.0-20210217022336-fa2cb2858354" } } \ No newline at end of file diff --git a/third_party/github.com/onsi/ginkgo.v2/METADATA.json b/third_party/github.com/onsi/ginkgo.v2/METADATA.json index 7009348094..16fb9ac8c8 100644 --- a/third_party/github.com/onsi/ginkgo.v2/METADATA.json +++ b/third_party/github.com/onsi/ginkgo.v2/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v2.1.3" } } \ No newline at end of file diff --git a/third_party/github.com/onsi/gomega/METADATA.json b/third_party/github.com/onsi/gomega/METADATA.json index 44e9b99615..5eab1d8f67 100644 --- a/third_party/github.com/onsi/gomega/METADATA.json +++ b/third_party/github.com/onsi/gomega/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.18.1" } } \ No newline at end of file diff --git a/third_party/github.com/phodina/ProjectConverter/converter.py b/third_party/github.com/phodina/ProjectConverter/converter.py index 16668cad63..30299b5d21 100644 --- a/third_party/github.com/phodina/ProjectConverter/converter.py +++ b/third_party/github.com/phodina/ProjectConverter/converter.py @@ -49,16 +49,18 @@ def find_file(path, fileext): elif args.format == 'uvprojx': print('Looking for *.uvprojx file in ' + args.path) filename = find_file(args.path, '.uvprojx') + if not len(filename): + filename = find_file(args.path, '.uvproj') if len(filename): print('Found project file: ' + filename) - project = uvprojxproject.UVPROJXProject(args.path, filename) + project = uvprojxproject.UVPROJXProject(os.path.dirname(filename), filename) project.parseProject() project.displaySummary() cmakefile = cmake.CMake(project.getProject(), args.path) cmakefile.populateCMake() else: - print('No project *.uvprojx file found') + print('No project *.uvprojx or *.uvproj file found') else: print ('No format specified') else: diff --git a/third_party/github.com/phodina/ProjectConverter/uvprojxproject.py b/third_party/github.com/phodina/ProjectConverter/uvprojxproject.py index 5f09e29270..f1a4e54fb1 100644 --- a/third_party/github.com/phodina/ProjectConverter/uvprojxproject.py +++ b/third_party/github.com/phodina/ProjectConverter/uvprojxproject.py @@ -21,7 +21,7 @@ def __init__(self, path, xmlFile): def parseProject(self): """ Parses EWP project file for project settings """ - self.project['name'] = self.root.Targets.Target.TargetName + self.project['name'] = self.root.Targets.Target.TargetName.text.replace(" ", "-") self.project['chip'] = str(self.root.Targets.Target.TargetOption.TargetCommonOption.Device) self.project['incs'] = self.root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.IncludePath.text.split(';') self.project['mems'] = self.root.Targets.Target.TargetOption.TargetCommonOption.Cpu @@ -39,7 +39,9 @@ def parseProject(self): s = s.replace('/', '\\') elif os.path.sep == '/': s = s.replace('\\', '/') - self.project['srcs'].append(s.replace('..', self.path, 1)) + if not os.path.isabs(s): + s = os.path.join(self.path, s) + self.project['srcs'].append(s) for i in range(0, len(self.project['incs'])): s = str(self.project['incs'][i]) @@ -48,8 +50,9 @@ def parseProject(self): s = s.replace('/', '\\') elif os.path.sep == '/': s = s.replace('\\', '/') - - self.project['incs'][i] = s.replace('..', self.path, 1) + if not os.path.isabs(s): + s = os.path.join(self.path, s) + self.project['incs'][i] = s self.project['files'] = [] i = 0 diff --git a/third_party/github.com/pmezard/go-difflib/METADATA.json b/third_party/github.com/pmezard/go-difflib/METADATA.json index 2421d19ccf..c2d8495d23 100644 --- a/third_party/github.com/pmezard/go-difflib/METADATA.json +++ b/third_party/github.com/pmezard/go-difflib/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v1.0.0" } } \ No newline at end of file diff --git a/third_party/github.com/securego/gosec.v2/METADATA.json b/third_party/github.com/securego/gosec.v2/METADATA.json index bda71fd6af..8850fee4a0 100644 --- a/third_party/github.com/securego/gosec.v2/METADATA.json +++ b/third_party/github.com/securego/gosec.v2/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "Apache-2.0", "version": "v2.11.0" } } \ No newline at end of file diff --git a/third_party/github.com/spf13/afero/METADATA.json b/third_party/github.com/spf13/afero/METADATA.json index 63d54223e3..97bdcb4006 100644 --- a/third_party/github.com/spf13/afero/METADATA.json +++ b/third_party/github.com/spf13/afero/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "Apache-2.0", "version": "v1.2.2" } } \ No newline at end of file diff --git a/third_party/github.com/stretchr/objx/METADATA.json b/third_party/github.com/stretchr/objx/METADATA.json index 6def1a2210..3dfe550c42 100644 --- a/third_party/github.com/stretchr/objx/METADATA.json +++ b/third_party/github.com/stretchr/objx/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.1.0" } } \ No newline at end of file diff --git a/third_party/github.com/stretchr/testify/METADATA.json b/third_party/github.com/stretchr/testify/METADATA.json index 3dccacbe44..d3157992ad 100644 --- a/third_party/github.com/stretchr/testify/METADATA.json +++ b/third_party/github.com/stretchr/testify/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.7.2" } } \ No newline at end of file diff --git a/third_party/github.com/xo/terminfo/METADATA.json b/third_party/github.com/xo/terminfo/METADATA.json index d27d87addb..79c9c6646e 100644 --- a/third_party/github.com/xo/terminfo/METADATA.json +++ b/third_party/github.com/xo/terminfo/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.0.0-20210125001918-ca9a967f8778" } } \ No newline at end of file diff --git a/third_party/github.com/yuin/goldmark/METADATA.json b/third_party/github.com/yuin/goldmark/METADATA.json index 76d0ad3cef..3e2d8fad18 100644 --- a/third_party/github.com/yuin/goldmark/METADATA.json +++ b/third_party/github.com/yuin/goldmark/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v1.4.13" } } \ No newline at end of file diff --git a/third_party/golang.org/x/crypto/METADATA.json b/third_party/golang.org/x/crypto/METADATA.json index 49c3b78f48..303725a603 100644 --- a/third_party/golang.org/x/crypto/METADATA.json +++ b/third_party/golang.org/x/crypto/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.14.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/exp/METADATA.json b/third_party/golang.org/x/exp/METADATA.json index f8bb848486..6a90282b45 100644 --- a/third_party/golang.org/x/exp/METADATA.json +++ b/third_party/golang.org/x/exp/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.0.0-20220518171630-0b5c67f07fdf" } } \ No newline at end of file diff --git a/third_party/golang.org/x/exp/typeparams/METADATA.json b/third_party/golang.org/x/exp/typeparams/METADATA.json index 037747fed0..4228c60bde 100644 --- a/third_party/golang.org/x/exp/typeparams/METADATA.json +++ b/third_party/golang.org/x/exp/typeparams/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.0.0-20220218215828-6cf2b201936e" } } \ No newline at end of file diff --git a/third_party/golang.org/x/mod/METADATA.json b/third_party/golang.org/x/mod/METADATA.json index 608e361855..3453cf006b 100644 --- a/third_party/golang.org/x/mod/METADATA.json +++ b/third_party/golang.org/x/mod/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.13.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/net/METADATA.json b/third_party/golang.org/x/net/METADATA.json index 8a3942cc2c..0568e9a616 100644 --- a/third_party/golang.org/x/net/METADATA.json +++ b/third_party/golang.org/x/net/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.17.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/sync/METADATA.json b/third_party/golang.org/x/sync/METADATA.json index db1be3ad0c..4b22adb683 100644 --- a/third_party/golang.org/x/sync/METADATA.json +++ b/third_party/golang.org/x/sync/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.4.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/sys/METADATA.json b/third_party/golang.org/x/sys/METADATA.json index 608e361855..3453cf006b 100644 --- a/third_party/golang.org/x/sys/METADATA.json +++ b/third_party/golang.org/x/sys/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.13.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/term/METADATA.json b/third_party/golang.org/x/term/METADATA.json index 608e361855..3453cf006b 100644 --- a/third_party/golang.org/x/term/METADATA.json +++ b/third_party/golang.org/x/term/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.13.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/text/METADATA.json b/third_party/golang.org/x/text/METADATA.json index 608e361855..3453cf006b 100644 --- a/third_party/golang.org/x/text/METADATA.json +++ b/third_party/golang.org/x/text/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.13.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/tools/METADATA.json b/third_party/golang.org/x/tools/METADATA.json index 49c3b78f48..303725a603 100644 --- a/third_party/golang.org/x/tools/METADATA.json +++ b/third_party/golang.org/x/tools/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.14.0" } } \ No newline at end of file diff --git a/third_party/golang.org/x/xerrors/METADATA.json b/third_party/golang.org/x/xerrors/METADATA.json index e8b1827351..469a7d9066 100644 --- a/third_party/golang.org/x/xerrors/METADATA.json +++ b/third_party/golang.org/x/xerrors/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v0.0.0-20200804184101-5ec99f83aff1" } } \ No newline at end of file diff --git a/third_party/google.golang.org/protobuf/METADATA.json b/third_party/google.golang.org/protobuf/METADATA.json index 351af05015..78b8fb8042 100644 --- a/third_party/google.golang.org/protobuf/METADATA.json +++ b/third_party/google.golang.org/protobuf/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-3-Clause", "version": "v1.27.1" } } diff --git a/third_party/gopkg.in/check.v1/METADATA.json b/third_party/gopkg.in/check.v1/METADATA.json index 567e4d8926..497e899bb2 100644 --- a/third_party/gopkg.in/check.v1/METADATA.json +++ b/third_party/gopkg.in/check.v1/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "BSD-2-Clause", "version": "v1.0.0-20190902080502-41f04d3bba15" } } \ No newline at end of file diff --git a/third_party/gopkg.in/yaml.v2/METADATA.json b/third_party/gopkg.in/yaml.v2/METADATA.json index 52a6ce90cf..bcc44eb6bc 100644 --- a/third_party/gopkg.in/yaml.v2/METADATA.json +++ b/third_party/gopkg.in/yaml.v2/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT and Apache-2.0", "version": "v2.4.0" } } \ No newline at end of file diff --git a/third_party/gopkg.in/yaml.v3/METADATA.json b/third_party/gopkg.in/yaml.v3/METADATA.json index 94a2c9c695..127a6dea41 100644 --- a/third_party/gopkg.in/yaml.v3/METADATA.json +++ b/third_party/gopkg.in/yaml.v3/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT and Apache-2.0", "version": "v3.0.1" } } \ No newline at end of file diff --git a/third_party/honnef.co/go/tools/METADATA.json b/third_party/honnef.co/go/tools/METADATA.json index c0c1e140fc..8d3fbcba2b 100644 --- a/third_party/honnef.co/go/tools/METADATA.json +++ b/third_party/honnef.co/go/tools/METADATA.json @@ -1,5 +1,6 @@ { "third_party": { + "license": "MIT", "version": "v0.3.2" } } \ No newline at end of file diff --git a/third_party/llvm-project/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/third_party/llvm-project/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index de0b158f3a..84886b93d2 100644 --- a/third_party/llvm-project/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/third_party/llvm-project/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -8,7 +8,6 @@ add_clang_library(clangStaticAnalyzerCheckers AnalyzerStatsChecker.cpp ArrayBoundChecker.cpp ArrayBoundCheckerV2.cpp - autosar-A0_4_4-MathErrorChecker.cpp BasicObjCFoundationChecks.cpp BlockInCriticalSectionChecker.cpp BoolAssignmentChecker.cpp @@ -29,10 +28,6 @@ add_clang_library(clangStaticAnalyzerCheckers CloneChecker.cpp ContainerModeling.cpp ConversionChecker.cpp - cwe-120-CStringChecker.cpp - cwe-121-ArrayBoundCheckerV2.cpp - cwe-124-127-BufferUnderAccessChecker.cpp - cwe-126-BuferOverAccessChecker.cpp CXXSelfAssignmentChecker.cpp DeadStoresChecker.cpp DebugCheckers.cpp @@ -53,10 +48,6 @@ add_clang_library(clangStaticAnalyzerCheckers FuchsiaHandleChecker.cpp GCDAntipatternChecker.cpp GenericTaintChecker.cpp - misra-cxx-2008-R-0_1_2-Unreachable.cpp - misra-cxx-2008-R-0_1_6-DUDataflow.cpp - misra-cxx-2008-R-5_2_7-pointerCast.cpp - misra-cxx-2008-R-15_5_2-ExceptionThrow.cpp GTestChecker.cpp IdenticalExprChecker.cpp InnerPointerChecker.cpp @@ -76,21 +67,6 @@ add_clang_library(clangStaticAnalyzerCheckers MismatchedIteratorChecker.cpp MmapWriteExecChecker.cpp MIGChecker.cpp - misrac-2012-11_5-VoidToObjectPtr.cpp - misrac-2012-12_2-ShiftOp.cpp - misrac-2012-13_2-VarUnsequencedAccess.cpp - misrac-2012-18_2-PointerSub.cpp - misrac-2012-18_3-PointerComp.cpp - misrac-2012-21_13-CtypeChecker.cpp - misrac-2012-21_14-MemcmpChecker.cpp - misrac-2012-21_19-ConstReturnPointerChecker.cpp - misrac-2012-21_20-DeprecatedResourceChecker.cpp - misrac-2012-22_3-OpenFileChecker.cpp - misrac-2012-22_4-WriteReadOnlyChecker.cpp - misrac-2012-22_5-FileDereferenceChecker.cpp - misrac-2012-22_6-UseClosedFileChecker.cpp - misrac-2012-22_7-EOFComparisonChecker.cpp - misrac-2012-d4_14-TaintCheck.cpp MoveChecker.cpp MPI-Checker/MPIBugReporter.cpp MPI-Checker/MPIChecker.cpp diff --git a/toy_rules/rule_1/libtooling/BUILD b/toy_rules/rule_1/libtooling/BUILD index ff147da7e4..b758b3ae2c 100644 --- a/toy_rules/rule_1/libtooling/BUILD +++ b/toy_rules/rule_1/libtooling/BUILD @@ -1,41 +1,15 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_library( - name = "checker", - srcs = ["checker.cc"], - hdrs = ["checker.h"], - deps = [ - "//analyzer/proto:analyzer_cc_proto", - "//misra:proto_util", - "//misra/libtooling_utils", - "@com_github_google_glog//:glog", - "@com_google_absl//absl/strings", - "@llvm-project//clang:tooling", - ], -) - cc_library( name = "rule_1_lib", - srcs = ["rule_1.cc"], - hdrs = ["lib.h"], + srcs = ["checker.cc"], visibility = ["//visibility:public"], - deps = [ - ":checker", - "//libtooling_includes:cmd_options", - "//misra:proto_util", - "//misra/libtooling_utils", - "//podman_image/bigmain:suffix_rule", - "@com_github_google_glog//:glog", - "@llvm-project//clang:tooling", - ], + deps = ["//sdk/checker"], alwayslink = True, ) cc_binary( name = "rule_1", - srcs = ["main.cc"], deps = [ ":rule_1_lib", - "//libtooling_includes:cmd_options", + "//podman_image/bigmain", ], ) diff --git a/toy_rules/rule_1/libtooling/checker.cc b/toy_rules/rule_1/libtooling/checker.cc index 4f7c32482c..7204778fc4 100644 --- a/toy_rules/rule_1/libtooling/checker.cc +++ b/toy_rules/rule_1/libtooling/checker.cc @@ -16,55 +16,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "toy_rules/rule_1/libtooling/checker.h" +#include -#include +#include "sdk/checker/define_expr_checker.h" -#include "absl/strings/str_format.h" -#include "misra/libtooling_utils/libtooling_utils.h" - -using namespace misra::proto_util; using namespace clang::ast_matchers; -using analyzer::proto::ResultsList; -using std::string; - -namespace toy_rules { -namespace rule_1 { -namespace libtooling { - -class Callback : public MatchFinder::MatchCallback { - public: - void Init(ResultsList* results_list, MatchFinder* finder) { - results_list_ = results_list; - finder->addMatcher( - implicitCastExpr(hasSourceExpression(expr(gnuNullExpr())), - hasImplicitDestinationType(isInteger()), - unless(isExpansionInSystemHeader())) - .bind("cast"), - this); - } - - void run(const MatchFinder::MatchResult& result) override { - const Expr* expr = result.Nodes.getNodeAs("cast"); - string error_message = "NULL不得用作整型值"; - string path = - misra::libtooling_utils::GetFilename(expr, result.SourceManager); - int line = misra::libtooling_utils::GetLine(expr, result.SourceManager); - analyzer::proto::Result* pb_result = - AddResultToResultsList(results_list_, path, line, error_message); - } - - private: - ResultsList* results_list_; -}; +namespace { -void Checker::Init(ResultsList* result_list) { - results_list_ = result_list; - callback_ = new Callback; - callback_->Init(results_list_, &finder_); -} +sdk::checker::DefineExprChecker _( + "toy_rules/rule_4", "NULL不得用作整型值", + implicitCastExpr(hasSourceExpression(expr(gnuNullExpr())), + hasImplicitDestinationType(isInteger()), + unless(isExpansionInSystemHeader())) + .bind("cast"), + "cast"); -} // namespace libtooling -} // namespace rule_1 -} // namespace toy_rules +} // namespace diff --git a/toy_rules/rule_1/libtooling/rule_1.cc b/toy_rules/rule_1/libtooling/rule_1.cc deleted file mode 100644 index 7c46c3a323..0000000000 --- a/toy_rules/rule_1/libtooling/rule_1.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* -NaiveSystems Analyze - A tool for static code analysis -Copyright (C) 2023 Naive Systems Ltd. - -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 3 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, see . -*/ - -#include -#include -#include - -#include "absl/strings/match.h" -#include "misra/libtooling_utils/libtooling_utils.h" -#include "misra/proto_util.h" -#include "podman_image/bigmain/suffix_rule.h" -#include "toy_rules/rule_1/libtooling/checker.h" -#include "toy_rules/rule_1/libtooling/lib.h" - -using namespace clang::tooling; -using namespace llvm; - -extern cl::OptionCategory ns_libtooling_checker; -extern cl::opt results_path; - -namespace toy_rules { -namespace rule_1 { -namespace libtooling { - -int rule_1(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - gflags::AllowCommandLineReparsing(); - int gflag_argc = argc; - int libtooling_argc = argc; - misra::libtooling_utils::SplitArg(&gflag_argc, &libtooling_argc, argc, argv); - const char** const_argv = const_cast(argv); - auto expected_parser = CommonOptionsParser::create( - libtooling_argc, &const_argv[argc - libtooling_argc], - ns_libtooling_checker); - gflags::ParseCommandLineFlags(&gflag_argc, &argv, false); - if (!expected_parser) { - errs() << expected_parser.takeError(); - return 1; - } - CommonOptionsParser& options_parser = expected_parser.get(); - ClangTool tool(options_parser.getCompilations(), - options_parser.getSourcePathList()); - analyzer::proto::ResultsList all_results; - - toy_rules::rule_1::libtooling::Checker checker; - checker.Init(&all_results); - int status = - tool.run(newFrontendActionFactory(checker.GetMatchFinder()).get()); - LOG(INFO) << "libtooling status: " << status; - if (misra::proto_util::GenerateProtoFile(all_results, results_path).ok()) { - LOG(INFO) << "rule 1 check done"; - } - return 0; -} - -} // namespace libtooling -} // namespace rule_1 -} // namespace toy_rules - -namespace { - -podman_image::bigmain::SuffixRule _("toy_rules/rule_1", - toy_rules::rule_1::libtooling::rule_1); - -} // namespace diff --git a/misra_cpp_2008/rule_4_10_2/libtooling/lib.h b/toy_rules/rule_1/rule_1_test.go similarity index 62% rename from misra_cpp_2008/rule_4_10_2/libtooling/lib.h rename to toy_rules/rule_1/rule_1_test.go index 0a6828d801..aa111c74c1 100644 --- a/misra_cpp_2008/rule_4_10_2/libtooling/lib.h +++ b/toy_rules/rule_1/rule_1_test.go @@ -16,17 +16,21 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef ANALYZER_MISRA_CPP_2008_RULE_4_10_2_LIBTOOLING_LIB_H_ -#define ANALYZER_MISRA_CPP_2008_RULE_4_10_2_LIBTOOLING_LIB_H_ +package rule_1 -namespace misra_cpp_2008 { -namespace rule_4_10_2 { -namespace libtooling { +import ( + "testing" -int rule_4_10_2(int argc, char** argv); + "naive.systems/analyzer/cruleslib/testlib" + "naive.systems/analyzer/sdk/testcase" +) +func TestBad0001(t *testing.T) { + tc := testcase.NewWithSystemHeader(t, "_bad0001") + tc.ExpectOK(testlib.ToTestResult(Analyze(tc.Srcdir, tc.Options))) } -} // namespace rule_4_10_2 -} // namespace misra_cpp_2008 -#endif +func TestGood0001(t *testing.T) { + tc := testcase.NewWithSystemHeader(t, "_good0001") + tc.ExpectOK(testlib.ToTestResult(Analyze(tc.Srcdir, tc.Options))) +} diff --git a/toy_rules/rule_2/_bad0001/Makefile b/toy_rules/rule_2/_bad0001/Makefile new file mode 100644 index 0000000000..d2888a09c4 --- /dev/null +++ b/toy_rules/rule_2/_bad0001/Makefile @@ -0,0 +1,2 @@ +all: + clang -c *.c diff --git a/toy_rules/rule_2/_bad0001/bad.c b/toy_rules/rule_2/_bad0001/bad.c new file mode 100644 index 0000000000..7cfee703b4 --- /dev/null +++ b/toy_rules/rule_2/_bad0001/bad.c @@ -0,0 +1,6 @@ +void test ( void ) +{ + goto label1; +label1: + return; +} diff --git a/toy_rules/rule_2/_bad0001/expected.textproto b/toy_rules/rule_2/_bad0001/expected.textproto new file mode 100644 index 0000000000..b5803f5cb9 --- /dev/null +++ b/toy_rules/rule_2/_bad0001/expected.textproto @@ -0,0 +1,5 @@ +results { + path:"bad.c" + line_number:3 + error_message:"不应使用goto语句" +} diff --git a/toy_rules/rule_1/libtooling/main.cc b/toy_rules/rule_2/rule_2.go similarity index 57% rename from toy_rules/rule_1/libtooling/main.cc rename to toy_rules/rule_2/rule_2.go index 36c0c3e46c..86c3a69025 100644 --- a/toy_rules/rule_1/libtooling/main.cc +++ b/toy_rules/rule_2/rule_2.go @@ -16,9 +16,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "libtooling_includes/cmd_options.h" -#include "toy_rules/rule_1/libtooling/lib.h" +package rule_2 -int main(int argc, char** argv) { - return toy_rules::rule_1::libtooling::rule_1(argc, argv); +import ( + pb "naive.systems/analyzer/analyzer/proto" + "naive.systems/analyzer/cruleslib/options" + "naive.systems/analyzer/cruleslib/runner" + "naive.systems/analyzer/misra/checker_integration" +) + +func Analyze(srcdir string, opts *options.CheckOptions) (*pb.ResultsList, error) { + results, err := runner.RunCppcheck(srcdir, "toy_rules/rule_2", checker_integration.Cppcheck_STU, opts) + if err != nil { + return nil, err + } + for _, r := range results.Results { + r.ErrorMessage = "不应使用goto语句" + } + return results, nil } diff --git a/misra_cpp_2008/rule_4_10_1/libtooling/realmain.cc b/toy_rules/rule_2/rule_2_test.go similarity index 72% rename from misra_cpp_2008/rule_4_10_1/libtooling/realmain.cc rename to toy_rules/rule_2/rule_2_test.go index f225ea1514..2c095699e4 100644 --- a/misra_cpp_2008/rule_4_10_1/libtooling/realmain.cc +++ b/toy_rules/rule_2/rule_2_test.go @@ -16,9 +16,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "libtooling_includes/cmd_options.h" -#include "misra_cpp_2008/rule_4_10_1/libtooling/lib.h" +package rule_2 -int main(int argc, char** argv) { - return misra_cpp_2008::rule_4_10_1::libtooling::rule_4_10_1(argc, argv); +import ( + "testing" + + "naive.systems/analyzer/cruleslib/testlib" + "naive.systems/analyzer/sdk/testcase" +) + +func TestBad0001(t *testing.T) { + tc := testcase.NewWithSystemHeader(t, "_bad0001") + tc.ExpectOK(testlib.ToTestResult(Analyze(tc.Srcdir, tc.Options))) }