summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-04-23 21:15:26 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-04-23 21:15:26 +0000
commit8c099ce72d480fbff943613c7482992449fafe2d (patch)
tree8267c823a4c59b202a1fba84bf73bd4b39c764f5 /clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
parentfc79ab9857adc96d243cc5ed0a641eef8ef3f253 (diff)
downloadbcm5719-llvm-8c099ce72d480fbff943613c7482992449fafe2d.tar.gz
bcm5719-llvm-8c099ce72d480fbff943613c7482992449fafe2d.zip
Re-apply r357823 "[Lexer] NFC: Fix an off-by-one bug in getAsCharRange()."
It now comes with a follow-up fix for the clients of this API in clangd and clang-tidy. Differential Revision: https://reviews.llvm.org/D59977 llvm-svn: 359035
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 17184ec21b9..6428f8cdc98 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -102,11 +102,14 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
}
}
+ // FIXME: This probably breaks on comments between the namespace and its '{'.
auto TextRange =
Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin, LBracketLocation),
Sources, getLangOpts());
StringRef NestedNamespaceName =
- Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
+ Lexer::getSourceText(TextRange, Sources, getLangOpts())
+ .rtrim('{') // Drop the { itself.
+ .rtrim(); // Drop any whitespace before it.
bool IsNested = NestedNamespaceName.contains(':');
if (IsNested)
OpenPOWER on IntegriCloud