From 58b03044f98c1d0c859185500b09859021de0338 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 11:12:12 -0400 Subject: [PATCH 1/7] clang formatting changes --- StdAfx.h | 2 +- UI/Controls/SortList/ContentsTableListCtrl.cpp | 2 +- UI/Controls/SortList/SingleMAPIPropListCtrl.cpp | 2 +- UI/Controls/SortList/SortHeader.cpp | 2 +- UI/Controls/SortList/SortListCtrl.cpp | 2 +- UI/Controls/StyleTree/StyleTreeCtrl.cpp | 2 +- core/mapi/mapiFile.cpp | 4 ++-- core/mapi/mapiFunctions.h | 2 +- mapistub | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/StdAfx.h b/StdAfx.h index 08df68b7a..417dc20da 100644 --- a/StdAfx.h +++ b/StdAfx.h @@ -41,7 +41,7 @@ // A bug in annotations in shobjidl.h forces us to disable 6387 to include afxwin.h #pragma warning(push) #pragma warning( \ - disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y + disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y #include // MFC core and standard components #pragma warning(pop) #include // MFC support for Windows Common Controls diff --git a/UI/Controls/SortList/ContentsTableListCtrl.cpp b/UI/Controls/SortList/ContentsTableListCtrl.cpp index 07351b09c..c316c76ab 100644 --- a/UI/Controls/SortList/ContentsTableListCtrl.cpp +++ b/UI/Controls/SortList/ContentsTableListCtrl.cpp @@ -60,7 +60,7 @@ namespace controls::sortlistctrl BEGIN_MESSAGE_MAP(CContentsTableListCtrl, CSortListCtrl) #pragma warning(push) #pragma warning( \ - disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time + disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemChanged) #pragma warning(pop) ON_WM_KEYDOWN() diff --git a/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp b/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp index 3f95a435c..1a2f21f51 100644 --- a/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp +++ b/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp @@ -98,7 +98,7 @@ namespace controls::sortlistctrl BEGIN_MESSAGE_MAP(CSingleMAPIPropListCtrl, CSortListCtrl) #pragma warning(push) #pragma warning( \ - disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time + disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk) #pragma warning(pop) ON_WM_KEYDOWN() diff --git a/UI/Controls/SortList/SortHeader.cpp b/UI/Controls/SortList/SortHeader.cpp index 308549b1c..d74207718 100644 --- a/UI/Controls/SortList/SortHeader.cpp +++ b/UI/Controls/SortList/SortHeader.cpp @@ -16,7 +16,7 @@ namespace controls::sortlistctrl ON_MESSAGE(WM_MFCMAPI_SAVECOLUMNORDERHEADER, msgOnSaveColumnOrder) #pragma warning(push) #pragma warning( \ - disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time + disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) #pragma warning(pop) END_MESSAGE_MAP() diff --git a/UI/Controls/SortList/SortListCtrl.cpp b/UI/Controls/SortList/SortListCtrl.cpp index e5b37ef1b..aa4e8e3eb 100644 --- a/UI/Controls/SortList/SortListCtrl.cpp +++ b/UI/Controls/SortList/SortListCtrl.cpp @@ -49,7 +49,7 @@ namespace controls::sortlistctrl ON_WM_DRAWITEM() #pragma warning(push) #pragma warning( \ - disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time + disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time ON_NOTIFY_REFLECT(LVN_DELETEALLITEMS, OnDeleteAllItems) ON_NOTIFY_REFLECT(LVN_DELETEITEM, OnDeleteItem) ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) diff --git a/UI/Controls/StyleTree/StyleTreeCtrl.cpp b/UI/Controls/StyleTree/StyleTreeCtrl.cpp index ca802046e..1b8d8d122 100644 --- a/UI/Controls/StyleTree/StyleTreeCtrl.cpp +++ b/UI/Controls/StyleTree/StyleTreeCtrl.cpp @@ -24,7 +24,7 @@ namespace controls BEGIN_MESSAGE_MAP(StyleTreeCtrl, CTreeCtrl) #pragma warning(push) #pragma warning( \ - disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time + disable : 26454) // Warning C26454 Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) ON_NOTIFY_REFLECT(NM_RCLICK, OnRightClick) ON_NOTIFY_REFLECT(TVN_GETDISPINFO, OnGetDispInfo) diff --git a/core/mapi/mapiFile.cpp b/core/mapi/mapiFile.cpp index cc05fbdc3..4a20a0a14 100644 --- a/core/mapi/mapiFile.cpp +++ b/core/mapi/mapiFile.cpp @@ -150,7 +150,7 @@ namespace file LPITNEF lpTNEF = nullptr; #pragma warning(push) #pragma warning( \ - disable : 28159) // Warning C28159 Consider using *function_name_1* instead of *function_name_2*. Reason: reason + disable : 28159) // Warning C28159 Consider using *function_name_1* instead of *function_name_2*. Reason: reason //GetTickCount is OK for what we're doing static auto wKeyVal = static_cast(GetTickCount() + 1); #pragma warning(pop) @@ -583,7 +583,7 @@ namespace file #pragma warning(push) #pragma warning( \ - disable : 28159) // Warning C28159 Consider using *function_name_1* instead of *function_name_2*. Reason: reason + disable : 28159) // Warning C28159 Consider using *function_name_1* instead of *function_name_2*. Reason: reason //GetTickCount is OK for what we're doing static auto wKeyVal = static_cast(GetTickCount() + 1); #pragma warning(pop) diff --git a/core/mapi/mapiFunctions.h b/core/mapi/mapiFunctions.h index 06acacc92..7e3f168f9 100644 --- a/core/mapi/mapiFunctions.h +++ b/core/mapi/mapiFunctions.h @@ -361,7 +361,7 @@ namespace mapi #pragma warning(push) #pragma warning( \ - disable : 26476) // Warning C26476 Expression/symbol '' uses a naked union '' with multiple type pointers: Use variant instead (type.7). + disable : 26476) // Warning C26476 Expression/symbol '' uses a naked union '' with multiple type pointers: Use variant instead (type.7). inline const SBinary& getBin(_In_ const _SPropValue* prop) noexcept { if (!prop) assert(false); diff --git a/mapistub b/mapistub index a888542d2..9646eb248 160000 --- a/mapistub +++ b/mapistub @@ -1 +1 @@ -Subproject commit a888542d2e2630bf0da3b3855d198773b61c700e +Subproject commit 9646eb248f405c83f72afa96ba9234cc84b06eea From 65f4ae0e18301d0d2acc37f64678ad1abe3ced87 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 11:59:23 -0400 Subject: [PATCH 2/7] remove custom clang script --- .github/workflows/clang.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/clang.yml diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml deleted file mode 100644 index ce4641185..000000000 --- a/.github/workflows/clang.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Clang-format - -on: - pull_request: - branches: [ "main" ] - workflow_dispatch: - -permissions: - contents: read - -jobs: - check-formatting: - runs-on: windows-latest - - steps: - - name: Harden Runner - uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 - with: - egress-policy: audit - - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: clang-format (w/ diff) - uses: egor-tensin/clang-format@5ee263e007725df60d02ef2e6fd3d0dd92f048a0 # v1.0.1 - with: - # :-separated list of excluded files and directories - exclude: include:mapistub From 73ef84429654336e089c0251e95257f5a35c01a5 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 14:01:50 -0400 Subject: [PATCH 3/7] try different clang runner --- .github/workflows/clang.yml | 27 +++++++++++++++++++++++++++ scripts/clang.ps1 | 10 ++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/clang.yml diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml new file mode 100644 index 000000000..b300bd9b7 --- /dev/null +++ b/.github/workflows/clang.yml @@ -0,0 +1,27 @@ +name: Clang-format + +on: + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + check-formatting: + name: Formatting Check + runs-on: windows-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - uses: actions/checkout@v4 + - name: Run clang-format style check for C/C++ programs. + uses: jidicula/clang-format-action@v4.13.0 + with: + clang-format-version: '17' + exclude-regex: 'mapistub/*' + fallback-style: 'Microsoft' \ No newline at end of file diff --git a/scripts/clang.ps1 b/scripts/clang.ps1 index 99ce6dfd8..18b953fbb 100644 --- a/scripts/clang.ps1 +++ b/scripts/clang.ps1 @@ -1,26 +1,28 @@ $vsRoot = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath $vcInstallDir = Join-Path $vsRoot "VC" -$clangdir = Join-Path $vcInstallDir "Tools\Llvm\bin\clang-format.exe" +$clang = Join-Path $vcInstallDir "Tools\Llvm\bin\clang-format.exe" # Check if VC install directory was found if ($null -eq $vcInstallDir) { Write-Host "Visual C++ installation directory not found." } -if ($null -eq $clangdir) { +if ($null -eq $clang) { Write-Host "clang not found." } +Write-Host "clang-format found at $clang" +& $clang --version Push-Location .. Write-Host "Formatting C++ headers" Get-ChildItem -Recurse -Filter *.h | Where-Object { $_.DirectoryName -notlike "*include*" } | ForEach-Object { - & $clangdir -i $_.FullName + & $clang -i $_.FullName } Write-Host "Formatting C++ sources" Get-ChildItem -Recurse -Filter *.cpp | ForEach-Object { - & $clangdir -i $_.FullName + & $clang -i $_.FullName } Pop-Location \ No newline at end of file From 3de1402c64e931c852c1a246ef1624207fef30f1 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 14:02:51 -0400 Subject: [PATCH 4/7] fix runner --- .github/workflows/clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index b300bd9b7..2b31d6680 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -11,7 +11,7 @@ permissions: jobs: check-formatting: name: Formatting Check - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Harden Runner uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 From 61a7de6db611fbdfdad1b7920cd7bc6af9a45bd6 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 14:08:15 -0400 Subject: [PATCH 5/7] add intentional clang break --- core/addin/addin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/addin/addin.cpp b/core/addin/addin.cpp index 3fa7d233e..5db818150 100644 --- a/core/addin/addin.cpp +++ b/core/addin/addin.cpp @@ -17,7 +17,7 @@ #include #include -std::vector PropTagArray; +std::vector PropTagArray ; std::vector PropTypeArray; std::vector PropGuidArray; std::vector NameIDArray; From 97d47580b15f83899abc47570859a047e7c61627 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 14:14:51 -0400 Subject: [PATCH 6/7] fix one clang - add another for additional test --- StdAfx.h | 2 +- core/addin/addin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/StdAfx.h b/StdAfx.h index 417dc20da..08df68b7a 100644 --- a/StdAfx.h +++ b/StdAfx.h @@ -41,7 +41,7 @@ // A bug in annotations in shobjidl.h forces us to disable 6387 to include afxwin.h #pragma warning(push) #pragma warning( \ - disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y + disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y #include // MFC core and standard components #pragma warning(pop) #include // MFC support for Windows Common Controls diff --git a/core/addin/addin.cpp b/core/addin/addin.cpp index 5db818150..3fa7d233e 100644 --- a/core/addin/addin.cpp +++ b/core/addin/addin.cpp @@ -17,7 +17,7 @@ #include #include -std::vector PropTagArray ; +std::vector PropTagArray; std::vector PropTypeArray; std::vector PropGuidArray; std::vector NameIDArray; From fafb1266e213241519badf82dd1ea51f791c9c80 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Mon, 17 Jun 2024 14:19:33 -0400 Subject: [PATCH 7/7] go to zero local clang format issues --- StdAfx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StdAfx.h b/StdAfx.h index 08df68b7a..417dc20da 100644 --- a/StdAfx.h +++ b/StdAfx.h @@ -41,7 +41,7 @@ // A bug in annotations in shobjidl.h forces us to disable 6387 to include afxwin.h #pragma warning(push) #pragma warning( \ - disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y + disable : 6387) // Warning C6387 'argument' may be 'value': this does not adhere to the specification for the function 'function name': Lines: x, y #include // MFC core and standard components #pragma warning(pop) #include // MFC support for Windows Common Controls