[clang] 0079343 - [libTooling][NFC] Add a comment about comment parsing to getAssociatedRange.

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 30 05:47:18 PDT 2022


Author: Aaron Jacobs
Date: 2022-06-30T12:46:57Z
New Revision: 007934343c4c18102b2b3e4195d356dbcdf9a3fc

URL: https://github.com/llvm/llvm-project/commit/007934343c4c18102b2b3e4195d356dbcdf9a3fc
DIFF: https://github.com/llvm/llvm-project/commit/007934343c4c18102b2b3e4195d356dbcdf9a3fc.diff

LOG: [libTooling][NFC] Add a comment about comment parsing to getAssociatedRange.

It took me multiple hours of debugging plus asking an expert for help to
figure out why this function didn't do what it promised to do. It turns
out there is a flag that needs to be set. Document this, in an attempt
to save the next person the surprise.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D128774

Added: 
    

Modified: 
    clang/include/clang/Tooling/Transformer/SourceCode.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/Transformer/SourceCode.h b/clang/include/clang/Tooling/Transformer/SourceCode.h
index 16411b9c398d0..f3d119c86074a 100644
--- a/clang/include/clang/Tooling/Transformer/SourceCode.h
+++ b/clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@ CharSourceRange getExtendedRange(const T &Node, tok::TokenKind Next,
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// `-fparse-all-comments`.
 CharSourceRange getAssociatedRange(const Decl &D, ASTContext &Context);
 
 /// Returns the source-code text in the specified range.


        


More information about the cfe-commits mailing list