diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2021-02-26 19:10:25 +0000 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2021-02-26 19:10:25 +0000 |
commit | 1a721b6a2634d9740b389a7604275b426c22600a (patch) | |
tree | c49d04021185a9127e46207922c0ca16c07ecf94 /clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp | |
parent | b55f29c194d31cb51096d80b5e2710fc3385a7ef (diff) | |
download | llvm-1a721b6a2634d9740b389a7604275b426c22600a.zip llvm-1a721b6a2634d9740b389a7604275b426c22600a.tar.gz llvm-1a721b6a2634d9740b389a7604275b426c22600a.tar.bz2 |
[clang-tidy][NFC] Tweak some generation of diag messages
Fix up cases where diag is called by piecing together a string in favour of placeholders.
Fix up cases where select could be used instead of duplicating the message for sake of 1 word difference.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D97488
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp index bc586d30..872dd18 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp @@ -57,13 +57,10 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) { void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) { const auto *ArrayType = Result.Nodes.getNodeAs<TypeLoc>("typeloc"); - static constexpr llvm::StringLiteral UseArray = llvm::StringLiteral( - "do not declare C-style arrays, use std::array<> instead"); - static constexpr llvm::StringLiteral UseVector = llvm::StringLiteral( - "do not declare C VLA arrays, use std::vector<> instead"); - diag(ArrayType->getBeginLoc(), - ArrayType->getTypePtr()->isVariableArrayType() ? UseVector : UseArray); + "do not declare %select{C-style|C VLA}0 arrays, use " + "%select{std::array<>|std::vector<>}0 instead") + << ArrayType->getTypePtr()->isVariableArrayType(); } } // namespace modernize |