[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
Wed Apr 25 08:30:42 PDT 2018


ilya-biryukov added inline comments.


================
Comment at: lib/AST/RawCommentList.cpp:380
+        SourceMgr.getSpellingColumnNumber(Tok.getLocation(), &LocInvalid);
+    if (LocInvalid)
+      TokColumn = 0;
----------------
ilya-biryukov wrote:
> ioeric wrote:
> > Explain when this would be invalid and why `TokColumn = 0` is used?
> I don't know whether this can be even be invalid, but I'm not confident enough to add an assert there.
> `TokColumn = 0` seems like a reasonable way to recover if we can't compute the column number, i.e. assume the line starts at the first column if SourceLocation of the line was invalid for any reason.
> 
> This whole column thing looks weird to me, maybe I should just remove it altogether and just remove the same amount of whitespace in all the lines. WDYT?
On a second thought, now I remember why I added this in the first place.
To support the following example we want to take column numbers into account:

```
class Foo {
    /* A block comment
       spanning multiple lines
       has too many spaces on the all lines except the first one.
    */
    int func();
};
```


Repository:
  rC Clang

https://reviews.llvm.org/D46000





More information about the cfe-commits mailing list