diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 2d6504c..e9ea69aa 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -107,17 +107,16 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) { FixItHints.push_back( FixItHint::CreateReplacement(SourceRange(AssertLoc), "static_assert")); - std::string StaticAssertMSG = ", \"\""; if (AssertExprRoot) { FixItHints.push_back(FixItHint::CreateRemoval( SourceRange(AssertExprRoot->getOperatorLoc()))); FixItHints.push_back(FixItHint::CreateRemoval( SourceRange(AssertMSG->getBeginLoc(), AssertMSG->getEndLoc()))); - StaticAssertMSG = (Twine(", \"") + AssertMSG->getString() + "\"").str(); + FixItHints.push_back(FixItHint::CreateInsertion( + LastParenLoc, (Twine(", \"") + AssertMSG->getString() + "\"").str())); + } else if (!Opts.CPlusPlus17) { + FixItHints.push_back(FixItHint::CreateInsertion(LastParenLoc, ", \"\"")); } - - FixItHints.push_back( - FixItHint::CreateInsertion(LastParenLoc, StaticAssertMSG)); } diag(AssertLoc, "found assert() that could be replaced by static_assert()") |