Skip to content

Commit

Permalink
a few minor tweaks basked on static analysis suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
eteran committed Jan 21, 2019
1 parent 64763f4 commit 4d1e6e0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ else()
-Wno-unused-macros
-Wno-switch-enum
-Wno-unknown-pragmas
-Wsuggest-override
)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand All @@ -126,6 +127,12 @@ else()
#-Wduplicated-cond
#-Wduplicated-branches
-Wlogical-op

#-Wsuggest-attribute=pure
#-Wsuggest-attribute=const
#-Wsuggest-attribute=noreturn
-Wsuggest-final-types
-Wsuggest-final-methods
)
endif()
endif()
Expand Down
6 changes: 3 additions & 3 deletions Regex/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ uint8_t GET_OP_CODE(T *p) noexcept {
* escape.
*--------------------------------------------------------------------*/
template <class R, class Ch>
R literal_escape(Ch ch) noexcept {
constexpr R literal_escape(Ch ch) noexcept {

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

static const char value[] = {
constexpr char value[] = {
'\a', '\b', 0x1B, // Escape character in ASCII character set.
'\f', '\n', '\r', '\t', '\v', '(', ')', '-', '[', ']', '<', '>', '{',
'}', '.', '\\', '|', '^', '$', '*', '+', '?', '&', '\0'
Expand Down
4 changes: 3 additions & 1 deletion Util/include/Util/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#ifndef UTILS_H_
#define UTILS_H_

#include <QtGlobal>

template <int (&F)(int), class Ch>
int safe_ctype (Ch c) {
constexpr int safe_ctype (Ch c) {
return F(static_cast<unsigned char>(c));
}

Expand Down
2 changes: 1 addition & 1 deletion src/RangesetTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace {

// --------------------------------------------------------------------------

const std::array<uint8_t, N_RANGESETS> rangeset_labels = {
constexpr std::array<uint8_t, N_RANGESETS> rangeset_labels = {
58, 10, 15, 1, 27, 52, 14, 3, 61, 13, 31, 30, 45, 28, 41, 55,
33, 20, 62, 34, 42, 18, 57, 47, 24, 49, 19, 50, 25, 38, 40, 2,
21, 39, 59, 22, 60, 4, 6, 16, 29, 37, 48, 46, 54, 43, 32, 56,
Expand Down
7 changes: 5 additions & 2 deletions src/TextArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3204,9 +3204,12 @@ void TextArea::TextDResize(bool widthChanged) {
the top character no longer pointing at a valid line start */
if (continuousWrap_ && wrapMargin_ == 0 && widthChanged) {
const TextCursor oldFirstChar = firstChar_;
nBufferLines_ = TextDCountLines(buffer_->BufStartOfBuffer(), buffer_->BufEndOfBuffer(), /*startPosIsLineStart=*/true);
const TextCursor start = buffer_->BufStartOfBuffer();
const TextCursor end = buffer_->BufEndOfBuffer();

nBufferLines_ = TextDCountLines(start, end, /*startPosIsLineStart=*/true);
firstChar_ = TextDStartOfLine(firstChar_);
topLineNum_ = TextDCountLines(buffer_->BufStartOfBuffer(), firstChar_, /*startPosIsLineStart=*/true) + 1;
topLineNum_ = TextDCountLines(start, firstChar_, /*startPosIsLineStart=*/true) + 1;
offsetAbsLineNum(oldFirstChar);
}

Expand Down
2 changes: 1 addition & 1 deletion src/TextAreaMimeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TextAreaMimeData : public QMimeData {
~TextAreaMimeData() override = default;

public:
QStringList formats() const override;
QStringList formats() const override final;
bool hasFormat(const QString &mimeType) const override;

protected:
Expand Down

0 comments on commit 4d1e6e0

Please sign in to comment.