This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simplify `insertDecl` and support insertion after the last declaration in a file
AbandonedPublic

Authored by avogelsgesang on Mar 20 2022, 7:44 AM.

Details

Summary

So far insertDecl, did not support insertion of new code after the
last top-level declaration in a file. This was, because a
TranslationUnitDecl does not have a valid getEndLoc().

Also, the logic of Anchor::Below was somewhat surprising: I would have
expected Below to insert below the first match. Instead it insert
after the first contigous run of matches. I found this highly
unintuitive, and replaced it by an additional optional First/Last
flag which can be specified for an anchor.

Diff Detail