diff --git a/c/clang/_wrap/cursor.cpp b/c/clang/_wrap/cursor.cpp index 7bfb4031..2952a0d2 100644 --- a/c/clang/_wrap/cursor.cpp +++ b/c/clang/_wrap/cursor.cpp @@ -15,6 +15,14 @@ CXChildVisitResult wrap_visitor(CXCursor cursor, CXCursor parent, CXClientData d extern "C" { +void wrap_clang_getLocation(CXTranslationUnit tu, CXFile file, unsigned line, unsigned column, CXSourceLocation *loc) { + *loc = clang_getLocation(tu, file, line, column); +} + +void wrap_clang_getLocationForOffset(CXTranslationUnit tu, CXFile file, unsigned offset, CXSourceLocation *loc) { + *loc = clang_getLocationForOffset(tu, file, offset); +} + void wrap_clang_getTranslationUnitCursor(CXTranslationUnit uint, CXCursor *cur) { *cur = clang_getTranslationUnitCursor(uint); } diff --git a/c/clang/clang.go b/c/clang/clang.go index f3136d93..8f2faf9b 100644 --- a/c/clang/clang.go +++ b/c/clang/clang.go @@ -1157,6 +1157,30 @@ type UnsavedFile struct { Length c.Ulong } +/** + * Retrieves the source location associated with a given file/line/column + * in a particular translation unit. + */ +// llgo:link (*TranslationUnit).wrapGetLocation C.wrap_clang_getLocation +func (t *TranslationUnit) wrapGetLocation(file File, line, column c.Uint, loc *SourceLocation) {} + +func (t *TranslationUnit) GetLocation(file File, line, column c.Uint) (ret SourceLocation) { + t.wrapGetLocation(file, line, column, &ret) + return +} + +/** + * Retrieves the source location associated with a given character offset + * in a particular translation unit. + */ +// llgo:link (*TranslationUnit).wrapGetLocationForOffset C.wrap_clang_getLocationForOffset +func (t *TranslationUnit) wrapGetLocationForOffset(file File, offset c.Uint, loc *SourceLocation) {} + +func (t *TranslationUnit) GetLocationForOffset(file File, offset c.Uint) (ret SourceLocation) { + t.wrapGetLocationForOffset(file, offset, &ret) + return +} + /** * An "index" that consists of a set of translation units that would * typically be linked together into an executable or library.