Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] CDT Monthly Call
  • From: Nathan Ridge <zeratul976@xxxxxxxxxxx>
  • Date: Wed, 8 Mar 2023 22:12:24 +0000
  • Accept-language: en-CA, en-US
  • Arc-authentication-results: i=1; 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed;; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Hhk5hW5LQ5sVrHpmZstKBuBgqnryoNBx82qSnSmoRuk=; b=Lcj8CJ17TJvqx86QiTqjnRCDPaJVqvYTY4s03mVJsqbxNbJlByzEPh9p793u3Wh1KaqpTLbmBTv7/fRc9oyvCrvgyKFR3wiGKoLt71r3TbIEAxU463knjI0d9PM16b5TyIryZvk1IdObpsLB5t+PwZ9TaxTIV8lZ8kfDno9U05g61tQCllOk6wWoI8B4JOftdfosYV0w4DcZmRVsa5VanlV+isA/mGb40+vbVt1kddzIw9P3lzDgL0h83sVy8BTrAWFT6kp/hHTtVZ7JLeVnulyW4dUNPMn2DJQ9DCZspYdls1zVVy7eFSp2xGm2QKFWYRnMopkysK4qDiAyZfug8Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901;; cv=none; b=NOTk7fLudjOu9n1anZn6WyhSYcUV9G2uuceVi7bIJAaha5nyLTRrGmeRHBOo4vt0YMgrI6t7fqbY1cirdzkxxwzQioxWx+uYJf1XgdnTqxzludCVImL/ySnQvMQk85+wPyeizhkhxyni401IOmH9pfBdemA0dpLF/oDnjhoPbQHoeLu59d1IB+URDeCvRBdgAywKFnVCMOq6nMavmbFGVIjNSownxLfG7OasDjXCzZ9P4XMTyVD3GcdA4oRQhbuUOv6nT31y23Of9w2vY9HO58W113h6/xUmlhHIDnFB/UK5phyr7tfLW5cowS38Ib+GnrCxsN44FZNbs7AWhrQupw==
  • Delivered-to: cdt-dev@xxxxxxxxxxx
  • List-archive: <>
  • List-help: <>
  • List-subscribe: <>, <>
  • List-unsubscribe: <>, <>
  • Msip_labels:
  • Thread-index: AQHZUWkm/zzvgzZ1QkeFFq7+j7mqT67xM6WAgAAVab2AAAsAgIAAGvTQ
  • Thread-topic: [cdt-dev] CDT Monthly Call

Hi Dominic,

> as discussed in the call today, one point on the roadmap is AST support.
> Clangd provides a protocol extension to get the AST for a text document.
> I just played around with lsp4j and was able to get the AST from clangd*.
> Do you have a feeling about if it would be feasible to convert the
> clangd AST to the cdt AST?

My understanding is that the textDocument/ast protocol extension is meant
primarily for visualizing the AST in an "AST view" (which in turn is primarily
useful as a debugging tool for developers of clangd and other clang-based 

I don't think it's meant for building client-side AST traversal logic on top of,
and I suspect it's likely not detailed enough to build a CDT AST from it.

Moreover, I think the idea behind the Language Server Protocol is to place
operations requiring a semantic understanding of the code like AST
traversal on the server side, and expose them to the client in the form of
high-level operations such as diagnostics and code actions. Among other
advantages, this removes the need for clients to maintain their own AST
representations, which then need to be kept up to date with the evolving
C and C++ languages.

So, I think the more promising approach would be to take the operations
you'd want to perform on the CDT AST (for example, Codan checkers),
and port them to the clang AST instead (for example, in the form of
clang-tidy checkers; note that you'll probably find that the equivalents of
many of CDT's existing Codan checkers already exist, and are more battle-
tested, as clang-tidy checkers), where they can run on the server side as
part of clangd.

One thing that will need to be figured out / improved here is clangd's
extensibility story for third-party checkers and other functionality.
Currently, these need to be baked in at clangd's build time, but a
mechanism to support runtime extensibility seems like it could be a
worthwhile improvement in general.

Hope that helps,

Back to the top