mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Fix some more warnings from clang
This commit is contained in:
parent
8910d0a13e
commit
c66c927c1f
@ -1,54 +0,0 @@
|
|||||||
cmake_minimum_required (VERSION 3.3.1)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Project configuration
|
|
||||||
#
|
|
||||||
project (SuperClangIndex)
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
file(GLOB SOURCE_FILES *.cc *.cpp libclangmm/*.cc)
|
|
||||||
find_program(llvm_config llvm-config-3.8)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Find clang library and include directories
|
|
||||||
#
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${llvm_config} --includedir
|
|
||||||
OUTPUT_VARIABLE LIBCLANG_INCLUDEDIR)
|
|
||||||
string(STRIP "${LIBCLANG_INCLUDEDIR}" LIBCLANG_INCLUDEDIR)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${llvm_config} --libdir
|
|
||||||
OUTPUT_VARIABLE LIBCLANG_LIBDIR)
|
|
||||||
string(STRIP "${LIBCLANG_LIBDIR}" LIBCLANG_LIBDIR)
|
|
||||||
|
|
||||||
find_library(LIBCLANG_LIBRARIES NAMES libclang clang
|
|
||||||
PATHS ${LIBCLANG_LIBDIR})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(LIBCLANG_INCLUDEDIR "/usr/local/google/home/jdufault/super-clang-index/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04/include")
|
|
||||||
set(LIBCLANG_LIBDIR "/usr/local/google/home/jdufault/super-clang-index/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04/lib")
|
|
||||||
set(LIBCLANG_LIBRARIES "/usr/local/google/home/jdufault/super-clang-index/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04/lib/libclang.so")
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Debugging
|
|
||||||
#
|
|
||||||
#message("SOURCE_FILES: " ${SOURCE_FILES} )
|
|
||||||
message("LIBCLANG_INCLUDEDIR: " ${LIBCLANG_INCLUDEDIR})
|
|
||||||
message("LIBCLANG_LIBDIR: " ${LIBCLANG_LIBDIR})
|
|
||||||
message("LIBCLANG_LIBRARIES: " ${LIBCLANG_LIBRARIES})
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Setup output binary.
|
|
||||||
#
|
|
||||||
include_directories("${PROJECT_SOURCE_DIR}/third_party/rapidjson/include")
|
|
||||||
include_directories("${LIBCLANG_INCLUDEDIR}")
|
|
||||||
|
|
||||||
add_executable (indexer ${SOURCE_FILES})
|
|
||||||
target_link_libraries(indexer ${LIBCLANG_LIBRARIES})
|
|
@ -57,16 +57,18 @@ const int kExpectedClientVersion = 1;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if false
|
||||||
std::string FormatMicroseconds(long long microseconds) {
|
std::string FormatMicroseconds(long long microseconds) {
|
||||||
long long milliseconds = microseconds / 1000;
|
long long milliseconds = microseconds / 1000;
|
||||||
long long remaining = microseconds - milliseconds;
|
long long remaining = microseconds - milliseconds;
|
||||||
|
|
||||||
// Only show two digits after the dot.
|
// Only show two digits after the dot.
|
||||||
while (remaining >= 100)
|
while (remaining >= 100)
|
||||||
remaining /= 10;
|
remaining /= 10;
|
||||||
|
|
||||||
return std::to_string(milliseconds) + "." + std::to_string(remaining) + "ms";
|
return std::to_string(milliseconds) + "." + std::to_string(remaining) + "ms";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,15 +88,15 @@ return std::to_string(milliseconds) + "." + std::to_string(remaining) + "ms";
|
|||||||
// the user erases a character. vscode will resend the completion request if
|
// the user erases a character. vscode will resend the completion request if
|
||||||
// that happens.
|
// that happens.
|
||||||
struct CodeCompleteCache {
|
struct CodeCompleteCache {
|
||||||
optional<std::string> cached_path;
|
optional<std::string> cached_path;
|
||||||
optional<lsPosition> cached_completion_position;
|
optional<lsPosition> cached_completion_position;
|
||||||
NonElidedVector<lsCompletionItem> cached_results;
|
NonElidedVector<lsCompletionItem> cached_results;
|
||||||
NonElidedVector<lsDiagnostic> cached_diagnostics;
|
NonElidedVector<lsDiagnostic> cached_diagnostics;
|
||||||
|
|
||||||
bool IsCacheValid(lsTextDocumentPositionParams position) const {
|
bool IsCacheValid(lsTextDocumentPositionParams position) const {
|
||||||
return cached_path == position.textDocument.uri.GetPath() &&
|
return cached_path == position.textDocument.uri.GetPath() &&
|
||||||
cached_completion_position == position.position;
|
cached_completion_position == position.position;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -467,6 +469,8 @@ std::vector<QueryLocation> GetDeclarationsOfSymbolForGotoDefinition(QueryDatabas
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include_completion.h"
|
#include "include_completion.h"
|
||||||
|
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
@ -8,6 +6,8 @@
|
|||||||
#include "standard_includes.h"
|
#include "standard_includes.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string ElideLongPath(Config* config, const std::string& path) {
|
std::string ElideLongPath(Config* config, const std::string& path) {
|
||||||
@ -96,7 +96,7 @@ lsCompletionItem BuildCompletionItem(Config* config, std::string path, bool use_
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
IncludeCompletion::IncludeCompletion(Config* config, Project* project)
|
IncludeCompletion::IncludeCompletion(Config* config, Project* project)
|
||||||
: config_(config), project_(project), is_scanning(false) {}
|
: is_scanning(false), config_(config), project_(project) {}
|
||||||
|
|
||||||
void IncludeCompletion::Rescan() {
|
void IncludeCompletion::Rescan() {
|
||||||
if (is_scanning)
|
if (is_scanning)
|
||||||
|
@ -412,6 +412,8 @@ clang::VisiterResult FindTypeVisitor(clang::Cursor cursor,
|
|||||||
case CXCursor_TemplateRef:
|
case CXCursor_TemplateRef:
|
||||||
*result = cursor;
|
*result = cursor;
|
||||||
return clang::VisiterResult::Break;
|
return clang::VisiterResult::Break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clang::VisiterResult::Recurse;
|
return clang::VisiterResult::Recurse;
|
||||||
@ -485,7 +487,7 @@ clang::VisiterResult VisitDeclForTypeUsageVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
param->previous_cursor = cursor;
|
param->previous_cursor = cursor;
|
||||||
break;
|
return clang::VisiterResult::Continue;
|
||||||
|
|
||||||
// We do not want to recurse for everything, since if we do that we will end
|
// We do not want to recurse for everything, since if we do that we will end
|
||||||
// up visiting method definition bodies/etc. Instead, we only recurse for
|
// up visiting method definition bodies/etc. Instead, we only recurse for
|
||||||
@ -501,6 +503,9 @@ clang::VisiterResult VisitDeclForTypeUsageVisitor(
|
|||||||
case CXCursor_CXXStaticCastExpr:
|
case CXCursor_CXXStaticCastExpr:
|
||||||
case CXCursor_CXXReinterpretCastExpr:
|
case CXCursor_CXXReinterpretCastExpr:
|
||||||
return clang::VisiterResult::Recurse;
|
return clang::VisiterResult::Recurse;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return clang::VisiterResult::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clang::VisiterResult::Continue;
|
return clang::VisiterResult::Continue;
|
||||||
@ -684,7 +689,7 @@ clang::VisiterResult AddDeclInitializerUsagesVisitor(clang::Cursor cursor,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
switch (cursor.get_kind()) {
|
switch (cursor.get_kind()) {
|
||||||
case CXCursor_DeclRefExpr:
|
case CXCursor_DeclRefExpr: {
|
||||||
if (cursor.get_referenced().get_kind() != CXCursor_VarDecl)
|
if (cursor.get_referenced().get_kind() != CXCursor_VarDecl)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -710,6 +715,10 @@ clang::VisiterResult AddDeclInitializerUsagesVisitor(clang::Cursor cursor,
|
|||||||
IndexVar* ref_def = db->Resolve(ref_id);
|
IndexVar* ref_def = db->Resolve(ref_id);
|
||||||
UniqueAdd(ref_def->uses, loc);
|
UniqueAdd(ref_def->uses, loc);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clang::VisiterResult::Recurse;
|
return clang::VisiterResult::Recurse;
|
||||||
@ -735,7 +744,7 @@ bool AreEqualLocations(CXIdxLoc loc, CXCursor cursor) {
|
|||||||
clang::VisiterResult VisitMacroDefinitionAndExpansions(clang::Cursor cursor, clang::Cursor parent, IndexParam* param) {
|
clang::VisiterResult VisitMacroDefinitionAndExpansions(clang::Cursor cursor, clang::Cursor parent, IndexParam* param) {
|
||||||
switch (cursor.get_kind()) {
|
switch (cursor.get_kind()) {
|
||||||
case CXCursor_MacroDefinition:
|
case CXCursor_MacroDefinition:
|
||||||
case CXCursor_MacroExpansion:
|
case CXCursor_MacroExpansion: {
|
||||||
// Resolve location, find IndexFile instance.
|
// Resolve location, find IndexFile instance.
|
||||||
CXSourceRange cx_source_range = clang_Cursor_getSpellingNameRange(cursor.cx_cursor, 0, 0);
|
CXSourceRange cx_source_range = clang_Cursor_getSpellingNameRange(cursor.cx_cursor, 0, 0);
|
||||||
CXSourceLocation start = clang_getRangeStart(cx_source_range);
|
CXSourceLocation start = clang_getRangeStart(cx_source_range);
|
||||||
@ -769,6 +778,9 @@ clang::VisiterResult VisitMacroDefinitionAndExpansions(clang::Cursor cursor, cla
|
|||||||
var_def->def.definition_extent = ResolveExtent(cursor.cx_cursor);;
|
var_def->def.definition_extent = ResolveExtent(cursor.cx_cursor);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1052,6 +1064,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
// AddInterestingUsageToType(db, arg_type,
|
// AddInterestingUsageToType(db, arg_type,
|
||||||
// FindLocationOfTypeSpecifier(arg));
|
// FindLocationOfTypeSpecifier(arg));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1222,6 +1236,9 @@ bool IsFunctionCallContext(CXCursorKind kind) {
|
|||||||
// TODO: we need to test lambdas
|
// TODO: we need to test lambdas
|
||||||
case CXCursor_LambdaExpr:
|
case CXCursor_LambdaExpr:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -44,6 +44,8 @@ Type Type::strip_qualifiers() const {
|
|||||||
case CXType_LValueReference:
|
case CXType_LValueReference:
|
||||||
case CXType_Pointer:
|
case CXType_Pointer:
|
||||||
return clang_getPointeeType(cx_type);
|
return clang_getPointeeType(cx_type);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cx_type;
|
return cx_type;
|
||||||
@ -118,7 +120,7 @@ CXCursorKind Cursor::get_kind() const {
|
|||||||
|
|
||||||
Cursor Cursor::get_declaration() const {
|
Cursor Cursor::get_declaration() const {
|
||||||
Type type = get_type();
|
Type type = get_type();
|
||||||
|
|
||||||
// auto x = new Foo() will not be deduced to |Foo| if we do not use the
|
// auto x = new Foo() will not be deduced to |Foo| if we do not use the
|
||||||
// canonical type. However, a canonical type will look past typedefs so we
|
// canonical type. However, a canonical type will look past typedefs so we
|
||||||
// will not accurately report variables on typedefs if we always do this.
|
// will not accurately report variables on typedefs if we always do this.
|
||||||
|
@ -326,6 +326,8 @@ std::string clang::ToString(CXCursorKind kind) {
|
|||||||
// case CXCursor_FirstExtraDecl: return "FirstExtraDecl";
|
// case CXCursor_FirstExtraDecl: return "FirstExtraDecl";
|
||||||
case CXCursor_LastExtraDecl:
|
case CXCursor_LastExtraDecl:
|
||||||
return "LastExtraDecl";
|
return "LastExtraDecl";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return "<unknown kind>";
|
return "<unknown kind>";
|
||||||
}
|
}
|
||||||
|
@ -625,6 +625,8 @@ void QueryDatabase::RemoveUsrs(SymbolKind usr_kind, const std::vector<Usr>& to_r
|
|||||||
vars[usr_to_var[usr].id] = nullopt;
|
vars[usr_to_var[usr].id] = nullopt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SymbolKind::Invalid:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user