[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 8 06:43:49 PDT 2018
ilya-biryukov added inline comments.
================
Comment at: lib/AST/RawCommentList.cpp:376
+ SourceMgr.getSpellingColumnNumber(Tok.getLocation(), &LocInvalid);
+ if (LocInvalid)
+ TokColumn = 0;
----------------
ioeric wrote:
> This is a bit confusing... Could you please add comments about the behavior here (as chatted offline)?
After thinking about it for a while, decided to add an assert that location was valid instead.
Invalid locations don't make any sense there, since we won't be able to get the comment text in case of invalid locs.
================
Comment at: lib/AST/RawCommentList.cpp:394
+ : std::min(WhitespaceLen,
+ (size_t)std::max((int)IndentColumn - (int)TokColumn, 0));
+ llvm::StringRef Trimmed = TokText.drop_front(SkipLen);
----------------
ioeric wrote:
> use `static_cast` instead of conversions.
Done. Rewrote the code to keep the reduce the number of casts too. It was unreadable with 3 static casts and default formatting.
Repository:
rC Clang
https://reviews.llvm.org/D46000
More information about the cfe-commits
mailing list