Renamed CXSourceFileLine to CXSourceLocation and added a CXFile, to
better match Clang's SourceLocation. Teach clang_getDeclExtent to fill
in the CXFile properly.
Renamed CXSourceExtent to CXSourceRange, to better match Clang's
SourceLocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93783
91177308-0d34-0410-b5e6-
96231b3b80d8
CINDEX_LINKAGE const char *clang_getDeclSource(CXDecl); /* deprecate */
CINDEX_LINKAGE CXFile clang_getDeclSourceFile(CXDecl);
-typedef struct CXSourceLineColumn {
+/**
+ * \brief Identifies a specific source location given its file, line, and
+ * column.
+ */
+typedef struct {
+ CXFile file;
unsigned line;
unsigned column;
-} CXSourceLineColumn;
+} CXSourceLocation;
-typedef struct CXDeclExtent {
- CXSourceLineColumn begin;
- CXSourceLineColumn end;
-} CXSourceExtent;
+/**
+ * \brief Identifies a range of source locations identified by the starting and
+ * ending locations of that range.
+ *
+ * The \c begin location points to the first character in the range and the
+ * \c end location points to the last character in the range.
+ */
+typedef struct {
+ CXSourceLocation begin;
+ CXSourceLocation end;
+} CXSourceRange;
/* clang_getDeclExtent() returns the physical extent of a declaration. The
* beginning line/column pair points to the start of the first token in the
* declaration, and the ending line/column pair points to the last character in
* the last token of the declaration.
*/
-CINDEX_LINKAGE CXSourceExtent clang_getDeclExtent(CXDecl);
+CINDEX_LINKAGE CXSourceRange clang_getDeclExtent(CXDecl);
/*
* CXCursor Operations.
return SourceMgr.getSpellingColumnNumber(ND->getLocation());
}
-CXDeclExtent clang_getDeclExtent(CXDecl AnonDecl) {
+CXSourceRange clang_getDeclExtent(CXDecl AnonDecl) {
assert(AnonDecl && "Passed null CXDecl");
NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
SourceManager &SM = ND->getASTContext().getSourceManager();
SourceLocation End = SM.getInstantiationLoc(R.getEnd());
if (!Begin.isValid()) {
- CXDeclExtent extent = { { 0, 0 }, { 0, 0 } };
+ CXSourceRange extent = { { 0, 0, 0 }, { 0, 0, 0 } };
return extent;
}
}
// Package up the line/column data and return to the caller.
- CXDeclExtent extent = { { StartLineNo, StartColNo },
- { EndLineNo, EndColNo } };
+ const FileEntry *FEntry = SM.getFileEntryForID(SM.getFileID(Begin));
+ CXSourceRange extent = { { (void *)FEntry, StartLineNo, StartColNo },
+ { (void *)FEntry, EndLineNo, EndColNo } };
return extent;
}
static const char *FileCheckPrefix = "CHECK";
static void PrintDeclExtent(CXDecl Dcl) {
- CXSourceExtent extent;
+ CXSourceRange extent;
if (!Dcl)
return;
extent = clang_getDeclExtent(Dcl);