Skip to content

Conversation

@leekillough
Copy link
Contributor

@leekillough leekillough commented Dec 29, 2025

This adds a clang-tidy.sh script which runs clang-tidy with a modest default set of checks, a more aggressive --picky set of checks, and a --checks option for specifying specific tests.

--fix can be used to invoke the clang-tidy automatic fixer, and it modifies files in the working tree similar to how test-includes.pl --fix automatically adds #includes.

This clang-tidy.sh is not intended for CI runs, but for periodic manual runs to detect potential issues and to modernize the SST code to modern C++ idioms.

I recommend running it with no arguments at first, inspecting the output file, and if one of the suggestions is acceptable, running it with the --fix --checks <check_name> with the check name listed in brackets near the suggestion ( [<check_name>]), running tests, and merging the changes if they are acceptable. Some of the automatic fixes might require massaging the code after it is edited, because it is not always perfect.

I found one va_arg leak (va_end() was not called), and I found a reversed name string comparison. I also saw an if ( strcmp(...) ) which clang-tidy warned about because the int result was implicitly converted to bool, but I only added != 0 since I am not sure whether the comparison was reversed or not.

A self-assignment check had to be added to decimal_fixedpoint. clang-tidy detected that self-assignment wasn't accounted for.

There were warnings about strcpy() being insecure, but in two such cases the strcpy() was preceded by a malloc() or new[] and both the allocation and strcpy() could be replaced with strdup().

I will add comments below each of these changes.

The changes are minimal, to avoid disruptions, but the script is robust enough to be used in the future for clang-tidy research into possible issues, as well as ideas for modernizing the code.

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels Dec 29, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v20 to check formatting

@github-actions github-actions bot added AT: CLANG-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels Dec 29, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - PASSED

@leekillough leekillough reopened this Dec 29, 2025
@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL and removed AT: CLANG-FORMAT PASS labels Dec 29, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v20 to check formatting

1 similar comment
@github-actions
Copy link

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v20 to check formatting

@github-actions github-actions bot added AT: CLANG-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels Dec 29, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - PASSED

fflush(stdout);

int launch_sst = execve(real_binary_path, argv, environ);
free(real_binary_path);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy complained about a possible memory leak in real_binary_path.

{
printf("SST-Core Version (" PACKAGE_VERSION);
if ( strcmp(SSTCORE_GIT_HEADSHA, PACKAGE_VERSION) ) {
if ( strcmp(SSTCORE_GIT_HEADSHA, PACKAGE_VERSION) != 0 ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy complained about the integer result of strcmp() being converted to bool without a comparison or boolean operator like !. I added != 0 which gets rid of the warning and has the same effect, but I would double-check this logic.

if ( columns ) {
errno = E_OK;
uint32_t x = strtoul(getenv("COLUMNS"), nullptr, 0);
uint32_t x = strtoul(columns, nullptr, 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy complained about getenv("COLUMNS") possibly passing nullptr as the first argument of strtoul(), even though we test getenv("COLUMNS") above. By loading getenv("COLUMNS") into columns and making sure it is not nullptr before passing it to strtoul(), the warning goes away, besides it being more efficient.


} // namespace Core
} // namespace SST
} // namespace SST::Core
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were still a few places where nested namespace names were not used. clang-tidy was able to fix these automatically, although it sometimes left the old namespace closing comment around, so I had to manually remove them.

*/
decimal_fixedpoint& operator=(const decimal_fixedpoint& v)
{
if ( &v == this ) return *this;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy complained about decimal_fixedpoint's assignment operator not checking for self-assignment.

}

delete[] pathCopy;
free(pathCopy);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy complained about strcpy() being inherently insecure. Since here we are simply allocating and copying a string, strdup() is simpler, and removes the warning.

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

if ( nullptr != envConfigPaths ) {
char* envConfigPathBuffer = (char*)malloc(sizeof(char) * (strlen(envConfigPaths) + 1));
strcpy(envConfigPathBuffer, envConfigPaths);
char* envConfigPathBuffer = strdup(envConfigPaths);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again, but here, the old code used malloc()/free() instead of new[]/delete[].

#include "sst/core/model/configGraph.h"
#include "sst/core/warnmacros.h"

#include <cstdlib>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are numerous places where C-style headers were replaced with C++ headers ( <stdlib.h> -> <cstdlib> etc.).

namespace SST {

using genPythonModuleFunction = void* (*)(void);
using genPythonModuleFunction = void* (*)();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(void) function parameter lists are the same as () in C++

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

3 similar comments
@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

Copy link
Member

@berquist berquist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is for the script only, and not the actual clang-tidy checks used.

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Merge Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
THE LAST COMMIT TO THIS PULL REQUEST HAS BEEN REVIEWED, BUT NOT ACCEPTED OR REQUIRES CHANGES!

@sst-autotester
Copy link
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

CLANG-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

CLANG-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED by label AT: PRE-TEST INSPECTED! Autotester is Removing Label; this inspection will remain valid until a new commit to source branch is performed.

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2433
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2383
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2382
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1002
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-15-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 933
  • Status: STARTED

Using Repos:

Repo: CORE (leekillough/sst-core)
  • Branch: clang-tidy
  • SHA: 95a1b12
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: 788652510af0795d1b08ea6504761359dca32fae
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: d588d110dfd2afca4c574a8bd2ad4a6f5240ef34
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 489f035111339bbd94e9db661a68c1b2cd7faf77
  • Mode: SUPPORT_REPO

Pull Request Author: leekillough

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED

Pull Request Auto Testing has PASSED (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements

  • Build Num: 2433
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MR-2

  • Build Num: 2383
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-elements_MT-2

  • Build Num: 2382
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.9_sst-core_Make-Dist

  • Build Num: 1002
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-15-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 933
  • Status: PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Merge Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
THE LAST COMMIT TO THIS PULL REQUEST HAS NOT BEEN REVIEWED YET!

@sst-autotester
Copy link
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Merge Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED AND APPROVED by [ feldergast ]!

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

@feldergast feldergast dismissed berquist’s stale review January 8, 2026 23:03

Items addressed. Can revisit at a future date if anything else comes up.

@feldergast feldergast merged commit 1973d80 into sstsimulator:devel Jan 8, 2026
10 checks passed
@leekillough leekillough deleted the clang-tidy branch January 20, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants