c/clang:file to loc

This commit is contained in:
luoliwoshang
2024-11-14 14:31:20 +08:00
parent ea654ef235
commit 78e96cc312
2 changed files with 32 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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.