Skip to content

SourceLocation Clang API 지원 #11

@bongjunj

Description

@bongjunj

From #6

문제점

https://github.com/prosyslab/claml/blob/d2765b65d92a878137ad416f85ee3016db8218e8/src/clang_ocaml.cpp#L289C1-L305

claml/src/clang.ml

Lines 20 to 22 in d2765b6

module SourceLocation : Sig.SOURCE_LOCATION = struct
type t = { filename : string; line : int; column : int }
end

현재 claml에서 SourceLocation이 OCaml Record로 구현되어 있고, PresumedLoc(https://clang.llvm.org/doxygen/classclang_1_1PresumedLoc.html)의 정보를 이용해 생성됨.

이러면 Clang C++ API에서
PresumedLoc에서 SourceLocation으로 변환하기 힘들기 때문에
SourceLocation을 사용하는 API를 호출하기 어려움.

SourceLocation이 직접 사용되는 예시: https://clang.llvm.org/doxygen/classclang_1_1Rewriter.html#a5fd6f665d719a8f2dbd6a6e6b5e1436b

Rewriter에서 SourceLocation을 사용해 삽입할 텍스트 위치를 받는데,
현재 구현상으로는 OCaml Record에 있는 filename, line, colSourceLocation로 변환해야 함.

현 상황에서 어떻게 변환해야 하는지 알기 어려움.

가능한 해결책

Clang C++ API에서 사용하기 쉽게 구현을 변경하면 좋겠음.
예를 들어, SourceLocation C++ 개체를 OCaml에서 접근할 수 있도록 Interface를 선택해 제공.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions