Skip to content

Commit 4d1e6e0

Browse files
committed
a few minor tweaks basked on static analysis suggestions
1 parent 64763f4 commit 4d1e6e0

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ else()
107107
-Wno-unused-macros
108108
-Wno-switch-enum
109109
-Wno-unknown-pragmas
110+
-Wsuggest-override
110111
)
111112

112113
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
@@ -126,6 +127,12 @@ else()
126127
#-Wduplicated-cond
127128
#-Wduplicated-branches
128129
-Wlogical-op
130+
131+
#-Wsuggest-attribute=pure
132+
#-Wsuggest-attribute=const
133+
#-Wsuggest-attribute=noreturn
134+
-Wsuggest-final-types
135+
-Wsuggest-final-methods
129136
)
130137
endif()
131138
endif()

Regex/Common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ uint8_t GET_OP_CODE(T *p) noexcept {
3535
* escape.
3636
*--------------------------------------------------------------------*/
3737
template <class R, class Ch>
38-
R literal_escape(Ch ch) noexcept {
38+
constexpr R literal_escape(Ch ch) noexcept {
3939

40-
static const char valid_escape[] = {
40+
constexpr char valid_escape[] = {
4141
'a', 'b', 'e', 'f', 'n', 'r', 't', 'v', '(', ')', '-', '[', ']', '<',
4242
'>', '{', '}', '.', '\\', '|', '^', '$', '*', '+', '?', '&', '\0'
4343
};
4444

45-
static const char value[] = {
45+
constexpr char value[] = {
4646
'\a', '\b', 0x1B, // Escape character in ASCII character set.
4747
'\f', '\n', '\r', '\t', '\v', '(', ')', '-', '[', ']', '<', '>', '{',
4848
'}', '.', '\\', '|', '^', '$', '*', '+', '?', '&', '\0'

Util/include/Util/utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
#ifndef UTILS_H_
33
#define UTILS_H_
44

5+
#include <QtGlobal>
6+
57
template <int (&F)(int), class Ch>
6-
int safe_ctype (Ch c) {
8+
constexpr int safe_ctype (Ch c) {
79
return F(static_cast<unsigned char>(c));
810
}
911

src/RangesetTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace {
99

1010
// --------------------------------------------------------------------------
1111

12-
const std::array<uint8_t, N_RANGESETS> rangeset_labels = {
12+
constexpr std::array<uint8_t, N_RANGESETS> rangeset_labels = {
1313
58, 10, 15, 1, 27, 52, 14, 3, 61, 13, 31, 30, 45, 28, 41, 55,
1414
33, 20, 62, 34, 42, 18, 57, 47, 24, 49, 19, 50, 25, 38, 40, 2,
1515
21, 39, 59, 22, 60, 4, 6, 16, 29, 37, 48, 46, 54, 43, 32, 56,

src/TextArea.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,9 +3204,12 @@ void TextArea::TextDResize(bool widthChanged) {
32043204
the top character no longer pointing at a valid line start */
32053205
if (continuousWrap_ && wrapMargin_ == 0 && widthChanged) {
32063206
const TextCursor oldFirstChar = firstChar_;
3207-
nBufferLines_ = TextDCountLines(buffer_->BufStartOfBuffer(), buffer_->BufEndOfBuffer(), /*startPosIsLineStart=*/true);
3207+
const TextCursor start = buffer_->BufStartOfBuffer();
3208+
const TextCursor end = buffer_->BufEndOfBuffer();
3209+
3210+
nBufferLines_ = TextDCountLines(start, end, /*startPosIsLineStart=*/true);
32083211
firstChar_ = TextDStartOfLine(firstChar_);
3209-
topLineNum_ = TextDCountLines(buffer_->BufStartOfBuffer(), firstChar_, /*startPosIsLineStart=*/true) + 1;
3212+
topLineNum_ = TextDCountLines(start, firstChar_, /*startPosIsLineStart=*/true) + 1;
32103213
offsetAbsLineNum(oldFirstChar);
32113214
}
32123215

src/TextAreaMimeData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TextAreaMimeData : public QMimeData {
1313
~TextAreaMimeData() override = default;
1414

1515
public:
16-
QStringList formats() const override;
16+
QStringList formats() const override final;
1717
bool hasFormat(const QString &mimeType) const override;
1818

1919
protected:

0 commit comments

Comments
 (0)