[all-commits] [llvm/llvm-project] 18d4ba: [LLVM][IR] Add location tracking to LLVM IR parser...

Bertik23 via All-commits all-commits at lists.llvm.org
Wed Oct 22 07:46:34 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 18d4ba593db9d6949300fbd97e900bfb86d651b2
      https://github.com/llvm/llvm-project/commit/18d4ba593db9d6949300fbd97e900bfb86d651b2
  Author: Bertik23 <39457484+Bertik23 at users.noreply.github.com>
  Date:   2025-10-22 (Wed, 22 Oct 2025)

  Changed paths:
    A llvm/include/llvm/AsmParser/AsmParserContext.h
    A llvm/include/llvm/AsmParser/FileLoc.h
    M llvm/include/llvm/AsmParser/LLLexer.h
    M llvm/include/llvm/AsmParser/LLParser.h
    M llvm/include/llvm/AsmParser/Parser.h
    M llvm/include/llvm/IRReader/IRReader.h
    A llvm/lib/AsmParser/AsmParserContext.cpp
    M llvm/lib/AsmParser/CMakeLists.txt
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/AsmParser/Parser.cpp
    M llvm/lib/IRReader/IRReader.cpp
    M llvm/unittests/AsmParser/AsmParserTest.cpp

  Log Message:
  -----------
  [LLVM][IR] Add location tracking to LLVM IR parser (#155797)

This PR is part of the LLVM IR LSP server project
([RFC](https://discourse.llvm.org/t/rfc-ir-visualization-with-vs-code-extension-using-an-lsp-server/87773))

To be able to make a LSP server, it's crucial to have location
information about the LLVM objects (Functions, BasicBlocks and
Instructions).

This PR adds:
 * Position tracking to the Lexer
 * A new AsmParserContext class, to hold the new position info
 * Tests to check if the location is correct

The AsmParserContext can be passed as an optional parameter into the
parser. Which populates it and it can be then used by other tools, such
as the LSP server.

The AsmParserContext idea was borrowed from MLIR. As we didn't want to
store data no one else uses inside the objects themselves. But the
implementation is different, this class holds several maps of Functions,
BasicBlocks and Instructions, to map them to their location.

And some utility methods were added to get the positions of the
processed tokens.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list