diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
| commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
| tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /tools/libclang | |
| parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) | |
Notes
Diffstat (limited to 'tools/libclang')
| -rw-r--r-- | tools/libclang/ARCMigrate.cpp | 4 | ||||
| -rw-r--r-- | tools/libclang/CIndex.cpp | 140 | ||||
| -rw-r--r-- | tools/libclang/CIndexCodeCompletion.cpp | 16 | ||||
| -rw-r--r-- | tools/libclang/CIndexer.cpp | 84 | ||||
| -rw-r--r-- | tools/libclang/CIndexer.h | 30 | ||||
| -rw-r--r-- | tools/libclang/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | tools/libclang/CXIndexDataConsumer.cpp | 1 | ||||
| -rw-r--r-- | tools/libclang/CXIndexDataConsumer.h | 2 | ||||
| -rw-r--r-- | tools/libclang/CXTranslationUnit.h | 2 | ||||
| -rw-r--r-- | tools/libclang/CXType.cpp | 9 | ||||
| -rw-r--r-- | tools/libclang/Indexing.cpp | 13 | ||||
| -rw-r--r-- | tools/libclang/libclang.exports | 4 |
12 files changed, 284 insertions, 43 deletions
diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp index 0f2bd06db4b4..ed2ecdb29e7a 100644 --- a/tools/libclang/ARCMigrate.cpp +++ b/tools/libclang/ARCMigrate.cpp @@ -34,7 +34,7 @@ struct Remap { //===----------------------------------------------------------------------===// CXRemapping clang_getRemappings(const char *migrate_dir_path) { -#ifndef CLANG_ENABLE_ARCMT +#if !CLANG_ENABLE_ARCMT llvm::errs() << "error: feature not enabled in this build\n"; return nullptr; #else @@ -77,7 +77,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) { CXRemapping clang_getRemappingsFromFileList(const char **filePaths, unsigned numFiles) { -#ifndef CLANG_ENABLE_ARCMT +#if !CLANG_ENABLE_ARCMT llvm::errs() << "error: feature not enabled in this build\n"; return nullptr; #else diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index d527535a17c1..f4d347108c9f 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -81,6 +81,8 @@ CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx, D->Diagnostics = nullptr; D->OverridenCursorsPool = createOverridenCXCursorsPool(); D->CommentToXML = nullptr; + D->ParsingOptions = 0; + D->Arguments = {}; return D; } @@ -877,6 +879,9 @@ bool CursorVisitor::VisitFieldDecl(FieldDecl *D) { if (Expr *BitWidth = D->getBitWidth()) return Visit(MakeCXCursor(BitWidth, StmtParent, TU, RegionOfInterest)); + if (Expr *Init = D->getInClassInitializer()) + return Visit(MakeCXCursor(Init, StmtParent, TU, RegionOfInterest)); + return false; } @@ -907,7 +912,8 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitFunctionDecl(D->getTemplatedDecl()); + auto* FD = D->getTemplatedDecl(); + return VisitAttributes(FD) || VisitFunctionDecl(FD); } bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) { @@ -916,7 +922,8 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitCXXRecordDecl(D->getTemplatedDecl()); + auto* CD = D->getTemplatedDecl(); + return VisitAttributes(CD) || VisitCXXRecordDecl(CD); } bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { @@ -1020,8 +1027,9 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) { [&SM](Decl *A, Decl *B) { SourceLocation L_A = A->getLocStart(); SourceLocation L_B = B->getLocStart(); - assert(L_A.isValid() && L_B.isValid()); - return SM.isBeforeInTranslationUnit(L_A, L_B); + return L_A != L_B ? + SM.isBeforeInTranslationUnit(L_A, L_B) : + SM.isBeforeInTranslationUnit(A->getLocEnd(), B->getLocEnd()); }); // Now visit the decls. @@ -1742,6 +1750,7 @@ DEFAULT_TYPELOC_IMPL(ConstantArray, ArrayType) DEFAULT_TYPELOC_IMPL(IncompleteArray, ArrayType) DEFAULT_TYPELOC_IMPL(VariableArray, ArrayType) DEFAULT_TYPELOC_IMPL(DependentSizedArray, ArrayType) +DEFAULT_TYPELOC_IMPL(DependentAddressSpace, Type) DEFAULT_TYPELOC_IMPL(DependentSizedExtVector, Type) DEFAULT_TYPELOC_IMPL(Vector, Type) DEFAULT_TYPELOC_IMPL(ExtVector, VectorType) @@ -2281,6 +2290,25 @@ void OMPClauseEnqueue::VisitOMPTaskReductionClause( Visitor->AddStmt(E); } } +void OMPClauseEnqueue::VisitOMPInReductionClause( + const OMPInReductionClause *C) { + VisitOMPClauseList(C); + VisitOMPClauseWithPostUpdate(C); + for (auto *E : C->privates()) { + Visitor->AddStmt(E); + } + for (auto *E : C->lhs_exprs()) { + Visitor->AddStmt(E); + } + for (auto *E : C->rhs_exprs()) { + Visitor->AddStmt(E); + } + for (auto *E : C->reduction_ops()) { + Visitor->AddStmt(E); + } + for (auto *E : C->taskgroup_descriptors()) + Visitor->AddStmt(E); +} void OMPClauseEnqueue::VisitOMPLinearClause(const OMPLinearClause *C) { VisitOMPClauseList(C); VisitOMPClauseWithPostUpdate(C); @@ -2738,6 +2766,8 @@ void EnqueueVisitor::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *D) { void EnqueueVisitor::VisitOMPTaskgroupDirective( const OMPTaskgroupDirective *D) { VisitOMPExecutableDirective(D); + if (const Expr *E = D->getReductionRef()) + VisitStmt(E); } void EnqueueVisitor::VisitOMPFlushDirective(const OMPFlushDirective *D) { @@ -3227,6 +3257,12 @@ unsigned clang_CXIndex_getGlobalOptions(CXIndex CIdx) { return 0; } +void clang_CXIndex_setInvocationEmissionPathOption(CXIndex CIdx, + const char *Path) { + if (CIdx) + static_cast<CIndexer *>(CIdx)->setInvocationEmissionPath(Path ? Path : ""); +} + void clang_toggleCrashRecovery(unsigned isEnabled) { if (isEnabled) llvm::CrashRecoveryContext::Enable(); @@ -3403,6 +3439,11 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename, // faster, trading for a slower (first) reparse. unsigned PrecompilePreambleAfterNParses = !PrecompilePreamble ? 0 : 2 - CreatePreambleOnFirstParse; + + LibclangInvocationReporter InvocationReporter( + *CXXIdx, LibclangInvocationReporter::OperationKind::ParseOperation, + options, llvm::makeArrayRef(*Args), /*InvocationArgs=*/None, + unsaved_files); std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCommandLine( Args->data(), Args->data() + Args->size(), CXXIdx->getPCHContainerOperations(), Diags, @@ -3429,7 +3470,14 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename, return CXError_ASTReadError; *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(Unit)); - return *out_TU ? CXError_Success : CXError_Failure; + if (CXTranslationUnitImpl *TU = *out_TU) { + TU->ParsingOptions = options; + TU->Arguments.reserve(Args->size()); + for (const char *Arg : *Args) + TU->Arguments.push_back(Arg); + return CXError_Success; + } + return CXError_Failure; } CXTranslationUnit @@ -3483,6 +3531,7 @@ enum CXErrorCode clang_parseTranslationUnit2FullArgv( CIdx, source_filename, command_line_args, num_command_line_args, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU); }; + llvm::CrashRecoveryContext CRC; if (!RunSafely(CRC, ParseTranslationUnitImpl)) { @@ -3891,8 +3940,7 @@ int clang_saveTranslationUnit(CXTranslationUnit TU, const char *FileName, result = clang_saveTranslationUnit_Impl(TU, FileName, options); }; - if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred() || - getenv("LIBCLANG_NOTHREADS")) { + if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred()) { SaveTranslationUnitImpl(); if (getenv("LIBCLANG_RESOURCE_USAGE")) @@ -4015,11 +4063,6 @@ int clang_reparseTranslationUnit(CXTranslationUnit TU, TU, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options); }; - if (getenv("LIBCLANG_NOTHREADS")) { - ReparseTranslationUnitImpl(); - return result; - } - llvm::CrashRecoveryContext CRC; if (!RunSafely(CRC, ReparseTranslationUnitImpl)) { @@ -4129,6 +4172,27 @@ CXFile clang_getFile(CXTranslationUnit TU, const char *file_name) { return const_cast<FileEntry *>(FMgr.getFile(file_name)); } +const char *clang_getFileContents(CXTranslationUnit TU, CXFile file, + size_t *size) { + if (isNotUsableTU(TU)) { + LOG_BAD_TU(TU); + return nullptr; + } + + const SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager(); + FileID fid = SM.translateFile(static_cast<FileEntry *>(file)); + bool Invalid = true; + llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid); + if (Invalid) { + if (size) + *size = 0; + return nullptr; + } + if (size) + *size = buf->getBufferSize(); + return buf->getBufferStart(); +} + unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU, CXFile file) { if (isNotUsableTU(TU)) { @@ -4612,6 +4676,20 @@ CXStringSet *clang_Cursor_getCXXManglings(CXCursor C) { return cxstring::createSet(Manglings); } +CXStringSet *clang_Cursor_getObjCManglings(CXCursor C) { + if (clang_isInvalid(C.kind) || !clang_isDeclaration(C.kind)) + return nullptr; + + const Decl *D = getCursorDecl(C); + if (!(isa<ObjCInterfaceDecl>(D) || isa<ObjCImplementationDecl>(D))) + return nullptr; + + ASTContext &Ctx = D->getASTContext(); + index::CodegenNameGenerator CGNameGen(Ctx); + std::vector<std::string> Manglings = CGNameGen.getAllManglings(D); + return cxstring::createSet(Manglings); +} + CXString clang_getCursorDisplayName(CXCursor C) { if (!clang_isDeclaration(C.kind)) return clang_getCursorSpelling(C); @@ -4682,12 +4760,12 @@ CXString clang_getCursorDisplayName(CXCursor C) { // If the type was explicitly written, use that. if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten()) return cxstring::createDup(TSInfo->getType().getAsString(Policy)); - + SmallString<128> Str; llvm::raw_svector_ostream OS(Str); OS << *ClassSpec; - TemplateSpecializationType::PrintTemplateArgumentList( - OS, ClassSpec->getTemplateArgs().asArray(), Policy); + printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(), + Policy); return cxstring::createDup(OS.str()); } @@ -7282,7 +7360,8 @@ static void getCursorPlatformAvailabilityForDecl( std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(), [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) { - return LHS->getPlatform() > RHS->getPlatform(); + return LHS->getPlatform()->getName() < + RHS->getPlatform()->getName(); }); ASTContext &Ctx = D->getASTContext(); auto It = std::unique( @@ -7384,6 +7463,22 @@ CXLanguageKind clang_getCursorLanguage(CXCursor cursor) { return CXLanguage_Invalid; } +CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { + const Decl *D = cxcursor::getCursorDecl(cursor); + if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { + switch (VD->getTLSKind()) { + case VarDecl::TLS_None: + return CXTLS_None; + case VarDecl::TLS_Dynamic: + return CXTLS_Dynamic; + case VarDecl::TLS_Static: + return CXTLS_Static; + } + } + + return CXTLS_None; +} + /// \brief If the given cursor is the "templated" declaration /// descibing a class or function template, return the class or /// function template. @@ -7824,6 +7919,17 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) { return (Method && Method->isVirtual()) ? 1 : 0; } +unsigned clang_CXXRecord_isAbstract(CXCursor C) { + if (!clang_isDeclaration(C.kind)) + return 0; + + const auto *D = cxcursor::getCursorDecl(C); + const auto *RD = dyn_cast_or_null<CXXRecordDecl>(D); + if (RD) + RD = RD->getDefinition(); + return (RD && RD->isAbstract()) ? 1 : 0; +} + unsigned clang_EnumDecl_isScoped(CXCursor C) { if (!clang_isDeclaration(C.kind)) return 0; @@ -8103,7 +8209,7 @@ bool RunSafely(llvm::CrashRecoveryContext &CRC, llvm::function_ref<void()> Fn, unsigned Size) { if (!Size) Size = GetSafetyThreadStackSize(); - if (Size) + if (Size && !getenv("LIBCLANG_NOTHREADS")) return CRC.RunSafelyOnThread(Fn, Size); return CRC.RunSafely(Fn); } diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp index c2b4c0bcb072..d4af0870c0b6 100644 --- a/tools/libclang/CIndexCodeCompletion.cpp +++ b/tools/libclang/CIndexCodeCompletion.cpp @@ -32,6 +32,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Program.h" #include "llvm/Support/Timer.h" @@ -691,6 +692,16 @@ clang_codeCompleteAt_Impl(CXTranslationUnit TU, const char *complete_filename, CaptureCompletionResults Capture(Opts, *Results, &TU); // Perform completion. + std::vector<const char *> CArgs; + for (const auto &Arg : TU->Arguments) + CArgs.push_back(Arg.c_str()); + std::string CompletionInvocation = + llvm::formatv("-code-completion-at={0}:{1}:{2}", complete_filename, + complete_line, complete_column) + .str(); + LibclangInvocationReporter InvocationReporter( + *CXXIdx, LibclangInvocationReporter::OperationKind::CompletionOperation, + TU->ParsingOptions, CArgs, CompletionInvocation, unsaved_files); AST->CodeComplete(complete_filename, complete_line, complete_column, RemappedFiles, (options & CXCodeComplete_IncludeMacros), (options & CXCodeComplete_IncludeCodePatterns), @@ -806,11 +817,6 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options); }; - if (getenv("LIBCLANG_NOTHREADS")) { - CodeCompleteAtImpl(); - return result; - } - llvm::CrashRecoveryContext CRC; if (!RunSafely(CRC, CodeCompleteAtImpl)) { diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp index 694ed606306c..62ea88172069 100644 --- a/tools/libclang/CIndexer.cpp +++ b/tools/libclang/CIndexer.cpp @@ -12,10 +12,14 @@ //===----------------------------------------------------------------------===// #include "CIndexer.h" +#include "CXString.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Version.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/MD5.h" +#include "llvm/Support/MutexGuard.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" #include <cstdio> @@ -76,3 +80,83 @@ const std::string &CIndexer::getClangResourcesPath() { ResourcesPath = LibClangPath.str(); return ResourcesPath; } + +StringRef CIndexer::getClangToolchainPath() { + if (!ToolchainPath.empty()) + return ToolchainPath; + StringRef ResourcePath = getClangResourcesPath(); + ToolchainPath = llvm::sys::path::parent_path( + llvm::sys::path::parent_path(llvm::sys::path::parent_path(ResourcePath))); + return ToolchainPath; +} + +LibclangInvocationReporter::LibclangInvocationReporter( + CIndexer &Idx, OperationKind Op, unsigned ParseOptions, + llvm::ArrayRef<const char *> Args, + llvm::ArrayRef<std::string> InvocationArgs, + llvm::ArrayRef<CXUnsavedFile> UnsavedFiles) { + StringRef Path = Idx.getInvocationEmissionPath(); + if (Path.empty()) + return; + + // Create a temporary file for the invocation log. + SmallString<256> TempPath; + TempPath = Path; + llvm::sys::path::append(TempPath, "libclang-%%%%%%%%%%%%"); + int FD; + if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath)) + return; + File = std::string(TempPath.begin(), TempPath.end()); + llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true); + + // Write out the information about the invocation to it. + auto WriteStringKey = [&OS](StringRef Key, StringRef Value) { + OS << R"(")" << Key << R"(":")"; + OS << Value << '"'; + }; + OS << '{'; + WriteStringKey("toolchain", Idx.getClangToolchainPath()); + OS << ','; + WriteStringKey("libclang.operation", + Op == OperationKind::ParseOperation ? "parse" : "complete"); + OS << ','; + OS << R"("libclang.opts":)" << ParseOptions; + OS << ','; + OS << R"("args":[)"; + for (const auto &I : llvm::enumerate(Args)) { + if (I.index()) + OS << ','; + OS << '"' << I.value() << '"'; + } + if (!InvocationArgs.empty()) { + OS << R"(],"invocation-args":[)"; + for (const auto &I : llvm::enumerate(InvocationArgs)) { + if (I.index()) + OS << ','; + OS << '"' << I.value() << '"'; + } + } + if (!UnsavedFiles.empty()) { + OS << R"(],"unsaved_file_hashes":[)"; + for (const auto &UF : llvm::enumerate(UnsavedFiles)) { + if (UF.index()) + OS << ','; + OS << '{'; + WriteStringKey("name", UF.value().Filename); + OS << ','; + llvm::MD5 Hash; + Hash.update(getContents(UF.value())); + llvm::MD5::MD5Result Result; + Hash.final(Result); + SmallString<32> Digest = Result.digest(); + WriteStringKey("md5", Digest); + OS << '}'; + } + } + OS << "]}"; +} + +LibclangInvocationReporter::~LibclangInvocationReporter() { + if (!File.empty()) + llvm::sys::fs::remove(File); +} diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h index b227f943f7b3..6c46eed4fb98 100644 --- a/tools/libclang/CIndexer.h +++ b/tools/libclang/CIndexer.h @@ -18,6 +18,7 @@ #include "clang-c/Index.h" #include "clang/Frontend/PCHContainerOperations.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Mutex.h" #include <utility> namespace llvm { @@ -40,6 +41,10 @@ class CIndexer { std::string ResourcesPath; std::shared_ptr<PCHContainerOperations> PCHContainerOps; + std::string ToolchainPath; + + std::string InvocationEmissionPath; + public: CIndexer(std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<PCHContainerOperations>()) @@ -71,6 +76,31 @@ public: /// \brief Get the path of the clang resource files. const std::string &getClangResourcesPath(); + + StringRef getClangToolchainPath(); + + void setInvocationEmissionPath(StringRef Str) { + InvocationEmissionPath = Str; + } + + StringRef getInvocationEmissionPath() const { return InvocationEmissionPath; } +}; + +/// Logs information about a particular libclang operation like parsing to +/// a new file in the invocation emission path. +class LibclangInvocationReporter { +public: + enum class OperationKind { ParseOperation, CompletionOperation }; + + LibclangInvocationReporter(CIndexer &Idx, OperationKind Op, + unsigned ParseOptions, + llvm::ArrayRef<const char *> Args, + llvm::ArrayRef<std::string> InvocationArgs, + llvm::ArrayRef<CXUnsavedFile> UnsavedFiles); + ~LibclangInvocationReporter(); + +private: + std::string File; }; /// \brief Return the current size to request for "safety". diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt index 2dd670307636..44406378207b 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt @@ -51,6 +51,9 @@ if (TARGET clangTidyPlugin) add_definitions(-DCLANG_TOOL_EXTRA_BUILD) list(APPEND LIBS clangTidyPlugin) list(APPEND LIBS clangIncludeFixerPlugin) + if(LLVM_ENABLE_MODULES) + list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD") + endif() endif () find_library(DL_LIBRARY_PATH dl) @@ -115,6 +118,12 @@ if(ENABLE_SHARED) PROPERTIES VERSION ${LIBCLANG_LIBRARY_VERSION} DEFINE_SYMBOL _CINDEX_LIB_) + # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32. + if(LLVM_ENABLE_MODULES AND NOT WIN32) + target_compile_options(libclang PRIVATE + "-fmodules-ignore-macro=_CINDEX_LIB_" + ) + endif() endif() endif() @@ -132,10 +141,13 @@ install(DIRECTORY ../../include/clang-c PATTERN ".svn" EXCLUDE ) +# LLVM_DISTRIBUTION_COMPONENTS requires that each component have both a +# component and an install-component target, so add a dummy libclang-headers +# target to allow using it in LLVM_DISTRIBUTION_COMPONENTS. +add_custom_target(libclang-headers) +set_target_properties(libclang-headers PROPERTIES FOLDER "Misc") + if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's. - add_custom_target(install-libclang-headers - DEPENDS - COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=libclang-headers - -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + add_llvm_install_targets(install-libclang-headers + COMPONENT libclang-headers) endif() diff --git a/tools/libclang/CXIndexDataConsumer.cpp b/tools/libclang/CXIndexDataConsumer.cpp index a2ef68be49de..ffe5c486ddda 100644 --- a/tools/libclang/CXIndexDataConsumer.cpp +++ b/tools/libclang/CXIndexDataConsumer.cpp @@ -1258,6 +1258,7 @@ static CXIdxEntityKind getEntityKindFromSymbolKind(SymbolKind K, SymbolLanguage case SymbolKind::Module: case SymbolKind::Macro: case SymbolKind::ClassProperty: + case SymbolKind::Using: return CXIdxEntity_Unexposed; case SymbolKind::Enum: return CXIdxEntity_Enum; diff --git a/tools/libclang/CXIndexDataConsumer.h b/tools/libclang/CXIndexDataConsumer.h index 16162cb83f77..a54baadd0774 100644 --- a/tools/libclang/CXIndexDataConsumer.h +++ b/tools/libclang/CXIndexDataConsumer.h @@ -342,7 +342,7 @@ public: CXTranslationUnit getCXTU() const { return CXTU; } void setASTContext(ASTContext &ctx); - void setPreprocessor(std::shared_ptr<Preprocessor> PP); + void setPreprocessor(std::shared_ptr<Preprocessor> PP) override; bool shouldSuppressRefs() const { return IndexOptions & CXIndexOpt_SuppressRedundantRefs; diff --git a/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h index ce8469b501af..590142f30f12 100644 --- a/tools/libclang/CXTranslationUnit.h +++ b/tools/libclang/CXTranslationUnit.h @@ -33,6 +33,8 @@ struct CXTranslationUnitImpl { void *Diagnostics; void *OverridenCursorsPool; clang::index::CommentToXMLConverter *CommentToXML; + unsigned ParsingOptions; + std::vector<std::string> Arguments; }; struct CXTargetInfoImpl { diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index d2cb50905915..dfc015247768 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -53,6 +53,7 @@ static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) { BTCASE(Float); BTCASE(Double); BTCASE(LongDouble); + BTCASE(Float16); BTCASE(Float128); BTCASE(NullPtr); BTCASE(Overload); @@ -402,7 +403,10 @@ unsigned clang_getAddressSpace(CXType CT) { if (T.getAddressSpace() >= LangAS::FirstTargetAddressSpace) { return T.getQualifiers().getAddressSpaceAttributePrintValue(); } - return T.getAddressSpace(); + // FIXME: this function returns either a LangAS or a target AS + // Those values can overlap which makes this function rather unpredictable + // for any caller + return (unsigned)T.getAddressSpace(); } CXString clang_getTypedefName(CXType CT) { @@ -520,7 +524,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { TKIND(Char_U); TKIND(UChar); TKIND(Char16); - TKIND(Char32); + TKIND(Char32); TKIND(UShort); TKIND(UInt); TKIND(ULong); @@ -538,6 +542,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { TKIND(Float); TKIND(Double); TKIND(LongDouble); + TKIND(Float16); TKIND(Float128); TKIND(NullPtr); TKIND(Overload); diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 5312b7c0169c..021ebcfcfe43 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -272,7 +272,8 @@ public: /// SourceRangeSkipped - This hook is called when a source range is skipped. /// \param Range The SourceRange that was skipped. The range begins at the /// #if/#else directive and ends after the #endif/#else directive. - void SourceRangeSkipped(SourceRange Range) override {} + void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override { + } }; //===----------------------------------------------------------------------===// @@ -879,11 +880,6 @@ int clang_indexSourceFileFullArgv( TU_options); }; - if (getenv("LIBCLANG_NOTHREADS")) { - IndexSourceFileImpl(); - return result; - } - llvm::CrashRecoveryContext CRC; if (!RunSafely(CRC, IndexSourceFileImpl)) { @@ -933,11 +929,6 @@ int clang_indexTranslationUnit(CXIndexAction idxAction, index_options, TU); }; - if (getenv("LIBCLANG_NOTHREADS")) { - IndexTranslationUnitImpl(); - return result; - } - llvm::CrashRecoveryContext CRC; if (!RunSafely(CRC, IndexTranslationUnitImpl)) { diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index e0d178a5291a..4d3a029567d4 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -2,6 +2,7 @@ clang_CXCursorSet_contains clang_CXCursorSet_insert clang_CXIndex_getGlobalOptions clang_CXIndex_setGlobalOptions +clang_CXIndex_setInvocationEmissionPathOption clang_CXXConstructor_isConvertingConstructor clang_CXXConstructor_isCopyConstructor clang_CXXConstructor_isDefaultConstructor @@ -12,6 +13,7 @@ clang_CXXMethod_isConst clang_CXXMethod_isPureVirtual clang_CXXMethod_isStatic clang_CXXMethod_isVirtual +clang_CXXRecord_isAbstract clang_EnumDecl_isScoped clang_Cursor_getArgument clang_Cursor_getNumTemplateArguments @@ -23,6 +25,7 @@ clang_Cursor_getBriefCommentText clang_Cursor_getCommentRange clang_Cursor_getCXXManglings clang_Cursor_getMangling +clang_Cursor_getObjCManglings clang_Cursor_getParsedComment clang_Cursor_getRawCommentText clang_Cursor_getNumArguments @@ -189,6 +192,7 @@ clang_getCursorReferenced clang_getCursorResultType clang_getCursorSemanticParent clang_getCursorSpelling +clang_getCursorTLSKind clang_getCursorType clang_getCursorUSR clang_getCursorVisibility |
