From 5600989a421f64398316292ff54e14c80b8f086c Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 18 Dec 2017 13:48:32 -0800 Subject: [PATCH] [indexer] Treat explicit destructor call as not `is_implicit` (#159) Also fixed an unused warning. --- src/indexer.cc | 4 ++++ src/platform_posix.cc | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 575613e3..4ced5a75 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1443,6 +1443,10 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { // or implicit), but libclang only supports implicit for objective-c. bool is_implicit = CanBeCalledImplicitly(ref->referencedEntity->kind) && + // For explicit destructor call, ref->cursor may be "~" while called->def.short_name is "~A" + // "~A" is not a substring of ref->cursor, but we should take this case as not `is_implicit`. + called->def.short_name.size() && called->def.short_name[0] != '~' && + !CursorSpellingContainsString(ref->cursor, param->tu->cx_tu, called->def.short_name); diff --git a/src/platform_posix.cc b/src/platform_posix.cc index 6be1097d..fd883a01 100644 --- a/src/platform_posix.cc +++ b/src/platform_posix.cc @@ -342,9 +342,7 @@ out_error: bool IsSymLink(const std::string& path) { struct stat buf; - int result; - result = lstat(path.c_str(), &buf); - return S_ISLNK(buf.st_mode); + return lstat(path.c_str(), &buf) == 0 && S_ISLNK(buf.st_mode); } std::vector GetPlatformClangArguments() {