This is an archive of the discontinued LLVM Phabricator instance.

[mlir][PDLL] Add initial support for a PDLL compilation database
ClosedPublic

Authored by rriddle on Apr 20 2022, 2:18 AM.

Details

Summary

The compilation database acts in a similar way to the compilation database
(compile_commands.json) used by clang-tidy, i.e. it provides additional
information about the compilation of project files to help the language
server. The main piece of information provided by the PDLL compilation
database in this commit is the set of include directories used when processing
the input .pdll file. This allows for the server to properly process .pdll files
that use includes anchored by the include directories set up in the build system.

The structure of the textual form of a compilation database is a yaml file
containing documents of the following form:

--- !FileInfo:
  filepath: <string> - Absolute file path of the file.
  includes: <string> - Semi-colon delimited list of include directories.

This commit also adds support to cmake for automatically generating
a pdll_compile_commands.yml file at the top-level of the build
directory.

Diff Detail

Event Timeline

rriddle created this revision.Apr 20 2022, 2:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 2:18 AM
rriddle requested review of this revision.Apr 20 2022, 2:18 AM
rriddle updated this revision to Diff 424287.Apr 21 2022, 2:04 PM
rriddle edited the summary of this revision. (Show Details)
jpienaar accepted this revision.Apr 24 2022, 1:07 PM

Nice, thanks!

mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
50

This doesn't feel like consistent auto usage

74

Do we care about overlap?

mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.h
40

Construct from ?

45

s/this file/'filename'/ ? ("this" always feels overloaded unless referring to object)

mlir/lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp
59

YAML instead of .yml? (Type more important than file extension)

This revision is now accepted and ready to land.Apr 24 2022, 1:07 PM
rriddle marked 5 inline comments as done.Apr 26 2022, 3:54 PM
rriddle added inline comments.
mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
74

Not really IMO, given that such a situation would imply some misconfiguration in compilation databases (these files are intended to be absolute paths). Ignoring them doesn't really "harm" anyone, but added a log message.

This revision was landed with ongoing or failed builds.Apr 26 2022, 6:34 PM
This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.