From 88537e7f40bcae622f8975537fc55fe2997c3a10 Mon Sep 17 00:00:00 2001
From: guwirth
Date: Sun, 5 Sep 2021 17:44:06 +0200
Subject: [PATCH] align messages with Visual Studio 2019 version 16.11
(compiler version 19.29.30100.0) - add new compiler messages for
sonar.cxx.vc.reportPaths sensor - add a Visual Studio project for
vc_createrules.py - close #2247
---
.../src/main/resources/compiler-vc.xml | 152 +++++++++++++++++-
.../vc/CxxCompilerVcRuleRepositoryTest.java | 2 +-
cxx-sensors/src/tools/vc_createrules.py | 9 +-
cxx-sensors/src/tools/vc_createrules.pyproj | 29 ++++
cxx-sensors/src/tools/vc_createrules.sln | 23 +++
5 files changed, 209 insertions(+), 6 deletions(-)
create mode 100644 cxx-sensors/src/tools/vc_createrules.pyproj
create mode 100644 cxx-sensors/src/tools/vc_createrules.sln
diff --git a/cxx-sensors/src/main/resources/compiler-vc.xml b/cxx-sensors/src/main/resources/compiler-vc.xml
index 4e7844e30c..1aa92f9767 100644
--- a/cxx-sensors/src/main/resources/compiler-vc.xml
+++ b/cxx-sensors/src/main/resources/compiler-vc.xml
@@ -3200,7 +3200,7 @@ Under strict ANSI compatibility (C4407
]]>
@@ -4271,6 +4271,17 @@ Under strict ANSI compatibility (C4596]]>
INFO
+
+
+ C4597
+ C4597: undefined behavior: offsetof applied to a member of a virtual base
+
+ Using offsetof(T, m)
where m
refers to a static data member or a member function results in C4597.
+Microsoft Documentation
+C4597
]]>
+
+ INFO
C4600
@@ -5052,6 +5063,17 @@ Under strict ANSI compatibility (C4694]]>
INFO
+
+
+ C4698
+ C4698: 'feature' is for evaluation purposes only and is subject to change or removal in future updates
+
+ WinRT APIs that are released for experimentation and feedback are decorated with the Windows.Foundation.Metadata.ExperimentalAttribute
attribute. In Visual Studio 2017 version 15.3, the compiler produces warning C4698 for this attribute. A few APIs in previous versions of the Windows SDK have already been decorated with the attribute, and calls to these APIs now trigger this compiler warning. Newer Windows SDKs have the attribute removed from all shipped types. If you're using an older SDK, you'll need to suppress these warnings for all calls to shipped types.
+Microsoft Documentation
+C4698
]]>
+
+ INFO
C4700
@@ -5434,6 +5456,17 @@ Under strict ANSI compatibility (C4764]]>
INFO
+
+
+ C4768
+ C4768: __declspec attributes before linkage specification are ignored
+
+ The compiler warns if __declspec(...)
is applied before the extern "C"
linkage specification. Previously, the compiler would ignore the attribute, which could have runtime implications.
+Microsoft Documentation
+C4768
]]>
+
+ INFO
C4772
@@ -5709,6 +5742,17 @@ Under strict ANSI compatibility (C4829]]>
INFO
+
+
+ C4834
+ C4834: discarding return value of function with 'nodiscard' attribute
+
+ Starting in the C++17 Standard, the [[nodiscard]]
attribute specifies that a function's return value isn't intended to be discarded. If a caller discards the return value, the compiler generates warning C4834.
+Microsoft Documentation
+C4834
]]>
+
+ INFO
C4835
@@ -5753,6 +5797,28 @@ Under strict ANSI compatibility (C4840]]>
INFO
+
+
+ C4841
+ C4841: non-standard extension used: compound member designator used in offsetof
+
+ If you use offsetof(T, m)
, where m
is a compound member designator, the compiler generates a warning when you compile with the /Wall
option.
+Microsoft Documentation
+C4841
]]>
+
+ INFO
+
+
+ C4843
+ C4843: 'type1': An exception handler of reference to array or function type is unreachable, use 'type2' instead
+
+ Handlers of reference to array or function type are never a match for any exception object. Starting in Visual Studio 2017 version 15.5, the compiler honors this rule and raises a level 4 warning. It also no longer matches a handler of char*
or wchar_t*
to a string literal when /Zc:strictStrings
is used.
+Microsoft Documentation
+C4843
]]>
+
+ INFO
C4866
@@ -6326,12 +6392,23 @@ Under strict ANSI compatibility (/permissive-
.
+Microsoft Documentation
+C5037
]]>
+
+ INFO
+
C5038
C5038: data member 'member1' will be initialized after data member 'member2'
Class members are initialized in the order they're declared, not the order they appear in initializer lists. This warning indicates the order of initialization isn't the same as the declaration order of data members or base classes. This order can lead to undefined runtime behavior, if the initialization of one member in the list depends on the initialization of a member that's declared later.
+Class members get initialized in the order they're declared, not the order they appear in initializer lists. The compiler warns when the initialization order isn't the same as the declaration order of data members or base classes. The order can lead to undefined runtime behavior: for example, if the initialization of one member in the list depends on the initialization of a member that's declared later.
Microsoft Documentation
C5038
]]>
@@ -6358,6 +6435,17 @@ Under strict ANSI compatibility (C5046]]>
INFO
+
+
+ C5050
+ C5050: Possible incompatible environment while importing module 'module_name'
+
+ The compiler raises C5050 whenever the command-line options for modules aren't consistent between the module creation and module consumption sides.
+Microsoft Documentation
+C5050
]]>
+
+ INFO
C5105
@@ -6380,6 +6468,39 @@ Under strict ANSI compatibility (C5208]]>
INFO
+
+
+ C5243
+ C5243: 'type': using incomplete class 'class-name' can cause ODR violation due to ABI limitation
+
+ The Microsoft C++ ABI in Visual Studio 2019 and earlier versions uses more than one kind of pointer-to-member type. These types have different sizes that depend on the inheritance model used by the class. The C++ standard allows you to declare a pointer-to-member of an incomplete class type. If you declare a variable of pointer-to-member type for an incomplete class, the compiler must use the most general representation. It can lead to a one definition rule, or ODR violation, since the compiler may use a smaller, more specific representation for this pointer-to-member type in other translation units where the complete class type is available.
+Microsoft Documentation
+C5243
]]>
+
+ INFO
+
+
+ C5247
+ C5247: section 'section-name' is reserved for C++ dynamic initialization
+
+ The Microsoft C++ compiler uses reserved section names for internal implementation of features such as C++ dynamic initialization. If your code creates a section with the same name as a reserved section, such as .CRT$XCU
, it interferes with the compiler. It may prevent other dynamic initialization and cause undefined behavior.
+Microsoft Documentation
+C5247
]]>
+
+ INFO
+
+
+ C5248
+ C5248: section 'section-name' is reserved for C++ dynamic initialization
+
+ The Microsoft C++ compiler uses reserved section names for internal implementation of features such as C++ dynamic initialization. If your code inserts a variable in a reserved section, such as .CRT$XCU
, it interferes with the compiler. Your variable isn't considered a C++ dynamic initializer. Also, its relative initialization order compared to compiler generated dynamic initializers isn't specified.
+Microsoft Documentation
+C5248
]]>
+
+ INFO
C6001
@@ -7857,6 +7978,19 @@ Under strict ANSI compatibility (C6389]]>
+
+ CRITICAL
+ LINEAR
+ 5min
+
C6400
C6400: Using <function name> to perform a case-insensitive compare to constant string <string name>
@@ -8696,7 +8830,7 @@ Deleting such a pointer may lead to immediate memory corruption due to double de
C26409: Avoid calling new and delete explicitly, use std::make_unique<T> instead (r.11)
Even if code is clean of calls tomalloc()
and free()
, we still suggest that you consider better options than explicit use of operators new
and delete
.
+Even if code is clean of calls to malloc
and free
, we still suggest that you consider better options than explicit use of operators new
and delete
.
Microsoft Documentation
C26409
]]>
@@ -9155,6 +9289,18 @@ C4293 is a similar check in the Microsoft C++ compiler.
core-guideline
INFO
+
+
+ C26457
+ C26457: Never cast to (void) to ignore a [[nodiscard]] return value
+
+ Excerpt from the C++ Core Guideline for this warning:
+Microsoft Documentation
+C26457
]]>
+
+ core-guideline
+ INFO
C26460
diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/compiler/vc/CxxCompilerVcRuleRepositoryTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/compiler/vc/CxxCompilerVcRuleRepositoryTest.java
index 06b556eb07..6feb1710ea 100644
--- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/compiler/vc/CxxCompilerVcRuleRepositoryTest.java
+++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/compiler/vc/CxxCompilerVcRuleRepositoryTest.java
@@ -38,7 +38,7 @@ public void createVcRulesTest() {
def.define(context);
RulesDefinition.Repository repo = context.repository(CxxCompilerVcRuleRepository.KEY);
- assertThat(repo.rules()).hasSize(947);
+ assertThat(repo.rules()).hasSize(960);
}
}
diff --git a/cxx-sensors/src/tools/vc_createrules.py b/cxx-sensors/src/tools/vc_createrules.py
index f67e32c2e7..53188cf525 100644
--- a/cxx-sensors/src/tools/vc_createrules.py
+++ b/cxx-sensors/src/tools/vc_createrules.py
@@ -26,6 +26,11 @@
# pip install beautifulsoup4
# pip install selenium-requests
+# pages contains JavaScript: script is using Firefox to create HTML pages
+# you have to download and install geckodriver
+# from https://github.com/mozilla/geckodriver/releases
+# to C:\Program Files\geckodriver
+
import re
import sys
from bs4 import BeautifulSoup
@@ -355,10 +360,10 @@ def add_template_rules(rules):
Add template rule(s) to XML.
"""
rule_key = 'CustomRuleTemplate'
- rule_name = 'Template for custom Custom rules'
+ rule_name = 'Rule template for Visual Studio custom rules'
rule_severity = 'MAJOR'
# pylint: disable=line-too-long
- rule_description = """Follow these steps to make your custom Custom rules available in SonarQube:
+ rule_description = """Follow these steps to make your custom rules available in SonarQube:
- Create a new rule in SonarQube by "copying" this rule template and specify the
CheckId
of your custom rule, a title, a description, and a default severity.
diff --git a/cxx-sensors/src/tools/vc_createrules.pyproj b/cxx-sensors/src/tools/vc_createrules.pyproj
new file mode 100644
index 0000000000..ee599f7590
--- /dev/null
+++ b/cxx-sensors/src/tools/vc_createrules.pyproj
@@ -0,0 +1,29 @@
+
+
+
+ Debug
+ 2.0
+ {f4a3e4b0-40b1-4c37-82c8-a7c5e40c8930}
+
+ vc_createrules.py
+
+ .
+ .
+ {888888a0-9f3d-457c-b088-3a5042f75d52}
+ Standard Python launcher
+ Global|PythonCore|3.7
+
+
+
+
+ 10.0
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cxx-sensors/src/tools/vc_createrules.sln b/cxx-sensors/src/tools/vc_createrules.sln
new file mode 100644
index 0000000000..cde538fe3c
--- /dev/null
+++ b/cxx-sensors/src/tools/vc_createrules.sln
@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31313.79
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "vc_createrules", "vc_createrules.pyproj", "{F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F4A3E4B0-40B1-4C37-82C8-A7C5E40C8930}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F2AFAAF8-13A0-48E6-928C-53E41986A107}
+ EndGlobalSection
+EndGlobal