diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /tools/libclang | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang')
34 files changed, 252 insertions, 180 deletions
diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp index ed2ecdb29e..da8a7e4b91 100644 --- a/tools/libclang/ARCMigrate.cpp +++ b/tools/libclang/ARCMigrate.cpp @@ -1,9 +1,8 @@ //===- ARCMigrate.cpp - Clang-C ARC Migration Library ---------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/BuildSystem.cpp b/tools/libclang/BuildSystem.cpp index 6c1f2c145b..0d69dcf172 100644 --- a/tools/libclang/BuildSystem.cpp +++ b/tools/libclang/BuildSystem.cpp @@ -1,9 +1,8 @@ //===- BuildSystem.cpp - Utilities for use by build systems ---------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index a9c3077e5f..d7eee5e684 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1,9 +1,8 @@ //===- CIndex.cpp - Clang-C Source Indexing Library -----------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -172,7 +171,6 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM, static SourceRange getRawCursorExtent(CXCursor C); static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr); - RangeComparisonResult CursorVisitor::CompareRegionOfInterest(SourceRange R) { return RangeCompare(AU->getSourceManager(), R, RegionOfInterest); } @@ -2169,6 +2167,10 @@ void OMPClauseEnqueue::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { Visitor->AddStmt(C->getSimdlen()); } +void OMPClauseEnqueue::VisitOMPAllocatorClause(const OMPAllocatorClause *C) { + Visitor->AddStmt(C->getAllocator()); +} + void OMPClauseEnqueue::VisitOMPCollapseClause(const OMPCollapseClause *C) { Visitor->AddStmt(C->getNumForLoops()); } @@ -2260,6 +2262,10 @@ void OMPClauseEnqueue::VisitOMPClauseList(T *Node) { } } +void OMPClauseEnqueue::VisitOMPAllocateClause(const OMPAllocateClause *C) { + VisitOMPClauseList(C); + Visitor->AddStmt(C->getAllocator()); +} void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) { VisitOMPClauseList(C); for (const auto *E : C->private_copies()) { @@ -2473,7 +2479,7 @@ void EnqueueVisitor::VisitCXXNewExpr(const CXXNewExpr *E) { // Enqueue the initializer , if any. AddStmt(E->getInitializer()); // Enqueue the array size, if any. - AddStmt(E->getArraySize()); + AddStmt(E->getArraySize().getValueOr(nullptr)); // Enqueue the allocated type. AddTypeLoc(E->getAllocatedTypeSourceInfo()); // Enqueue the placement arguments. @@ -3409,7 +3415,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename, Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions)); if (options & CXTranslationUnit_KeepGoing) - Diags->setSuppressAfterFatalError(false); + Diags->setFatalsAsError(true); // Recover resources if we crash before exiting this function. llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine, @@ -4221,7 +4227,7 @@ const char *clang_getFileContents(CXTranslationUnit TU, CXFile file, 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); + const llvm::MemoryBuffer *buf = SM.getBuffer(fid, &Invalid); if (Invalid) { if (size) *size = 0; @@ -5474,7 +5480,15 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) { case CXCursor_StaticAssert: return cxstring::createRef("StaticAssert"); case CXCursor_FriendDecl: - return cxstring::createRef("FriendDecl"); + return cxstring::createRef("FriendDecl"); + case CXCursor_ConvergentAttr: + return cxstring::createRef("attribute(convergent)"); + case CXCursor_WarnUnusedAttr: + return cxstring::createRef("attribute(warn_unused)"); + case CXCursor_WarnUnusedResultAttr: + return cxstring::createRef("attribute(warn_unused_result)"); + case CXCursor_AlignedAttr: + return cxstring::createRef("attribute(aligned)"); } llvm_unreachable("Unhandled CXCursorKind"); @@ -6228,7 +6242,9 @@ CXCursor clang_getCursorDefinition(CXCursor C) { case Decl::CXXDeductionGuide: case Decl::Import: case Decl::OMPThreadPrivate: + case Decl::OMPAllocate: case Decl::OMPDeclareReduction: + case Decl::OMPDeclareMapper: case Decl::OMPRequires: case Decl::ObjCTypeParam: case Decl::BuiltinTemplate: @@ -8361,7 +8377,7 @@ unsigned clang_CXXMethod_isConst(CXCursor C) { const Decl *D = cxcursor::getCursorDecl(C); const CXXMethodDecl *Method = D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr; - return (Method && Method->getTypeQualifiers().hasConst()) ? 1 : 0; + return (Method && Method->getMethodQualifiers().hasConst()) ? 1 : 0; } unsigned clang_CXXMethod_isDefaulted(CXCursor C) { @@ -8706,8 +8722,8 @@ void clang::setThreadBackgroundPriority() { if (getenv("LIBCLANG_BGPRIO_DISABLE")) return; -#ifdef USE_DARWIN_THREADS - setpriority(PRIO_DARWIN_THREAD, 0, PRIO_DARWIN_BG); +#if LLVM_ENABLE_THREADS + llvm::set_thread_priority(llvm::ThreadPriority::Background); #endif } diff --git a/tools/libclang/CIndexCXX.cpp b/tools/libclang/CIndexCXX.cpp index 028b64a2b2..a06fe7ba4a 100644 --- a/tools/libclang/CIndexCXX.cpp +++ b/tools/libclang/CIndexCXX.cpp @@ -1,9 +1,8 @@ //===- CIndexCXX.cpp - Clang-C Source Indexing Library --------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp index c5cece52ac..1588812802 100644 --- a/tools/libclang/CIndexCodeCompletion.cpp +++ b/tools/libclang/CIndexCodeCompletion.cpp @@ -1,9 +1,8 @@ //===- CIndexCodeCompletion.cpp - Code Completion API hooks ---------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -569,9 +568,8 @@ namespace { CaptureCompletionResults(const CodeCompleteOptions &Opts, AllocatedCXCodeCompleteResults &Results, CXTranslationUnit *TranslationUnit) - : CodeCompleteConsumer(Opts, false), - AllocatedResults(Results), CCTUInfo(Results.CodeCompletionAllocator), - TU(TranslationUnit) { } + : CodeCompleteConsumer(Opts), AllocatedResults(Results), + CCTUInfo(Results.CodeCompletionAllocator), TU(TranslationUnit) {} ~CaptureCompletionResults() override { Finish(); } void ProcessCodeCompleteResults(Sema &S, diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp index a4e75e2aae..6dfdf2d2f9 100644 --- a/tools/libclang/CIndexDiagnostic.cpp +++ b/tools/libclang/CIndexDiagnostic.cpp @@ -1,15 +1,15 @@ -/*===-- CIndexDiagnostics.cpp - Diagnostics C Interface ---------*- C++ -*-===*\ -|* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* Implements the diagnostic functions of the Clang C interface. *| -|* *| -\*===----------------------------------------------------------------------===*/ +//===- CIndexDiagnostic.cpp - Diagnostics C Interface ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Implements the diagnostic functions of the Clang C interface. +// +//===----------------------------------------------------------------------===// + #include "CIndexDiagnostic.h" #include "CIndexer.h" #include "CXTranslationUnit.h" diff --git a/tools/libclang/CIndexDiagnostic.h b/tools/libclang/CIndexDiagnostic.h index e865df0894..25589bb574 100644 --- a/tools/libclang/CIndexDiagnostic.h +++ b/tools/libclang/CIndexDiagnostic.h @@ -1,9 +1,9 @@ /*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\ |* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |* *| |*===----------------------------------------------------------------------===*| |* *| diff --git a/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp index a9cd2cac42..04699ccb01 100644 --- a/tools/libclang/CIndexHigh.cpp +++ b/tools/libclang/CIndexHigh.cpp @@ -1,9 +1,8 @@ //===- CIndexHigh.cpp - Higher level API functions ------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -110,16 +109,14 @@ struct FindFileIdRefVisitData { private: bool isOverriddingMethod(const Decl *D) const { - if (std::find(TopMethods.begin(), TopMethods.end(), D) != - TopMethods.end()) + if (llvm::find(TopMethods, D) != TopMethods.end()) return true; TopMethodsTy methods; getTopOverriddenMethods(TU, D, methods); for (TopMethodsTy::iterator I = methods.begin(), E = methods.end(); I != E; ++I) { - if (std::find(TopMethods.begin(), TopMethods.end(), *I) != - TopMethods.end()) + if (llvm::find(TopMethods, *I) != TopMethods.end()) return true; } diff --git a/tools/libclang/CIndexInclusionStack.cpp b/tools/libclang/CIndexInclusionStack.cpp index 4b021fc4cb..f1c5b53c5e 100644 --- a/tools/libclang/CIndexInclusionStack.cpp +++ b/tools/libclang/CIndexInclusionStack.cpp @@ -1,9 +1,8 @@ //===- CIndexInclusionStack.cpp - Clang-C Source Indexing Library ---------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp index 7cd7b6f1cd..75bb3b0129 100644 --- a/tools/libclang/CIndexUSRs.cpp +++ b/tools/libclang/CIndexUSRs.cpp @@ -1,9 +1,8 @@ -//===- CIndexUSR.cpp - Clang-C Source Indexing Library --------------------===// +//===- CIndexUSRs.cpp - Clang-C Source Indexing Library -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp index 3c6e1530f1..0054c15bc7 100644 --- a/tools/libclang/CIndexer.cpp +++ b/tools/libclang/CIndexer.cpp @@ -1,9 +1,8 @@ -//===- CIndex.cpp - Clang-C Source Indexing Library -----------------------===// +//===- CIndexer.cpp - Clang-C Source Indexing Library ---------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -15,6 +14,7 @@ #include "CXString.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Version.h" +#include "clang/Driver/Driver.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/MD5.h" @@ -32,12 +32,69 @@ #ifdef _WIN32 #include <windows.h> +#elif defined(_AIX) +#include <errno.h> +#include <sys/ldr.h> #else #include <dlfcn.h> #endif using namespace clang; +#ifdef _AIX +namespace clang { +namespace { + +template <typename LibClangPathType> +void getClangResourcesPathImplAIX(LibClangPathType &LibClangPath) { + int PrevErrno = errno; + + size_t BufSize = 2048u; + std::unique_ptr<char[]> Buf; + while (true) { + Buf = llvm::make_unique<char []>(BufSize); + errno = 0; + int Ret = loadquery(L_GETXINFO, Buf.get(), (unsigned int)BufSize); + if (Ret != -1) + break; // loadquery() was successful. + if (errno != ENOMEM) + llvm_unreachable("Encountered an unexpected loadquery() failure"); + + // errno == ENOMEM; try to allocate more memory. + if ((BufSize & ~((-1u) >> 1u)) != 0u) + llvm::report_fatal_error("BufSize needed for loadquery() too large"); + + Buf.release(); + BufSize <<= 1u; + } + + // Extract the function entry point from the function descriptor. + uint64_t EntryAddr = + reinterpret_cast<uintptr_t &>(clang_createTranslationUnit); + + // Loop to locate the function entry point in the loadquery() results. + ld_xinfo *CurInfo = reinterpret_cast<ld_xinfo *>(Buf.get()); + while (true) { + uint64_t CurTextStart = (uint64_t)CurInfo->ldinfo_textorg; + uint64_t CurTextEnd = CurTextStart + CurInfo->ldinfo_textsize; + if (CurTextStart <= EntryAddr && EntryAddr < CurTextEnd) + break; // Successfully located. + + if (CurInfo->ldinfo_next == 0u) + llvm::report_fatal_error("Cannot locate entry point in " + "the loadquery() results"); + CurInfo = reinterpret_cast<ld_xinfo *>(reinterpret_cast<char *>(CurInfo) + + CurInfo->ldinfo_next); + } + + LibClangPath += reinterpret_cast<char *>(CurInfo) + CurInfo->ldinfo_filename; + errno = PrevErrno; +} + +} // end anonymous namespace +} // end namespace clang +#endif + const std::string &CIndexer::getClangResourcesPath() { // Did we already compute the path? if (!ResourcesPath.empty()) @@ -63,7 +120,9 @@ const std::string &CIndexer::getClangResourcesPath() { #endif #endif - LibClangPath += llvm::sys::path::parent_path(path); + LibClangPath += path; +#elif defined(_AIX) + getClangResourcesPathImplAIX(LibClangPath); #else // This silly cast below avoids a C++ warning. Dl_info info; @@ -71,13 +130,11 @@ const std::string &CIndexer::getClangResourcesPath() { llvm_unreachable("Call to dladdr() failed"); // We now have the CIndex directory, locate clang relative to it. - LibClangPath += llvm::sys::path::parent_path(info.dli_fname); + LibClangPath += info.dli_fname; #endif - llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING); - // Cache our result. - ResourcesPath = LibClangPath.str(); + ResourcesPath = driver::Driver::GetResourcesPath(LibClangPath); return ResourcesPath; } diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h index 3ba35d6db6..b7dd5f8ace 100644 --- a/tools/libclang/CIndexer.h +++ b/tools/libclang/CIndexer.h @@ -1,9 +1,8 @@ //===- CIndexer.h - Clang-C Source Indexing Library -------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CLog.h b/tools/libclang/CLog.h index a935995a11..c25dbc03a5 100644 --- a/tools/libclang/CLog.h +++ b/tools/libclang/CLog.h @@ -1,9 +1,8 @@ //===- CLog.h - Logging Interface -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt index 32333b011a..2de5b2956d 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt @@ -36,6 +36,7 @@ set(SOURCES set(LIBS clangAST clangBasic + clangDriver clangFrontend clangIndex clangLex @@ -74,7 +75,7 @@ if(MSVC) set(LLVM_EXPORTED_SYMBOL_FILE) endif() -if( LLVM_ENABLE_PIC ) +if(LLVM_ENABLE_PIC OR WIN32) set(ENABLE_SHARED SHARED) endif() @@ -91,7 +92,7 @@ endif() add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} OUTPUT_NAME ${output_name} ${SOURCES} - DEPENDS clang-headers + DEPENDS clang-resource-headers LINK_LIBS ${LIBS} @@ -148,7 +149,7 @@ install(DIRECTORY ../../include/clang-c 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. +if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-libclang-headers COMPONENT libclang-headers) endif() @@ -164,7 +165,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages") endforeach() -if(NOT CMAKE_CONFIGURATION_TYPES) +if(NOT LLVM_ENABLE_IDE) add_custom_target(libclang-python-bindings) add_llvm_install_targets(install-libclang-python-bindings COMPONENT diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index 028fdf1d3a..cb27b253fd 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -1,9 +1,8 @@ //===- CXComment.cpp - libclang APIs for manipulating CXComments ----------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXComment.h b/tools/libclang/CXComment.h index a937a80346..30be06419c 100644 --- a/tools/libclang/CXComment.h +++ b/tools/libclang/CXComment.h @@ -1,9 +1,8 @@ //===- CXComment.h - Routines for manipulating CXComments -----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index 99e4319fc1..f26d97f86b 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -1,9 +1,8 @@ //===- CXCursor.cpp - Routines for manipulating CXCursors -----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -79,6 +78,10 @@ static CXCursorKind GetCursorKind(const Attr *A) { case attr::ObjCRuntimeVisible: return CXCursor_ObjCRuntimeVisible; case attr::ObjCBoxable: return CXCursor_ObjCBoxable; case attr::FlagEnum: return CXCursor_FlagEnum; + case attr::Convergent: return CXCursor_ConvergentAttr; + case attr::WarnUnused: return CXCursor_WarnUnusedAttr; + case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr; + case attr::Aligned: return CXCursor_AlignedAttr; } return CXCursor_UnexposedAttr; @@ -106,8 +109,8 @@ CXCursor cxcursor::MakeCXCursor(const Decl *D, CXTranslationUnit TU, RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { SmallVector<SourceLocation, 16> SelLocs; cast<ObjCMethodDecl>(D)->getSelectorLocs(SelLocs); - SmallVectorImpl<SourceLocation>::iterator - I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); + SmallVectorImpl<SourceLocation>::iterator I = + llvm::find(SelLocs, RegionOfInterest.getBegin()); if (I != SelLocs.end()) SelectorIdIndex = I - SelLocs.begin(); } @@ -559,8 +562,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent, RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { SmallVector<SourceLocation, 16> SelLocs; cast<ObjCMessageExpr>(S)->getSelectorLocs(SelLocs); - SmallVectorImpl<SourceLocation>::iterator - I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); + SmallVectorImpl<SourceLocation>::iterator I = + llvm::find(SelLocs, RegionOfInterest.getBegin()); if (I != SelLocs.end()) SelectorIdIndex = I - SelLocs.begin(); } diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h index 312fb3ff25..d17381ba0a 100644 --- a/tools/libclang/CXCursor.h +++ b/tools/libclang/CXCursor.h @@ -1,9 +1,8 @@ //===- CXCursor.h - Routines for manipulating CXCursors -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXIndexDataConsumer.cpp b/tools/libclang/CXIndexDataConsumer.cpp index 3dec36a5da..d5de7df707 100644 --- a/tools/libclang/CXIndexDataConsumer.cpp +++ b/tools/libclang/CXIndexDataConsumer.cpp @@ -1,9 +1,8 @@ //===- CXIndexDataConsumer.cpp - Index data consumer for libclang----------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/tools/libclang/CXIndexDataConsumer.h b/tools/libclang/CXIndexDataConsumer.h index 5c1ce80b2f..864d870a90 100644 --- a/tools/libclang/CXIndexDataConsumer.h +++ b/tools/libclang/CXIndexDataConsumer.h @@ -1,9 +1,8 @@ //===- CXIndexDataConsumer.h - Index data consumer for libclang--*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp index fd6881e03a..551d8343fc 100644 --- a/tools/libclang/CXLoadedDiagnostic.cpp +++ b/tools/libclang/CXLoadedDiagnostic.cpp @@ -1,9 +1,8 @@ //===-- CXLoadedDiagnostic.cpp - Handling of persisent diags ----*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXLoadedDiagnostic.h b/tools/libclang/CXLoadedDiagnostic.h index 521ebd84bf..93995d7bb7 100644 --- a/tools/libclang/CXLoadedDiagnostic.h +++ b/tools/libclang/CXLoadedDiagnostic.h @@ -1,9 +1,9 @@ /*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\ |* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |* *| |*===----------------------------------------------------------------------===*| |* *| diff --git a/tools/libclang/CXSourceLocation.cpp b/tools/libclang/CXSourceLocation.cpp index 2e0ea4e440..a253dadb3b 100644 --- a/tools/libclang/CXSourceLocation.cpp +++ b/tools/libclang/CXSourceLocation.cpp @@ -1,9 +1,8 @@ //===- CXSourceLocation.cpp - CXSourceLocations APIs ------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXSourceLocation.h b/tools/libclang/CXSourceLocation.h index dddc847590..6702d0cf97 100644 --- a/tools/libclang/CXSourceLocation.h +++ b/tools/libclang/CXSourceLocation.h @@ -1,9 +1,8 @@ //===- CXSourceLocation.h - CXSourceLocations Utilities ---------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXStoredDiagnostic.cpp b/tools/libclang/CXStoredDiagnostic.cpp index 6bd2f67466..c4c24876e7 100644 --- a/tools/libclang/CXStoredDiagnostic.cpp +++ b/tools/libclang/CXStoredDiagnostic.cpp @@ -1,15 +1,14 @@ -/*===-- CXStoreDiagnostic.cpp - Diagnostics C Interface ----------*- C++ -*-===*\ -|* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* Implements part of the diagnostic functions of the Clang C interface. *| -|* *| -\*===----------------------------------------------------------------------===*/ +//===- CXStoredDiagnostic.cpp - Diagnostics C Interface -------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Implements part of the diagnostic functions of the Clang C interface. +// +//===----------------------------------------------------------------------===// #include "CIndexDiagnostic.h" #include "CIndexer.h" diff --git a/tools/libclang/CXString.cpp b/tools/libclang/CXString.cpp index cef4e53a42..2754795f4a 100644 --- a/tools/libclang/CXString.cpp +++ b/tools/libclang/CXString.cpp @@ -1,9 +1,8 @@ //===- CXString.cpp - Routines for manipulating CXStrings -----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXString.h b/tools/libclang/CXString.h index ed19261187..809bdec3d6 100644 --- a/tools/libclang/CXString.h +++ b/tools/libclang/CXString.h @@ -1,9 +1,8 @@ //===- CXString.h - Routines for manipulating CXStrings -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h index 590142f30f..3424bf2997 100644 --- a/tools/libclang/CXTranslationUnit.h +++ b/tools/libclang/CXTranslationUnit.h @@ -1,9 +1,8 @@ //===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index b8009ddc1c..6cb680a64d 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -1,9 +1,8 @@ -//===- CXTypes.cpp - Implements 'CXTypes' aspect of libclang ------------===// +//===- CXType.cpp - Implements 'CXTypes' aspect of libclang ---------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--------------------------------------------------------------------===// // @@ -110,6 +109,7 @@ static CXTypeKind GetTypeKind(QualType T) { TKCASE(VariableArray); TKCASE(DependentSizedArray); TKCASE(Vector); + TKCASE(ExtVector); TKCASE(MemberPointer); TKCASE(Auto); TKCASE(Elaborated); @@ -129,7 +129,9 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) { // Handle attributed types as the original type if (auto *ATT = T->getAs<AttributedType>()) { if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes)) { - return MakeCXType(ATT->getModifiedType(), TU); + // Return the equivalent type which represents the canonically + // equivalent type. + return MakeCXType(ATT->getEquivalentType(), TU); } } // Handle paren types as the original type @@ -599,6 +601,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { TKIND(VariableArray); TKIND(DependentSizedArray); TKIND(Vector); + TKIND(ExtVector); TKIND(MemberPointer); TKIND(Auto); TKIND(Elaborated); @@ -803,6 +806,9 @@ CXType clang_getElementType(CXType CT) { case Type::Vector: ET = cast<VectorType> (TP)->getElementType(); break; + case Type::ExtVector: + ET = cast<ExtVectorType>(TP)->getElementType(); + break; case Type::Complex: ET = cast<ComplexType> (TP)->getElementType(); break; @@ -826,6 +832,9 @@ long long clang_getNumElements(CXType CT) { case Type::Vector: result = cast<VectorType> (TP)->getNumElements(); break; + case Type::ExtVector: + result = cast<ExtVectorType>(TP)->getNumElements(); + break; default: break; } @@ -890,6 +899,9 @@ long long clang_Type_getAlignOf(CXType T) { return CXTypeLayoutError_Incomplete; if (QT->isDependentType()) return CXTypeLayoutError_Dependent; + if (const auto *Deduced = dyn_cast<DeducedType>(QT)) + if (Deduced->getDeducedType().isNull()) + return CXTypeLayoutError_Undeduced; // Exceptions by GCC extension - see ASTContext.cpp:1313 getTypeInfoImpl // if (QT->isFunctionType()) return 4; // Bug #15511 - should be 1 // if (QT->isVoidType()) return 1; @@ -927,6 +939,9 @@ long long clang_Type_getSizeOf(CXType T) { return CXTypeLayoutError_Dependent; if (!QT->isConstantSizeType()) return CXTypeLayoutError_NotConstantSize; + if (const auto *Deduced = dyn_cast<DeducedType>(QT)) + if (Deduced->getDeducedType().isNull()) + return CXTypeLayoutError_Undeduced; // [gcc extension] lib/AST/ExprConstant.cpp:1372 // HandleSizeof : {voidtype,functype} == 1 // not handled by ASTContext.cpp:1313 getTypeInfoImpl @@ -1238,6 +1253,16 @@ unsigned clang_Cursor_isAnonymous(CXCursor C){ return 0; } + +unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){ + if (!clang_isDeclaration(C.kind)) + return 0; + const Decl *D = cxcursor::getCursorDecl(C); + if (const RecordDecl *FD = dyn_cast_or_null<RecordDecl>(D)) + return FD->isAnonymousStructOrUnion(); + return 0; +} + CXType clang_Type_getNamedType(CXType CT){ QualType T = GetQualType(CT); const Type *TP = T.getTypePtrOrNull(); diff --git a/tools/libclang/CXType.h b/tools/libclang/CXType.h index 941cc0a9fd..1d458086c0 100644 --- a/tools/libclang/CXType.h +++ b/tools/libclang/CXType.h @@ -1,9 +1,8 @@ //===- CXTypes.h - Routines for manipulating CXTypes ----------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h index f2fb68fab9..b0afa5a0b5 100644 --- a/tools/libclang/CursorVisitor.h +++ b/tools/libclang/CursorVisitor.h @@ -1,9 +1,8 @@ //===- CursorVisitor.h - CursorVisitor interface ----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/tools/libclang/Index_Internal.h b/tools/libclang/Index_Internal.h index fbe3cabf04..d28438770e 100644 --- a/tools/libclang/Index_Internal.h +++ b/tools/libclang/Index_Internal.h @@ -1,9 +1,8 @@ //===- CXString.h - Routines for manipulating CXStrings -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 4da046b282..ad3dc70ea3 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -1,9 +1,8 @@ -//===- CIndexHigh.cpp - Higher level API functions ------------------------===// +//===- Indexing.cpp - Higher level API functions --------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -94,9 +93,6 @@ typedef llvm::DenseSet<PPRegion> PPRegionSetTy; } // end anonymous namespace namespace llvm { - template <> struct isPodLike<PPRegion> { - static const bool value = true; - }; template <> struct DenseMapInfo<PPRegion> { diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index 2c4b083a59..1d3cd5cd14 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -39,6 +39,7 @@ clang_Cursor_getSpellingNameRange clang_Cursor_getTranslationUnit clang_Cursor_getReceiverType clang_Cursor_isAnonymous +clang_Cursor_isAnonymousRecordDecl clang_Cursor_isBitField clang_Cursor_isDynamicCall clang_Cursor_isExternalSymbol |