Revise C++ coding style using clang-format with "east const"

Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
This commit is contained in:
Kitware Robot
2025-01-23 11:54:40 -05:00
committed by Brad King
parent 6ef947ea97
commit 0b96ae1f6a
887 changed files with 9690 additions and 9692 deletions
+7 -7
View File
@@ -24,12 +24,12 @@
#include "cmake.h"
namespace {
const cmDocumentationEntry cmDocumentationName = {
cmDocumentationEntry const cmDocumentationName = {
{},
" ccmake - Curses Interface for CMake."
};
const cmDocumentationEntry cmDocumentationUsage[2] = {
cmDocumentationEntry const cmDocumentationUsage[2] = {
{ {},
" ccmake <path-to-source>\n"
" ccmake <path-to-existing-build>" },
@@ -39,7 +39,7 @@ const cmDocumentationEntry cmDocumentationUsage[2] = {
"directory to re-generate its build system." },
};
const cmDocumentationEntry cmDocumentationUsageNote = {
cmDocumentationEntry const cmDocumentationUsageNote = {
{},
"Run 'ccmake --help' for more information."
};
@@ -157,7 +157,7 @@ int main(int argc, char const* const* argv)
* joined by '\n' before display.
* Removing any trailing '\n' avoid extra empty lines in the final results
*/
auto cleanMessage = [](const std::string& message) -> std::string {
auto cleanMessage = [](std::string const& message) -> std::string {
auto msg = message;
if (!msg.empty() && msg.back() == '\n') {
msg.pop_back();
@@ -165,13 +165,13 @@ int main(int argc, char const* const* argv)
return msg;
};
cmSystemTools::SetMessageCallback(
[&](const std::string& message, const cmMessageMetadata& md) {
[&](std::string const& message, cmMessageMetadata const& md) {
myform->AddError(cleanMessage(message), md.title);
});
cmSystemTools::SetStderrCallback([&](const std::string& message) {
cmSystemTools::SetStderrCallback([&](std::string const& message) {
myform->AddError(cleanMessage(message), "");
});
cmSystemTools::SetStdoutCallback([&](const std::string& message) {
cmSystemTools::SetStdoutCallback([&](std::string const& message) {
myform->UpdateProgress(cleanMessage(message), -1);
});
@@ -22,7 +22,7 @@
#include "cmValue.h"
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key, int labelwidth, int entrywidth)
std::string const& key, int labelwidth, int entrywidth)
: Key(key)
, LabelWidth(labelwidth)
, EntryWidth(entrywidth)
@@ -35,7 +35,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key, cmState* state, bool isNew, int labelwidth,
std::string const& key, cmState* state, bool isNew, int labelwidth,
int entrywidth)
: Key(key)
, LabelWidth(labelwidth)
@@ -100,7 +100,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite() = default;
const char* cmCursesCacheEntryComposite::GetValue()
char const* cmCursesCacheEntryComposite::GetValue()
{
if (this->Label) {
return this->Label->GetValue();
@@ -14,9 +14,9 @@ class cmState;
class cmCursesCacheEntryComposite
{
public:
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
cmCursesCacheEntryComposite(std::string const& key, int labelwidth,
int entrywidth);
cmCursesCacheEntryComposite(const std::string& key, cmState* state,
cmCursesCacheEntryComposite(std::string const& key, cmState* state,
bool isNew, int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();
@@ -28,7 +28,7 @@ public:
cmCursesCacheEntryComposite& operator=(cmCursesCacheEntryComposite&&) =
default;
const char* GetValue();
char const* GetValue();
friend class cmCursesMainForm;
+2 -2
View File
@@ -40,7 +40,7 @@ void cmCursesForm::DebugEnd()
cmCursesForm::DebugFile.close();
}
void cmCursesForm::LogMessage(const char* msg)
void cmCursesForm::LogMessage(char const* msg)
{
if (!cmCursesForm::Debug) {
return;
@@ -53,7 +53,7 @@ void cmCursesForm::HandleResize()
{
endwin();
if (!initscr()) {
static const char errmsg[] = "Error: ncurses initialization failed\n";
static char const errmsg[] = "Error: ncurses initialization failed\n";
#ifdef _WIN32
fprintf(stderr, "%s", errmsg);
#else
+2 -2
View File
@@ -35,7 +35,7 @@ public:
// Description:
// During a CMake run, an error handle should add errors
// to be displayed afterwards.
virtual void AddError(const std::string&, const char*) {}
virtual void AddError(std::string const&, char const*) {}
// Description:
// Turn debugging on. This will create ccmakelog.txt.
@@ -47,7 +47,7 @@ public:
// Description:
// Write a debugging message.
static void LogMessage(const char* msg);
static void LogMessage(char const* msg);
// Description:
// Return the FORM. Should be only used by low-level methods.
+1 -1
View File
@@ -5,7 +5,7 @@
#include "cmCursesWidget.h"
cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, int left,
int top, const std::string& name)
int top, std::string const& name)
: cmCursesWidget(width, height, left, top)
{
field_opts_off(this->Field, O_EDIT);
+1 -1
View File
@@ -15,7 +15,7 @@ class cmCursesLabelWidget : public cmCursesWidget
{
public:
cmCursesLabelWidget(int width, int height, int left, int top,
const std::string& name);
std::string const& name);
~cmCursesLabelWidget() override;
cmCursesLabelWidget(cmCursesLabelWidget const&) = delete;
@@ -17,7 +17,7 @@ inline int ctrl(int z)
}
cmCursesLongMessageForm::cmCursesLongMessageForm(
std::vector<std::string> const& messages, const char* title,
std::vector<std::string> const& messages, char const* title,
ScrollBehavior scrollBehavior)
: Scrolling(scrollBehavior)
{
@@ -148,7 +148,7 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/,
refresh();
}
void cmCursesLongMessageForm::DrawMessage(const char* msg) const
void cmCursesLongMessageForm::DrawMessage(char const* msg) const
{
int i = 0;
while (msg[i] != '\0' && i < MAX_CONTENT_SIZE) {
@@ -20,7 +20,7 @@ public:
};
cmCursesLongMessageForm(std::vector<std::string> const& messages,
const char* title, ScrollBehavior scrollBehavior);
char const* title, ScrollBehavior scrollBehavior);
~cmCursesLongMessageForm() override;
cmCursesLongMessageForm(cmCursesLongMessageForm const&) = delete;
@@ -50,7 +50,7 @@ public:
protected:
static constexpr int MAX_CONTENT_SIZE = 60000;
void DrawMessage(const char* msg) const;
void DrawMessage(char const* msg) const;
std::string Messages;
std::string Title;
+19 -19
View File
@@ -61,7 +61,7 @@ cmCursesMainForm::~cmCursesMainForm()
}
// See if a cache entry is in the list of entries in the ui.
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
bool cmCursesMainForm::LookForCacheEntry(std::string const& key)
{
return std::any_of(this->Entries.begin(), this->Entries.end(),
[&key](cmCursesCacheEntryComposite const& entry) {
@@ -326,7 +326,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
" ");
}
{
const char* toggleKeyInstruction =
char const* toggleKeyInstruction =
" [t] Toggle advanced mode (currently %s)";
snprintf(thirdLine, sizeof(thirdLine), toggleKeyInstruction,
this->AdvancedMode ? "on" : "off");
@@ -439,7 +439,7 @@ void cmCursesMainForm::UpdateStatusBar(cm::optional<std::string> message)
pos_form_cursor(this->Form);
}
void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
void cmCursesMainForm::UpdateProgress(std::string const& msg, float prog)
{
if (prog >= 0) {
constexpr int progressBarWidth = 40;
@@ -473,7 +473,7 @@ int cmCursesMainForm::Configure(int noconfigure)
if (noconfigure == 0) {
this->UpdateProgress("Configuring", 0);
this->CMakeInstance->SetProgressCallback(
[this](const std::string& msg, float prog) {
[this](std::string const& msg, float prog) {
this->UpdateProgress(msg, prog);
});
}
@@ -505,7 +505,7 @@ int cmCursesMainForm::Configure(int noconfigure)
int xx;
int yy;
getmaxyx(stdscr, yy, xx);
const char* title = "Configure produced the following output";
char const* title = "Configure produced the following output";
if (cmSystemTools::GetErrorOccurredFlag()) {
title = "Configure failed with the following output";
}
@@ -540,7 +540,7 @@ int cmCursesMainForm::Generate()
this->UpdateProgress("Generating", 0);
this->CMakeInstance->SetProgressCallback(
[this](const std::string& msg, float prog) {
[this](std::string const& msg, float prog) {
this->UpdateProgress(msg, prog);
});
@@ -560,7 +560,7 @@ int cmCursesMainForm::Generate()
int xx;
int yy;
getmaxyx(stdscr, yy, xx);
const char* title = "Generate produced the following output";
char const* title = "Generate produced the following output";
if (cmSystemTools::GetErrorOccurredFlag()) {
title = "Generate failed with the following output";
}
@@ -587,15 +587,15 @@ int cmCursesMainForm::Generate()
return 0;
}
void cmCursesMainForm::AddError(const std::string& message,
const char* /*unused*/)
void cmCursesMainForm::AddError(std::string const& message,
char const* /*unused*/)
{
this->Outputs.emplace_back(message);
this->HasNonStatusOutputs = true;
this->DisplayOutputs(message);
}
void cmCursesMainForm::RemoveEntry(const char* value)
void cmCursesMainForm::RemoveEntry(char const* value)
{
if (!value) {
return;
@@ -604,7 +604,7 @@ void cmCursesMainForm::RemoveEntry(const char* value)
auto removeIt =
std::find_if(this->Entries.begin(), this->Entries.end(),
[value](cmCursesCacheEntryComposite& entry) -> bool {
const char* val = entry.GetValue();
char const* val = entry.GetValue();
return val && !strcmp(value, val);
});
@@ -618,7 +618,7 @@ void cmCursesMainForm::RemoveEntry(const char* value)
void cmCursesMainForm::FillCacheManagerFromUI()
{
for (cmCursesCacheEntryComposite& entry : this->Entries) {
const std::string& cacheKey = entry.Key;
std::string const& cacheKey = entry.Key;
cmValue existingValue =
this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
if (existingValue) {
@@ -643,7 +643,7 @@ void cmCursesMainForm::FillCacheManagerFromUI()
}
void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type,
const std::string& in, std::string& out) const
std::string const& in, std::string& out) const
{
out = in.substr(0, in.find_last_not_of(' ') + 1);
if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) {
@@ -826,7 +826,7 @@ void cmCursesMainForm::HandleInput()
int findex = field_index(cur);
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
field_userptr(this->Fields[findex - 2]));
const char* curField = lbl->GetValue();
char const* curField = lbl->GetValue();
cmValue helpString = nullptr;
cmValue existingValue =
@@ -955,7 +955,7 @@ void cmCursesMainForm::HandleInput()
}
}
int cmCursesMainForm::LoadCache(const char* /*unused*/)
int cmCursesMainForm::LoadCache(char const* /*unused*/)
{
int r = this->CMakeInstance->LoadCache();
@@ -972,12 +972,12 @@ int cmCursesMainForm::LoadCache(const char* /*unused*/)
return r;
}
void cmCursesMainForm::JumpToCacheEntry(const char* astr)
void cmCursesMainForm::JumpToCacheEntry(char const* astr)
{
this->JumpToCacheEntry(astr, false);
}
void cmCursesMainForm::JumpToCacheEntry(const char* astr, bool reverse)
void cmCursesMainForm::JumpToCacheEntry(char const* astr, bool reverse)
{
std::string str;
if (astr) {
@@ -998,7 +998,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr, bool reverse)
field_userptr(this->Fields[findex - 2]));
}
if (lbl) {
const char* curField = lbl->GetValue();
char const* curField = lbl->GetValue();
if (curField) {
std::string cfld = cmSystemTools::LowerCase(curField);
if (cfld.find(str) != std::string::npos && findex != start_index) {
@@ -1057,7 +1057,7 @@ void cmCursesMainForm::DisplayOutputs(std::string const& newOutput)
}
}
const char* cmCursesMainForm::s_ConstHelpMessage =
char const* cmCursesMainForm::s_ConstHelpMessage =
"CMake is used to configure and generate build files for software projects. "
"The basic steps for configuring a project with ccmake are as follows:\n\n"
"1. Run ccmake in the directory where you want the object and executable "
+9 -9
View File
@@ -53,7 +53,7 @@ public:
* Returns true if an entry with the given key is in the
* list of current composites.
*/
bool LookForCacheEntry(const std::string& key);
bool LookForCacheEntry(std::string const& key);
enum
{
@@ -84,7 +84,7 @@ public:
* During a CMake run, an error handle should add errors
* to be displayed afterwards.
*/
void AddError(const std::string& message, const char* title) override;
void AddError(std::string const& message, char const* title) override;
/**
* Write files to cache file without reconfiguring.
@@ -105,30 +105,30 @@ public:
/**
* Used by main program
*/
int LoadCache(const char* dir);
int LoadCache(char const* dir);
/**
* Progress callback
*/
void UpdateProgress(const std::string& msg, float prog);
void UpdateProgress(std::string const& msg, float prog);
protected:
// Copy the cache values from the user interface to the actual
// cache.
void FillCacheManagerFromUI();
// Fix formatting of values to a consistent form.
void FixValue(cmStateEnums::CacheEntryType type, const std::string& in,
void FixValue(cmStateEnums::CacheEntryType type, std::string const& in,
std::string& out) const;
// Re-post the existing fields. Used to toggle between
// normal and advanced modes. Render() should be called
// afterwards.
void RePost();
// Remove an entry from the interface and the cache.
void RemoveEntry(const char* value);
void RemoveEntry(char const* value);
// Jump to the cache entry whose name matches the string.
void JumpToCacheEntry(const char* str);
void JumpToCacheEntry(const char* str, bool reverse);
void JumpToCacheEntry(char const* str);
void JumpToCacheEntry(char const* str, bool reverse);
// Clear and reset the output log and state
void ResetOutputs();
@@ -156,7 +156,7 @@ protected:
std::vector<std::string> HelpMessage;
// Common help
static const char* s_ConstHelpMessage;
static char const* s_ConstHelpMessage;
// Fields displayed. Includes labels, new entry markers, entries
std::vector<FIELD*> Fields;
@@ -79,7 +79,7 @@ void cmCursesOptionsWidget::PreviousOption()
this->SetValue(this->Options[this->CurrentOption]);
}
void cmCursesOptionsWidget::SetOption(const std::string& value)
void cmCursesOptionsWidget::SetOption(std::string const& value)
{
this->CurrentOption = 0; // default to 0 index
this->SetValue(value);
+1 -1
View File
@@ -25,7 +25,7 @@ public:
// when this widget has focus. Returns true if the input was
// handled.
bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
void SetOption(const std::string&);
void SetOption(std::string const&);
void AddOption(std::string const&);
void NextOption();
void PreviousOption();
+3 -3
View File
@@ -165,17 +165,17 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
return true;
}
void cmCursesStringWidget::SetString(const std::string& value)
void cmCursesStringWidget::SetString(std::string const& value)
{
this->SetValue(value);
}
const char* cmCursesStringWidget::GetString()
char const* cmCursesStringWidget::GetString()
{
return this->GetValue();
}
const char* cmCursesStringWidget::GetValue()
char const* cmCursesStringWidget::GetValue()
{
return field_buffer(this->Field, 0);
}
+3 -3
View File
@@ -32,9 +32,9 @@ public:
/**
* Set/Get the string.
*/
void SetString(const std::string& value);
const char* GetString();
const char* GetValue() override;
void SetString(std::string const& value);
char const* GetString();
char const* GetValue() override;
/**
* Set/Get InEdit flag. Can be used to tell the widget to leave
+2 -2
View File
@@ -32,13 +32,13 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage)
}
}
void cmCursesWidget::SetValue(const std::string& value)
void cmCursesWidget::SetValue(std::string const& value)
{
this->Value = value;
set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
}
const char* cmCursesWidget::GetValue()
char const* cmCursesWidget::GetValue()
{
return this->Value.c_str();
}
+2 -2
View File
@@ -37,8 +37,8 @@ public:
* Set/Get the value (setting the value also changes the contents
* of the field buffer).
*/
virtual void SetValue(const std::string& value);
virtual const char* GetValue();
virtual void SetValue(std::string const& value);
virtual char const* GetValue();
/**
* Get the type of the widget (STRING, PATH etc...)