[cfe-commits] r93783 - in /cfe/trunk: include/clang-c/Index.h tools/CIndex/CIndex.cpp tools/c-index-test/c-index-test.c
Douglas Gregor
dgregor at apple.com
Mon Jan 18 14:13:10 PST 2010
Author: dgregor
Date: Mon Jan 18 16:13:09 2010
New Revision: 93783
URL: http://llvm.org/viewvc/llvm-project?rev=93783&view=rev
Log:
Clean up the CIndex API slightly.
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.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/CIndex/CIndex.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=93783&r1=93782&r2=93783&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Jan 18 16:13:09 2010
@@ -339,22 +339,34 @@
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.
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=93783&r1=93782&r2=93783&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Mon Jan 18 16:13:09 2010
@@ -643,7 +643,7 @@
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();
@@ -653,7 +653,7 @@
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;
}
@@ -691,8 +691,9 @@
}
// 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;
}
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=93783&r1=93782&r2=93783&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Jan 18 16:13:09 2010
@@ -74,7 +74,7 @@
static const char *FileCheckPrefix = "CHECK";
static void PrintDeclExtent(CXDecl Dcl) {
- CXSourceExtent extent;
+ CXSourceRange extent;
if (!Dcl)
return;
extent = clang_getDeclExtent(Dcl);
More information about the cfe-commits
mailing list