summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-03 00:35:38 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-03 00:35:38 +0000
commit15417cfa56242d05f55e36da9de966ed469098f6 (patch)
tree3e58bf6edaaf7c07591af31c79d68e706abe509b /clang/tools
parent3e6c91946947050972b1ac929987e85e67ccf49d (diff)
downloadbcm5719-llvm-15417cfa56242d05f55e36da9de966ed469098f6.tar.gz
bcm5719-llvm-15417cfa56242d05f55e36da9de966ed469098f6.zip
Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a clang_getCursor()-related issue with CXXFunctionalCastExprs with CXXConstructExprs as children (see FIXME in the test case); I'll look at that separately. llvm-svn: 118132
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/libclang/CIndex.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index d825a400f99..e07c25d77a2 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -1748,7 +1748,8 @@ bool CursorVisitor::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
bool CursorVisitor::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
if (TypeSourceInfo *TSInfo = E->getTypeSourceInfo())
- return Visit(TSInfo->getTypeLoc());
+ if (Visit(TSInfo->getTypeLoc()))
+ return true;
return VisitExpr(E);
}
@@ -2849,6 +2850,7 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
if (SLoc.isInvalid())
return clang_getNullCursor();
+ bool Logging = getenv("LIBCLANG_LOGGING");
SLoc = Lexer::GetBeginningOfToken(SLoc, CXXUnit->getSourceManager(),
CXXUnit->getASTContext().getLangOptions());
@@ -2862,6 +2864,31 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
Decl::MaxPCHLevel, SourceLocation(SLoc));
CursorVis.VisitChildren(Parent);
}
+
+ if (Logging) {
+ CXFile SearchFile;
+ unsigned SearchLine, SearchColumn;
+ CXFile ResultFile;
+ unsigned ResultLine, ResultColumn;
+ CXString SearchFileName, ResultFileName, KindSpelling;
+ CXSourceLocation ResultLoc = clang_getCursorLocation(Result);
+
+ clang_getInstantiationLocation(Loc, &SearchFile, &SearchLine, &SearchColumn,
+ 0);
+ clang_getInstantiationLocation(ResultLoc, &ResultFile, &ResultLine,
+ &ResultColumn, 0);
+ SearchFileName = clang_getFileName(SearchFile);
+ ResultFileName = clang_getFileName(ResultFile);
+ KindSpelling = clang_getCursorKindSpelling(Result.kind);
+ fprintf(stderr, "clang_getCursor(%s:%d:%d) = %s(%s:%d:%d)\n",
+ clang_getCString(SearchFileName), SearchLine, SearchColumn,
+ clang_getCString(KindSpelling),
+ clang_getCString(ResultFileName), ResultLine, ResultColumn);
+ clang_disposeString(SearchFileName);
+ clang_disposeString(ResultFileName);
+ clang_disposeString(KindSpelling);
+ }
+
return Result;
}
OpenPOWER on IntegriCloud