From 8c099ce72d480fbff943613c7482992449fafe2d Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Tue, 23 Apr 2019 21:15:26 +0000 Subject: 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 --- clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp') 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) -- cgit v1.2.3