summaryrefslogtreecommitdiffstats
path: root/tools/libclang
diff options
context:
space:
mode:
Diffstat (limited to 'tools/libclang')
-rw-r--r--tools/libclang/ARCMigrate.cpp4
-rw-r--r--tools/libclang/CIndex.cpp203
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp4
-rw-r--r--tools/libclang/CIndexDiagnostic.cpp29
-rw-r--r--tools/libclang/CIndexDiagnostic.h27
-rw-r--r--tools/libclang/CIndexUSRs.cpp2
-rw-r--r--tools/libclang/CIndexer.h4
-rw-r--r--tools/libclang/CLog.h4
-rw-r--r--tools/libclang/CMakeLists.txt2
-rw-r--r--tools/libclang/CXComment.cpp2
-rw-r--r--tools/libclang/CXComment.h6
-rw-r--r--tools/libclang/CXCompilationDatabase.cpp6
-rw-r--r--tools/libclang/CXCursor.cpp167
-rw-r--r--tools/libclang/CXCursor.h4
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp591
-rw-r--r--tools/libclang/CXLoadedDiagnostic.h4
-rw-r--r--tools/libclang/CXSourceLocation.h4
-rw-r--r--tools/libclang/CXString.h4
-rw-r--r--tools/libclang/CXTranslationUnit.h4
-rw-r--r--tools/libclang/CXType.cpp1
-rw-r--r--tools/libclang/CXType.h4
-rw-r--r--tools/libclang/CursorVisitor.h4
-rw-r--r--tools/libclang/IndexBody.cpp2
-rw-r--r--tools/libclang/IndexTypeSourceInfo.cpp1
-rw-r--r--tools/libclang/Index_Internal.h4
-rw-r--r--tools/libclang/Indexing.cpp21
-rw-r--r--tools/libclang/IndexingContext.h5
-rw-r--r--tools/libclang/Makefile4
-rw-r--r--tools/libclang/libclang.exports8
29 files changed, 597 insertions, 528 deletions
diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp
index 375c5f4..b0b869b 100644
--- a/tools/libclang/ARCMigrate.cpp
+++ b/tools/libclang/ARCMigrate.cpp
@@ -47,9 +47,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) {
return nullptr;
}
- bool exists = false;
- llvm::sys::fs::exists(migrate_dir_path, exists);
- if (!exists) {
+ if (!llvm::sys::fs::exists(migrate_dir_path)) {
if (Logging) {
llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
<< "\")\n";
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index fc8703a..00ef8c0 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -22,10 +22,12 @@
#include "CXType.h"
#include "CursorVisitor.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/Mangle.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticCategories.h"
#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -40,6 +42,8 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Mangler.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Format.h"
@@ -1256,6 +1260,7 @@ bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
case NestedNameSpecifier::TypeSpecWithTemplate:
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Identifier:
+ case NestedNameSpecifier::Super:
break;
}
@@ -1297,6 +1302,7 @@ CursorVisitor::VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier) {
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Identifier:
+ case NestedNameSpecifier::Super:
break;
}
}
@@ -1828,6 +1834,7 @@ public:
void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *E);
void VisitCXXUuidofExpr(const CXXUuidofExpr *E);
void VisitCXXCatchStmt(const CXXCatchStmt *S);
+ void VisitCXXForRangeStmt(const CXXForRangeStmt *S);
void VisitDeclRefExpr(const DeclRefExpr *D);
void VisitDeclStmt(const DeclStmt *S);
void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E);
@@ -1856,21 +1863,28 @@ public:
void VisitOpaqueValueExpr(const OpaqueValueExpr *E);
void VisitLambdaExpr(const LambdaExpr *E);
void VisitOMPExecutableDirective(const OMPExecutableDirective *D);
+ void VisitOMPLoopDirective(const OMPLoopDirective *D);
void VisitOMPParallelDirective(const OMPParallelDirective *D);
void VisitOMPSimdDirective(const OMPSimdDirective *D);
void VisitOMPForDirective(const OMPForDirective *D);
+ void VisitOMPForSimdDirective(const OMPForSimdDirective *D);
void VisitOMPSectionsDirective(const OMPSectionsDirective *D);
void VisitOMPSectionDirective(const OMPSectionDirective *D);
void VisitOMPSingleDirective(const OMPSingleDirective *D);
void VisitOMPMasterDirective(const OMPMasterDirective *D);
void VisitOMPCriticalDirective(const OMPCriticalDirective *D);
void VisitOMPParallelForDirective(const OMPParallelForDirective *D);
+ void VisitOMPParallelForSimdDirective(const OMPParallelForSimdDirective *D);
void VisitOMPParallelSectionsDirective(const OMPParallelSectionsDirective *D);
void VisitOMPTaskDirective(const OMPTaskDirective *D);
void VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *D);
void VisitOMPBarrierDirective(const OMPBarrierDirective *D);
void VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *D);
void VisitOMPFlushDirective(const OMPFlushDirective *D);
+ void VisitOMPOrderedDirective(const OMPOrderedDirective *D);
+ void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
+ void VisitOMPTargetDirective(const OMPTargetDirective *D);
+ void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
private:
void AddDeclarationNameInfo(const Stmt *S);
@@ -1979,14 +1993,28 @@ void OMPClauseEnqueue::VisitOMPUntiedClause(const OMPUntiedClause *) {}
void OMPClauseEnqueue::VisitOMPMergeableClause(const OMPMergeableClause *) {}
+void OMPClauseEnqueue::VisitOMPReadClause(const OMPReadClause *) {}
+
+void OMPClauseEnqueue::VisitOMPWriteClause(const OMPWriteClause *) {}
+
+void OMPClauseEnqueue::VisitOMPUpdateClause(const OMPUpdateClause *) {}
+
+void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
+
+void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
+
template<typename T>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
- for (const auto *I : Node->varlists())
+ for (const auto *I : Node->varlists()) {
Visitor->AddStmt(I);
+ }
}
void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) {
VisitOMPClauseList(C);
+ for (const auto *E : C->private_copies()) {
+ Visitor->AddStmt(E);
+ }
}
void OMPClauseEnqueue::VisitOMPFirstprivateClause(
const OMPFirstprivateClause *C) {
@@ -2127,6 +2155,12 @@ void EnqueueVisitor::VisitCXXCatchStmt(const CXXCatchStmt *S) {
AddDecl(S->getExceptionDecl());
}
+void EnqueueVisitor::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
+ AddStmt(S->getBody());
+ AddStmt(S->getRangeInit());
+ AddDecl(S->getLoopVariable());
+}
+
void EnqueueVisitor::VisitDeclRefExpr(const DeclRefExpr *DR) {
if (DR->hasExplicitTemplateArgs()) {
AddExplicitTemplateArgs(&DR->getExplicitTemplateArgs());
@@ -2309,16 +2343,24 @@ void EnqueueVisitor::VisitOMPExecutableDirective(
EnqueueChildren(*I);
}
+void EnqueueVisitor::VisitOMPLoopDirective(const OMPLoopDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
void EnqueueVisitor::VisitOMPParallelDirective(const OMPParallelDirective *D) {
VisitOMPExecutableDirective(D);
}
void EnqueueVisitor::VisitOMPSimdDirective(const OMPSimdDirective *D) {
- VisitOMPExecutableDirective(D);
+ VisitOMPLoopDirective(D);
}
void EnqueueVisitor::VisitOMPForDirective(const OMPForDirective *D) {
- VisitOMPExecutableDirective(D);
+ VisitOMPLoopDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPForSimdDirective(const OMPForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
}
void EnqueueVisitor::VisitOMPSectionsDirective(const OMPSectionsDirective *D) {
@@ -2344,7 +2386,12 @@ void EnqueueVisitor::VisitOMPCriticalDirective(const OMPCriticalDirective *D) {
void
EnqueueVisitor::VisitOMPParallelForDirective(const OMPParallelForDirective *D) {
- VisitOMPExecutableDirective(D);
+ VisitOMPLoopDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPParallelForSimdDirective(
+ const OMPParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
}
void EnqueueVisitor::VisitOMPParallelSectionsDirective(
@@ -2373,6 +2420,22 @@ void EnqueueVisitor::VisitOMPFlushDirective(const OMPFlushDirective *D) {
VisitOMPExecutableDirective(D);
}
+void EnqueueVisitor::VisitOMPOrderedDirective(const OMPOrderedDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPAtomicDirective(const OMPAtomicDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPTargetDirective(const OMPTargetDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
+ VisitOMPExecutableDirective(D);
+}
+
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
}
@@ -2755,13 +2818,14 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
FileSystemOptions FileSystemOpts;
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
- ASTUnit *AU = ASTUnit::LoadFromASTFile(ast_filename, Diags, FileSystemOpts,
- CXXIdx->getOnlyLocalDecls(), None,
- /*CaptureDiagnostics=*/true,
- /*AllowPCHWithCompilerErrors=*/true,
- /*UserFilesAreVolatile=*/true);
- *out_TU = MakeCXTranslationUnit(CXXIdx, AU);
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
+ CompilerInstance::createDiagnostics(new DiagnosticOptions());
+ std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
+ ast_filename, Diags, FileSystemOpts, CXXIdx->getOnlyLocalDecls(), None,
+ /*CaptureDiagnostics=*/true,
+ /*AllowPCHWithCompilerErrors=*/true,
+ /*UserFilesAreVolatile=*/true);
+ *out_TU = MakeCXTranslationUnit(CXXIdx, AU.release());
return *out_TU ? CXError_Success : CXError_Failure;
}
@@ -2847,9 +2911,9 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
for (auto &UF : PTUI->unsaved_files) {
- llvm::MemoryBuffer *MB =
+ std::unique_ptr<llvm::MemoryBuffer> MB =
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
- RemappedFiles->push_back(std::make_pair(UF.Filename, MB));
+ RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
}
std::unique_ptr<std::vector<const char *>> Args(
@@ -3131,9 +3195,9 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
for (auto &UF : RTUI->unsaved_files) {
- llvm::MemoryBuffer *MB =
+ std::unique_ptr<llvm::MemoryBuffer> MB =
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
- RemappedFiles->push_back(std::make_pair(UF.Filename, MB));
+ RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
}
if (!CXXUnit->Reparse(*RemappedFiles.get()))
@@ -3259,6 +3323,18 @@ int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID) {
return 0;
}
+int clang_File_isEqual(CXFile file1, CXFile file2) {
+ if (file1 == file2)
+ return true;
+
+ if (!file1 || !file2)
+ return false;
+
+ FileEntry *FEnt1 = static_cast<FileEntry *>(file1);
+ FileEntry *FEnt2 = static_cast<FileEntry *>(file2);
+ return FEnt1->getUniqueID() == FEnt2->getUniqueID();
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
@@ -3628,6 +3704,18 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
return clang_getNullRange();
}
+ if (C.kind == CXCursor_CXXMethod || C.kind == CXCursor_Destructor ||
+ C.kind == CXCursor_ConversionFunction) {
+ if (pieceIndex > 0)
+ return clang_getNullRange();
+ if (const FunctionDecl *FD =
+ dyn_cast_or_null<FunctionDecl>(getCursorDecl(C))) {
+ DeclarationNameInfo FunctionName = FD->getNameInfo();
+ return cxloc::translateSourceRange(Ctx, FunctionName.getSourceRange());
+ }
+ return clang_getNullRange();
+ }
+
// FIXME: A CXCursor_InclusionDirective should give the location of the
// filename, but we don't keep track of this.
@@ -3647,6 +3735,37 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
return cxloc::translateSourceRange(Ctx, Loc);
}
+CXString clang_Cursor_getMangling(CXCursor C) {
+ if (clang_isInvalid(C.kind) || !clang_isDeclaration(C.kind))
+ return cxstring::createEmpty();
+
+ // Mangling only works for functions and variables.
+ const Decl *D = getCursorDecl(C);
+ if (!D || !(isa<FunctionDecl>(D) || isa<VarDecl>(D)))
+ return cxstring::createEmpty();
+
+ // First apply frontend mangling.
+ const NamedDecl *ND = cast<NamedDecl>(D);
+ ASTContext &Ctx = ND->getASTContext();
+ std::unique_ptr<MangleContext> MC(Ctx.createMangleContext());
+
+ std::string FrontendBuf;
+ llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
+ MC->mangleName(ND, FrontendBufOS);
+
+ // Now apply backend mangling.
+ std::unique_ptr<llvm::DataLayout> DL(
+ new llvm::DataLayout(Ctx.getTargetInfo().getTargetDescription()));
+ llvm::Mangler BackendMangler(DL.get());
+
+ std::string FinalBuf;
+ llvm::raw_string_ostream FinalBufOS(FinalBuf);
+ BackendMangler.getNameWithPrefix(FinalBufOS,
+ llvm::Twine(FrontendBufOS.str()));
+
+ return cxstring::createDup(FinalBufOS.str());
+}
+
CXString clang_getCursorDisplayName(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return clang_getCursorSpelling(C);
@@ -3997,6 +4116,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("attribute(global)");
case CXCursor_CUDAHostAttr:
return cxstring::createRef("attribute(host)");
+ case CXCursor_CUDASharedAttr:
+ return cxstring::createRef("attribute(shared)");
case CXCursor_PreprocessingDirective:
return cxstring::createRef("preprocessing directive");
case CXCursor_MacroDefinition:
@@ -4051,6 +4172,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("OMPSimdDirective");
case CXCursor_OMPForDirective:
return cxstring::createRef("OMPForDirective");
+ case CXCursor_OMPForSimdDirective:
+ return cxstring::createRef("OMPForSimdDirective");
case CXCursor_OMPSectionsDirective:
return cxstring::createRef("OMPSectionsDirective");
case CXCursor_OMPSectionDirective:
@@ -4063,6 +4186,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("OMPCriticalDirective");
case CXCursor_OMPParallelForDirective:
return cxstring::createRef("OMPParallelForDirective");
+ case CXCursor_OMPParallelForSimdDirective:
+ return cxstring::createRef("OMPParallelForSimdDirective");
case CXCursor_OMPParallelSectionsDirective:
return cxstring::createRef("OMPParallelSectionsDirective");
case CXCursor_OMPTaskDirective:
@@ -4075,6 +4200,14 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("OMPTaskwaitDirective");
case CXCursor_OMPFlushDirective:
return cxstring::createRef("OMPFlushDirective");
+ case CXCursor_OMPOrderedDirective:
+ return cxstring::createRef("OMPOrderedDirective");
+ case CXCursor_OMPAtomicDirective:
+ return cxstring::createRef("OMPAtomicDirective");
+ case CXCursor_OMPTargetDirective:
+ return cxstring::createRef("OMPTargetDirective");
+ case CXCursor_OMPTeamsDirective:
+ return cxstring::createRef("OMPTeamsDirective");
}
llvm_unreachable("Unhandled CXCursorKind");
@@ -6296,6 +6429,40 @@ static const Decl *maybeGetTemplateCursor(const Decl *D) {
return D;
}
+
+enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) {
+ StorageClass sc = SC_None;
+ const Decl *D = getCursorDecl(C);
+ if (D) {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ sc = FD->getStorageClass();
+ } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ sc = VD->getStorageClass();
+ } else {
+ return CX_SC_Invalid;
+ }
+ } else {
+ return CX_SC_Invalid;
+ }
+ switch (sc) {
+ case SC_None:
+ return CX_SC_None;
+ case SC_Extern:
+ return CX_SC_Extern;
+ case SC_Static:
+ return CX_SC_Static;
+ case SC_PrivateExtern:
+ return CX_SC_PrivateExtern;
+ case SC_OpenCLWorkGroupLocal:
+ return CX_SC_OpenCLWorkGroupLocal;
+ case SC_Auto:
+ return CX_SC_Auto;
+ case SC_Register:
+ return CX_SC_Register;
+ }
+ llvm_unreachable("Unhandled storage class!");
+}
+
CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
if (clang_isDeclaration(cursor.kind)) {
if (const Decl *D = getCursorDecl(cursor)) {
@@ -6490,11 +6657,7 @@ CXModule clang_getModuleForFile(CXTranslationUnit TU, CXFile File) {
HeaderSearch &HS = Unit.getPreprocessor().getHeaderSearchInfo();
ModuleMap::KnownHeader Header = HS.findModuleForHeader(FE);
- if (Module *Mod = Header.getModule()) {
- if (Header.getRole() != ModuleMap::ExcludedHeader)
- return Mod;
- }
- return nullptr;
+ return Header.getModule();
}
CXFile clang_Module_getASTFile(CXModule CXMod) {
diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index 0d88003..b6f71d2 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/tools/libclang/CIndexCodeCompletion.cpp
@@ -692,9 +692,9 @@ void clang_codeCompleteAt_Impl(void *UserData) {
SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
for (auto &UF : CCAI->unsaved_files) {
- llvm::MemoryBuffer *MB =
+ std::unique_ptr<llvm::MemoryBuffer> MB =
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
- RemappedFiles.push_back(std::make_pair(UF.Filename, MB));
+ RemappedFiles.push_back(std::make_pair(UF.Filename, MB.release()));
}
if (EnableLogging) {
diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp
index 0d97ebd..4d646f0 100644
--- a/tools/libclang/CIndexDiagnostic.cpp
+++ b/tools/libclang/CIndexDiagnostic.cpp
@@ -30,13 +30,11 @@ using namespace clang::cxloc;
using namespace clang::cxdiag;
using namespace llvm;
+CXDiagnosticSetImpl::~CXDiagnosticSetImpl() {}
-CXDiagnosticSetImpl::~CXDiagnosticSetImpl() {
- for (std::vector<CXDiagnosticImpl *>::iterator it = Diagnostics.begin(),
- et = Diagnostics.end();
- it != et; ++it) {
- delete *it;
- }
+void
+CXDiagnosticSetImpl::appendDiagnostic(std::unique_ptr<CXDiagnosticImpl> D) {
+ Diagnostics.push_back(std::move(D));
}
CXDiagnosticImpl::~CXDiagnosticImpl() {}
@@ -105,12 +103,13 @@ public:
if (Level != DiagnosticsEngine::Note)
CurrentSet = MainSet;
-
- CXStoredDiagnostic *CD = new CXStoredDiagnostic(*SD, LangOpts);
- CurrentSet->appendDiagnostic(CD);
-
+
+ auto Owner = llvm::make_unique<CXStoredDiagnostic>(*SD, LangOpts);
+ CXStoredDiagnostic &CD = *Owner;
+ CurrentSet->appendDiagnostic(std::move(Owner));
+
if (Level != DiagnosticsEngine::Note)
- CurrentSet = &CD->getChildDiagnostics();
+ CurrentSet = &CD.getChildDiagnostics();
}
void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
@@ -127,8 +126,8 @@ public:
L = translateSourceLocation(*SM, LangOpts, Loc);
else
L = clang_getNullLocation();
- CXDiagnosticImpl *CD = new CXDiagnosticCustomNoteImpl(Message, L);
- CurrentSet->appendDiagnostic(CD);
+ CurrentSet->appendDiagnostic(
+ llvm::make_unique<CXDiagnosticCustomNoteImpl>(Message, L));
}
void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
@@ -149,8 +148,8 @@ public:
L = translateSourceLocation(*SM, LangOpts, Loc);
else
L = clang_getNullLocation();
- CurrentSet->appendDiagnostic(new CXDiagnosticCustomNoteImpl(Message,
- L));
+ CurrentSet->appendDiagnostic(
+ llvm::make_unique<CXDiagnosticCustomNoteImpl>(Message, L));
}
CXDiagnosticSetImpl *CurrentSet;
diff --git a/tools/libclang/CIndexDiagnostic.h b/tools/libclang/CIndexDiagnostic.h
index 31ae902..4347fb7 100644
--- a/tools/libclang/CIndexDiagnostic.h
+++ b/tools/libclang/CIndexDiagnostic.h
@@ -10,10 +10,11 @@
|* Implements the diagnostic functions of the Clang C interface. *|
|* *|
\*===----------------------------------------------------------------------===*/
-#ifndef LLVM_CLANG_CINDEX_DIAGNOSTIC_H
-#define LLVM_CLANG_CINDEX_DIAGNOSTIC_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CINDEXDIAGNOSTIC_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CINDEXDIAGNOSTIC_H
#include "clang-c/Index.h"
+#include <memory>
#include <vector>
#include <assert.h>
@@ -24,27 +25,25 @@ class StoredDiagnostic;
class CXDiagnosticImpl;
class CXDiagnosticSetImpl {
- std::vector<CXDiagnosticImpl *> Diagnostics;
+ std::vector<std::unique_ptr<CXDiagnosticImpl>> Diagnostics;
const bool IsExternallyManaged;
public:
CXDiagnosticSetImpl(bool isManaged = false)
: IsExternallyManaged(isManaged) {}
virtual ~CXDiagnosticSetImpl();
-
+
size_t getNumDiagnostics() const {
return Diagnostics.size();
}
CXDiagnosticImpl *getDiagnostic(unsigned i) const {
assert(i < getNumDiagnostics());
- return Diagnostics[i];
+ return Diagnostics[i].get();
}
-
- void appendDiagnostic(CXDiagnosticImpl *D) {
- Diagnostics.push_back(D);
- }
-
+
+ void appendDiagnostic(std::unique_ptr<CXDiagnosticImpl> D);
+
bool empty() const {
return Diagnostics.empty();
}
@@ -99,9 +98,9 @@ public:
protected:
CXDiagnosticImpl(Kind k) : K(k) {}
CXDiagnosticSetImpl ChildDiags;
-
- void append(CXDiagnosticImpl *D) {
- ChildDiags.appendDiagnostic(D);
+
+ void append(std::unique_ptr<CXDiagnosticImpl> D) {
+ ChildDiags.appendDiagnostic(std::move(D));
}
private:
@@ -163,4 +162,4 @@ CXDiagnosticSetImpl *lazyCreateDiags(CXTranslationUnit TU,
} // end namespace clang
-#endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H
+#endif
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 25881c3..d7b6585 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -15,9 +15,9 @@
#include "CXCursor.h"
#include "CXString.h"
#include "CXTranslationUnit.h"
+#include "clang/Frontend/ASTUnit.h"
#include "clang/Index/USRGeneration.h"
#include "clang/Lex/PreprocessingRecord.h"
-#include "clang/Frontend/ASTUnit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h
index 95d8115..7a8dbd3 100644
--- a/tools/libclang/CIndexer.h
+++ b/tools/libclang/CIndexer.h
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CINDEXER_H
-#define LLVM_CLANG_CINDEXER_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CINDEXER_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CINDEXER_H
#include "clang-c/Index.h"
#include "llvm/ADT/StringRef.h"
diff --git a/tools/libclang/CLog.h b/tools/libclang/CLog.h
index e7419b7..b9309ed 100644
--- a/tools/libclang/CLog.h
+++ b/tools/libclang/CLog.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBCLANG_CLOG_H
-#define LLVM_LIBCLANG_CLOG_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CLOG_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CLOG_H
#include "clang-c/Index.h"
#include "clang/Basic/LLVM.h"
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
index e7ab63f..f1c3f4c 100644
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -86,7 +86,7 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC}
${LIBS}
LINK_COMPONENTS
- BitReader
+ Core
Support
)
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp
index 4547031..9cc05ed4 100644
--- a/tools/libclang/CXComment.cpp
+++ b/tools/libclang/CXComment.cpp
@@ -12,10 +12,10 @@
//===----------------------------------------------------------------------===//
#include "clang-c/Index.h"
-#include "clang-c/Documentation.h"
#include "CXComment.h"
#include "CXCursor.h"
#include "CXString.h"
+#include "clang-c/Documentation.h"
#include "clang/AST/Decl.h"
#include "clang/Index/CommentToXML.h"
#include "llvm/ADT/StringExtras.h"
diff --git a/tools/libclang/CXComment.h b/tools/libclang/CXComment.h
index d9d2bde..a937a80 100644
--- a/tools/libclang/CXComment.h
+++ b/tools/libclang/CXComment.h
@@ -11,12 +11,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXCOMMENT_H
-#define LLVM_CLANG_CXCOMMENT_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXCOMMENT_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXCOMMENT_H
#include "CXTranslationUnit.h"
-#include "clang-c/Index.h"
#include "clang-c/Documentation.h"
+#include "clang-c/Index.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Comment.h"
#include "clang/Frontend/ASTUnit.h"
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp
index 51677e7..1e4a2cd 100644
--- a/tools/libclang/CXCompilationDatabase.cpp
+++ b/tools/libclang/CXCompilationDatabase.cpp
@@ -16,8 +16,8 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir,
std::string ErrorMsg;
CXCompilationDatabase_Error Err = CXCompilationDatabase_NoError;
- CompilationDatabase *db = CompilationDatabase::loadFromDirectory(BuildDir,
- ErrorMsg);
+ std::unique_ptr<CompilationDatabase> db =
+ CompilationDatabase::loadFromDirectory(BuildDir, ErrorMsg);
if (!db) {
fprintf(stderr, "LIBCLANG TOOLING ERROR: %s\n", ErrorMsg.c_str());
@@ -27,7 +27,7 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir,
if (ErrorCode)
*ErrorCode = Err;
- return db;
+ return db.release();
}
void
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index 4321903..7834181 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -57,6 +57,7 @@ static CXCursorKind GetCursorKind(const Attr *A) {
case attr::CUDADevice: return CXCursor_CUDADeviceAttr;
case attr::CUDAGlobal: return CXCursor_CUDAGlobalAttr;
case attr::CUDAHost: return CXCursor_CUDAHostAttr;
+ case attr::CUDAShared: return CXCursor_CUDASharedAttr;
}
return CXCursor_UnexposedAttr;
@@ -228,6 +229,7 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::CXXBindTemporaryExprClass:
case Stmt::CXXDefaultArgExprClass:
case Stmt::CXXDefaultInitExprClass:
+ case Stmt::CXXFoldExprClass:
case Stmt::CXXStdInitializerListExprClass:
case Stmt::CXXScalarValueInitExprClass:
case Stmt::CXXUuidofExprClass:
@@ -468,6 +470,7 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::SubstNonTypeTemplateParmPackExprClass:
case Stmt::FunctionParmPackExprClass:
case Stmt::UnresolvedLookupExprClass:
+ case Stmt::TypoExprClass: // A typo could actually be a DeclRef or a MemberRef
K = CXCursor_DeclRefExpr;
break;
@@ -526,6 +529,9 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::OMPForDirectiveClass:
K = CXCursor_OMPForDirective;
break;
+ case Stmt::OMPForSimdDirectiveClass:
+ K = CXCursor_OMPForSimdDirective;
+ break;
case Stmt::OMPSectionsDirectiveClass:
K = CXCursor_OMPSectionsDirective;
break;
@@ -544,6 +550,9 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::OMPParallelForDirectiveClass:
K = CXCursor_OMPParallelForDirective;
break;
+ case Stmt::OMPParallelForSimdDirectiveClass:
+ K = CXCursor_OMPParallelForSimdDirective;
+ break;
case Stmt::OMPParallelSectionsDirectiveClass:
K = CXCursor_OMPParallelSectionsDirective;
break;
@@ -562,6 +571,18 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::OMPFlushDirectiveClass:
K = CXCursor_OMPFlushDirective;
break;
+ case Stmt::OMPOrderedDirectiveClass:
+ K = CXCursor_OMPOrderedDirective;
+ break;
+ case Stmt::OMPAtomicDirectiveClass:
+ K = CXCursor_OMPAtomicDirective;
+ break;
+ case Stmt::OMPTargetDirectiveClass:
+ K = CXCursor_OMPTargetDirective;
+ break;
+ case Stmt::OMPTeamsDirectiveClass:
+ K = CXCursor_OMPTeamsDirective;
+ break;
}
CXCursor C = { K, 0, { Parent, S, TU } };
@@ -1055,6 +1076,140 @@ CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) {
return clang_getNullCursor();
}
+int clang_Cursor_getNumTemplateArguments(CXCursor C) {
+ if (clang_getCursorKind(C) != CXCursor_FunctionDecl) {
+ return -1;
+ }
+
+ const FunctionDecl *FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(
+ getCursorDecl(C));
+ if (!FD) {
+ return -1;
+ }
+
+ const FunctionTemplateSpecializationInfo* SpecInfo =
+ FD->getTemplateSpecializationInfo();
+ if (!SpecInfo) {
+ return -1;
+ }
+
+ return SpecInfo->TemplateArguments->size();
+}
+
+enum CXGetTemplateArgumentStatus {
+ /** \brief The operation completed successfully */
+ CXGetTemplateArgumentStatus_Success = 0,
+
+ /** \brief The specified cursor did not represent a FunctionDecl. */
+ CXGetTemplateArgumentStatus_CursorNotFunctionDecl = -1,
+
+ /** \brief The specified cursor was not castable to a FunctionDecl. */
+ CXGetTemplateArgumentStatus_BadFunctionDeclCast = -2,
+
+ /** \brief A NULL FunctionTemplateSpecializationInfo was retrieved. */
+ CXGetTemplateArgumentStatus_NullTemplSpecInfo = -3,
+
+ /** \brief An invalid (OOB) argument index was specified */
+ CXGetTemplateArgumentStatus_InvalidIndex = -4
+};
+
+static int clang_Cursor_getTemplateArgument(
+ CXCursor C, unsigned I, TemplateArgument *TA) {
+ if (clang_getCursorKind(C) != CXCursor_FunctionDecl) {
+ return CXGetTemplateArgumentStatus_CursorNotFunctionDecl;
+ }
+
+ const FunctionDecl *FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(
+ getCursorDecl(C));
+ if (!FD) {
+ return CXGetTemplateArgumentStatus_BadFunctionDeclCast;
+ }
+
+ const FunctionTemplateSpecializationInfo* SpecInfo =
+ FD->getTemplateSpecializationInfo();
+ if (!SpecInfo) {
+ return CXGetTemplateArgumentStatus_NullTemplSpecInfo;
+ }
+
+ if (I >= SpecInfo->TemplateArguments->size()) {
+ return CXGetTemplateArgumentStatus_InvalidIndex;
+ }
+
+ *TA = SpecInfo->TemplateArguments->get(I);
+ return 0;
+}
+
+enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(CXCursor C,
+ unsigned I) {
+ TemplateArgument TA;
+ if (clang_Cursor_getTemplateArgument(C, I, &TA)) {
+ return CXTemplateArgumentKind_Invalid;
+ }
+
+ switch (TA.getKind()) {
+ case TemplateArgument::Null: return CXTemplateArgumentKind_Null;
+ case TemplateArgument::Type: return CXTemplateArgumentKind_Type;
+ case TemplateArgument::Declaration:
+ return CXTemplateArgumentKind_Declaration;
+ case TemplateArgument::NullPtr: return CXTemplateArgumentKind_NullPtr;
+ case TemplateArgument::Integral: return CXTemplateArgumentKind_Integral;
+ case TemplateArgument::Template: return CXTemplateArgumentKind_Template;
+ case TemplateArgument::TemplateExpansion:
+ return CXTemplateArgumentKind_TemplateExpansion;
+ case TemplateArgument::Expression: return CXTemplateArgumentKind_Expression;
+ case TemplateArgument::Pack: return CXTemplateArgumentKind_Pack;
+ }
+
+ return CXTemplateArgumentKind_Invalid;
+}
+
+CXType clang_Cursor_getTemplateArgumentType(CXCursor C, unsigned I) {
+ TemplateArgument TA;
+ if (clang_Cursor_getTemplateArgument(C, I, &TA) !=
+ CXGetTemplateArgumentStatus_Success) {
+ return cxtype::MakeCXType(QualType(), getCursorTU(C));
+ }
+
+ if (TA.getKind() != TemplateArgument::Type) {
+ return cxtype::MakeCXType(QualType(), getCursorTU(C));
+ }
+
+ return cxtype::MakeCXType(TA.getAsType(), getCursorTU(C));
+}
+
+long long clang_Cursor_getTemplateArgumentValue(CXCursor C, unsigned I) {
+ TemplateArgument TA;
+ if (clang_Cursor_getTemplateArgument(C, I, &TA) !=
+ CXGetTemplateArgumentStatus_Success) {
+ assert(0 && "Unable to retrieve TemplateArgument");
+ return 0;
+ }
+
+ if (TA.getKind() != TemplateArgument::Integral) {
+ assert(0 && "Passed template argument is not Integral");
+ return 0;
+ }
+
+ return TA.getAsIntegral().getSExtValue();
+}
+
+unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C,
+ unsigned I) {
+ TemplateArgument TA;
+ if (clang_Cursor_getTemplateArgument(C, I, &TA) !=
+ CXGetTemplateArgumentStatus_Success) {
+ assert(0 && "Unable to retrieve TemplateArgument");
+ return 0;
+ }
+
+ if (TA.getKind() != TemplateArgument::Integral) {
+ assert(0 && "Passed template argument is not Integral");
+ return 0;
+ }
+
+ return TA.getAsIntegral().getZExtValue();
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
@@ -1262,8 +1417,16 @@ int clang_Cursor_isDynamicCall(CXCursor C) {
if (!E)
return 0;
- if (const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E))
- return MsgE->getReceiverKind() == ObjCMessageExpr::Instance;
+ if (const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E)) {
+ if (MsgE->getReceiverKind() != ObjCMessageExpr::Instance)
+ return false;
+ if (auto *RecE = dyn_cast<ObjCMessageExpr>(
+ MsgE->getInstanceReceiver()->IgnoreParenCasts())) {
+ if (RecE->getMethodFamily() == OMF_alloc)
+ return false;
+ }
+ return true;
+ }
const MemberExpr *ME = nullptr;
if (isa<MemberExpr>(E))
diff --git a/tools/libclang/CXCursor.h b/tools/libclang/CXCursor.h
index fee3bac..931d112 100644
--- a/tools/libclang/CXCursor.h
+++ b/tools/libclang/CXCursor.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXCURSOR_H
-#define LLVM_CLANG_CXCURSOR_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXCURSOR_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXCURSOR_H
#include "clang-c/Index.h"
#include "clang/Basic/SourceLocation.h"
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index ddf3749..fe5599a 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -16,7 +16,8 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Frontend/SerializedDiagnosticPrinter.h"
+#include "clang/Frontend/SerializedDiagnosticReader.h"
+#include "clang/Frontend/SerializedDiagnostics.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
@@ -183,475 +184,207 @@ void CXLoadedDiagnostic::decodeLocation(CXSourceLocation location,
// Deserialize diagnostics.
//===----------------------------------------------------------------------===//
-enum { MaxSupportedVersion = 2 };
-typedef SmallVector<uint64_t, 64> RecordData;
-enum LoadResult { Failure = 1, Success = 0 };
-enum StreamResult { Read_EndOfStream,
- Read_BlockBegin,
- Read_Failure,
- Read_Record,
- Read_BlockEnd };
-
namespace {
-class DiagLoader {
+class DiagLoader : serialized_diags::SerializedDiagnosticReader {
enum CXLoadDiag_Error *error;
CXString *errorString;
-
- void reportBad(enum CXLoadDiag_Error code, llvm::StringRef err) {
+ std::unique_ptr<CXLoadedDiagnosticSetImpl> TopDiags;
+ SmallVector<std::unique_ptr<CXLoadedDiagnostic>, 8> CurrentDiags;
+
+ std::error_code reportBad(enum CXLoadDiag_Error code, llvm::StringRef err) {
if (error)
*error = code;
if (errorString)
*errorString = cxstring::createDup(err);
+ return serialized_diags::SDError::HandlerFailed;
}
- void reportInvalidFile(llvm::StringRef err) {
+ std::error_code reportInvalidFile(llvm::StringRef err) {
return reportBad(CXLoadDiag_InvalidFile, err);
}
- LoadResult readMetaBlock(llvm::BitstreamCursor &Stream);
-
- LoadResult readDiagnosticBlock(llvm::BitstreamCursor &Stream,
- CXDiagnosticSetImpl &Diags,
- CXLoadedDiagnosticSetImpl &TopDiags);
-
- StreamResult readToNextRecordOrBlock(llvm::BitstreamCursor &Stream,
- llvm::StringRef errorContext,
- unsigned &BlockOrRecordID,
- bool atTopLevel = false);
-
-
- LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
- Strings &strings, llvm::StringRef errorContext,
- RecordData &Record,
- StringRef Blob,
- bool allowEmptyString = false);
-
- LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
- const char *&RetStr,
- llvm::StringRef errorContext,
- RecordData &Record,
- StringRef Blob,
- bool allowEmptyString = false);
-
- LoadResult readRange(CXLoadedDiagnosticSetImpl &TopDiags,
- RecordData &Record, unsigned RecStartIdx,
- CXSourceRange &SR);
-
- LoadResult readLocation(CXLoadedDiagnosticSetImpl &TopDiags,
- RecordData &Record, unsigned &offset,
- CXLoadedDiagnostic::Location &Loc);
-
-public:
- DiagLoader(enum CXLoadDiag_Error *e, CXString *es)
- : error(e), errorString(es) {
- if (error)
- *error = CXLoadDiag_None;
- if (errorString)
- *errorString = cxstring::createEmpty();
- }
+ std::error_code readRange(const serialized_diags::Location &SDStart,
+ const serialized_diags::Location &SDEnd,
+ CXSourceRange &SR);
- CXDiagnosticSet load(const char *file);
-};
-}
+ std::error_code readLocation(const serialized_diags::Location &SDLoc,
+ CXLoadedDiagnostic::Location &LoadedLoc);
-CXDiagnosticSet DiagLoader::load(const char *file) {
- // Open the diagnostics file.
- std::string ErrStr;
- FileSystemOptions FO;
- FileManager FileMgr(FO);
+protected:
+ std::error_code visitStartOfDiagnostic() override;
+ std::error_code visitEndOfDiagnostic() override;
- std::unique_ptr<llvm::MemoryBuffer> Buffer;
- Buffer.reset(FileMgr.getBufferForFile(file));
+ std::error_code visitCategoryRecord(unsigned ID, StringRef Name) override;
- if (!Buffer) {
- reportBad(CXLoadDiag_CannotLoad, ErrStr);
- return nullptr;
- }
+ std::error_code visitDiagFlagRecord(unsigned ID, StringRef Name) override;
- llvm::BitstreamReader StreamFile;
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
-
- llvm::BitstreamCursor Stream;
- Stream.init(StreamFile);
-
- // Sniff for the signature.
- if (Stream.Read(8) != 'D' ||
- Stream.Read(8) != 'I' ||
- Stream.Read(8) != 'A' ||
- Stream.Read(8) != 'G') {
- reportBad(CXLoadDiag_InvalidFile,
- "Bad header in diagnostics file");
- return nullptr;
- }
+ std::error_code visitDiagnosticRecord(
+ unsigned Severity, const serialized_diags::Location &Location,
+ unsigned Category, unsigned Flag, StringRef Message) override;
- std::unique_ptr<CXLoadedDiagnosticSetImpl> Diags(
- new CXLoadedDiagnosticSetImpl());
-
- while (true) {
- unsigned BlockID = 0;
- StreamResult Res = readToNextRecordOrBlock(Stream, "Top-level",
- BlockID, true);
- switch (Res) {
- case Read_EndOfStream:
- return (CXDiagnosticSet)Diags.release();
- case Read_Failure:
- return nullptr;
- case Read_Record:
- llvm_unreachable("Top-level does not have records");
- case Read_BlockEnd:
- continue;
- case Read_BlockBegin:
- break;
- }
-
- switch (BlockID) {
- case serialized_diags::BLOCK_META:
- if (readMetaBlock(Stream))
- return nullptr;
- break;
- case serialized_diags::BLOCK_DIAG:
- if (readDiagnosticBlock(Stream, *Diags.get(), *Diags.get()))
- return nullptr;
- break;
- default:
- if (!Stream.SkipBlock()) {
- reportInvalidFile("Malformed block at top-level of diagnostics file");
- return nullptr;
- }
- break;
- }
+ std::error_code visitFilenameRecord(unsigned ID, unsigned Size,
+ unsigned Timestamp,
+ StringRef Name) override;
+
+ std::error_code visitFixitRecord(const serialized_diags::Location &Start,
+ const serialized_diags::Location &End,
+ StringRef CodeToInsert) override;
+
+ std::error_code
+ visitSourceRangeRecord(const serialized_diags::Location &Start,
+ const serialized_diags::Location &End) override;
+
+public:
+ DiagLoader(enum CXLoadDiag_Error *e, CXString *es)
+ : SerializedDiagnosticReader(), error(e), errorString(es) {
+ if (error)
+ *error = CXLoadDiag_None;
+ if (errorString)
+ *errorString = cxstring::createEmpty();
}
+
+ CXDiagnosticSet load(const char *file);
+};
}
-StreamResult DiagLoader::readToNextRecordOrBlock(llvm::BitstreamCursor &Stream,
- llvm::StringRef errorContext,
- unsigned &blockOrRecordID,
- bool atTopLevel) {
-
- blockOrRecordID = 0;
-
- while (!Stream.AtEndOfStream()) {
- unsigned Code = Stream.ReadCode();
-
- // Handle the top-level specially.
- if (atTopLevel) {
- if (Code == llvm::bitc::ENTER_SUBBLOCK) {
- unsigned BlockID = Stream.ReadSubBlockID();
- if (BlockID == llvm::bitc::BLOCKINFO_BLOCK_ID) {
- if (Stream.ReadBlockInfoBlock()) {
- reportInvalidFile("Malformed BlockInfoBlock in diagnostics file");
- return Read_Failure;
- }
- continue;
- }
- blockOrRecordID = BlockID;
- return Read_BlockBegin;
- }
- reportInvalidFile("Only blocks can appear at the top of a "
- "diagnostic file");
- return Read_Failure;
- }
-
- switch ((llvm::bitc::FixedAbbrevIDs)Code) {
- case llvm::bitc::ENTER_SUBBLOCK:
- blockOrRecordID = Stream.ReadSubBlockID();
- return Read_BlockBegin;
-
- case llvm::bitc::END_BLOCK:
- if (Stream.ReadBlockEnd()) {
- reportInvalidFile("Cannot read end of block");
- return Read_Failure;
- }
- return Read_BlockEnd;
-
- case llvm::bitc::DEFINE_ABBREV:
- Stream.ReadAbbrevRecord();
- continue;
-
- case llvm::bitc::UNABBREV_RECORD:
- reportInvalidFile("Diagnostics file should have no unabbreviated "
- "records");
- return Read_Failure;
-
- default:
- // We found a record.
- blockOrRecordID = Code;
- return Read_Record;
+CXDiagnosticSet DiagLoader::load(const char *file) {
+ TopDiags = llvm::make_unique<CXLoadedDiagnosticSetImpl>();
+
+ std::error_code EC = readDiagnostics(file);
+ if (EC) {
+ switch (EC.value()) {
+ case static_cast<int>(serialized_diags::SDError::HandlerFailed):
+ // We've already reported the problem.
+ break;
+ case static_cast<int>(serialized_diags::SDError::CouldNotLoad):
+ reportBad(CXLoadDiag_CannotLoad, EC.message());
+ break;
+ default:
+ reportInvalidFile(EC.message());
+ break;
}
+ return 0;
}
-
- if (atTopLevel)
- return Read_EndOfStream;
-
- reportInvalidFile(Twine("Premature end of diagnostics file within ").str() +
- errorContext.str());
- return Read_Failure;
+
+ return (CXDiagnosticSet)TopDiags.release();
}
-LoadResult DiagLoader::readMetaBlock(llvm::BitstreamCursor &Stream) {
- if (Stream.EnterSubBlock(clang::serialized_diags::BLOCK_META)) {
- reportInvalidFile("Malformed metadata block");
- return Failure;
- }
-
- bool versionChecked = false;
-
- while (true) {
- unsigned blockOrCode = 0;
- StreamResult Res = readToNextRecordOrBlock(Stream, "Metadata Block",
- blockOrCode);
-
- switch(Res) {
- case Read_EndOfStream:
- llvm_unreachable("EndOfStream handled by readToNextRecordOrBlock");
- case Read_Failure:
- return Failure;
- case Read_Record:
- break;
- case Read_BlockBegin:
- if (Stream.SkipBlock()) {
- reportInvalidFile("Malformed metadata block");
- return Failure;
- }
- case Read_BlockEnd:
- if (!versionChecked) {
- reportInvalidFile("Diagnostics file does not contain version"
- " information");
- return Failure;
- }
- return Success;
- }
-
- RecordData Record;
- unsigned recordID = Stream.readRecord(blockOrCode, Record);
-
- if (recordID == serialized_diags::RECORD_VERSION) {
- if (Record.size() < 1) {
- reportInvalidFile("malformed VERSION identifier in diagnostics file");
- return Failure;
- }
- if (Record[0] > MaxSupportedVersion) {
- reportInvalidFile("diagnostics file is a newer version than the one "
- "supported");
- return Failure;
- }
- versionChecked = true;
- }
+std::error_code
+DiagLoader::readLocation(const serialized_diags::Location &SDLoc,
+ CXLoadedDiagnostic::Location &LoadedLoc) {
+ unsigned FileID = SDLoc.FileID;
+ if (FileID == 0)
+ LoadedLoc.file = nullptr;
+ else {
+ LoadedLoc.file = const_cast<FileEntry *>(TopDiags->Files[FileID]);
+ if (!LoadedLoc.file)
+ return reportInvalidFile("Corrupted file entry in source location");
}
+ LoadedLoc.line = SDLoc.Line;
+ LoadedLoc.column = SDLoc.Col;
+ LoadedLoc.offset = SDLoc.Offset;
+ return std::error_code();
}
-LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
- const char *&RetStr,
- llvm::StringRef errorContext,
- RecordData &Record,
- StringRef Blob,
- bool allowEmptyString) {
+std::error_code
+DiagLoader::readRange(const serialized_diags::Location &SDStart,
+ const serialized_diags::Location &SDEnd,
+ CXSourceRange &SR) {
+ CXLoadedDiagnostic::Location *Start, *End;
+ Start = TopDiags->Alloc.Allocate<CXLoadedDiagnostic::Location>();
+ End = TopDiags->Alloc.Allocate<CXLoadedDiagnostic::Location>();
+
+ std::error_code EC;
+ if ((EC = readLocation(SDStart, *Start)))
+ return EC;
+ if ((EC = readLocation(SDEnd, *End)))
+ return EC;
- // Basic buffer overflow check.
- if (Blob.size() > 65536) {
- reportInvalidFile(std::string("Out-of-bounds string in ") +
- std::string(errorContext));
- return Failure;
- }
+ CXSourceLocation startLoc = makeLocation(Start);
+ CXSourceLocation endLoc = makeLocation(End);
+ SR = clang_getRange(startLoc, endLoc);
+ return std::error_code();
+}
- if (allowEmptyString && Record.size() >= 1 && Blob.size() == 0) {
- RetStr = "";
- return Success;
- }
-
- if (Record.size() < 1 || Blob.size() == 0) {
- reportInvalidFile(std::string("Corrupted ") + std::string(errorContext)
- + std::string(" entry"));
- return Failure;
- }
-
- RetStr = TopDiags.copyString(Blob);
- return Success;
+std::error_code DiagLoader::visitStartOfDiagnostic() {
+ CurrentDiags.push_back(llvm::make_unique<CXLoadedDiagnostic>());
+ return std::error_code();
}
-LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
- Strings &strings,
- llvm::StringRef errorContext,
- RecordData &Record,
- StringRef Blob,
- bool allowEmptyString) {
- const char *RetStr;
- if (readString(TopDiags, RetStr, errorContext, Record, Blob,
- allowEmptyString))
- return Failure;
- strings[Record[0]] = RetStr;
- return Success;
+std::error_code DiagLoader::visitEndOfDiagnostic() {
+ auto D = CurrentDiags.pop_back_val();
+ if (CurrentDiags.empty())
+ TopDiags->appendDiagnostic(std::move(D));
+ else
+ CurrentDiags.back()->getChildDiagnostics().appendDiagnostic(std::move(D));
+ return std::error_code();
}
-LoadResult DiagLoader::readLocation(CXLoadedDiagnosticSetImpl &TopDiags,
- RecordData &Record, unsigned &offset,
- CXLoadedDiagnostic::Location &Loc) {
- if (Record.size() < offset + 3) {
- reportInvalidFile("Corrupted source location");
- return Failure;
- }
-
- unsigned fileID = Record[offset++];
- if (fileID == 0) {
- // Sentinel value.
- Loc.file = nullptr;
- Loc.line = 0;
- Loc.column = 0;
- Loc.offset = 0;
- return Success;
- }
+std::error_code DiagLoader::visitCategoryRecord(unsigned ID, StringRef Name) {
+ // FIXME: Why do we care about long strings?
+ if (Name.size() > 65536)
+ return reportInvalidFile("Out-of-bounds string in category");
+ TopDiags->Categories[ID] = TopDiags->copyString(Name);
+ return std::error_code();
+}
- const FileEntry *FE = TopDiags.Files[fileID];
- if (!FE) {
- reportInvalidFile("Corrupted file entry in source location");
- return Failure;
- }
- Loc.file = const_cast<FileEntry *>(FE);
- Loc.line = Record[offset++];
- Loc.column = Record[offset++];
- Loc.offset = Record[offset++];
- return Success;
+std::error_code DiagLoader::visitDiagFlagRecord(unsigned ID, StringRef Name) {
+ // FIXME: Why do we care about long strings?
+ if (Name.size() > 65536)
+ return reportInvalidFile("Out-of-bounds string in warning flag");
+ TopDiags->WarningFlags[ID] = TopDiags->copyString(Name);
+ return std::error_code();
}
-LoadResult DiagLoader::readRange(CXLoadedDiagnosticSetImpl &TopDiags,
- RecordData &Record,
- unsigned int RecStartIdx,
- CXSourceRange &SR) {
- CXLoadedDiagnostic::Location *Start, *End;
- Start = TopDiags.Alloc.Allocate<CXLoadedDiagnostic::Location>();
- End = TopDiags.Alloc.Allocate<CXLoadedDiagnostic::Location>();
-
- if (readLocation(TopDiags, Record, RecStartIdx, *Start))
- return Failure;
- if (readLocation(TopDiags, Record, RecStartIdx, *End))
- return Failure;
-
- CXSourceLocation startLoc = makeLocation(Start);
- CXSourceLocation endLoc = makeLocation(End);
- SR = clang_getRange(startLoc, endLoc);
- return Success;
+std::error_code DiagLoader::visitFilenameRecord(unsigned ID, unsigned Size,
+ unsigned Timestamp,
+ StringRef Name) {
+ // FIXME: Why do we care about long strings?
+ if (Name.size() > 65536)
+ return reportInvalidFile("Out-of-bounds string in filename");
+ TopDiags->FileNames[ID] = TopDiags->copyString(Name);
+ TopDiags->Files[ID] =
+ TopDiags->FakeFiles.getVirtualFile(Name, Size, Timestamp);
+ return std::error_code();
}
-LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
- CXDiagnosticSetImpl &Diags,
- CXLoadedDiagnosticSetImpl &TopDiags){
+std::error_code
+DiagLoader::visitSourceRangeRecord(const serialized_diags::Location &Start,
+ const serialized_diags::Location &End) {
+ CXSourceRange SR;
+ if (std::error_code EC = readRange(Start, End, SR))
+ return EC;
+ CurrentDiags.back()->Ranges.push_back(SR);
+ return std::error_code();
+}
- if (Stream.EnterSubBlock(clang::serialized_diags::BLOCK_DIAG)) {
- reportInvalidFile("malformed diagnostic block");
- return Failure;
- }
+std::error_code
+DiagLoader::visitFixitRecord(const serialized_diags::Location &Start,
+ const serialized_diags::Location &End,
+ StringRef CodeToInsert) {
+ CXSourceRange SR;
+ if (std::error_code EC = readRange(Start, End, SR))
+ return EC;
+ // FIXME: Why do we care about long strings?
+ if (CodeToInsert.size() > 65536)
+ return reportInvalidFile("Out-of-bounds string in FIXIT");
+ CurrentDiags.back()->FixIts.push_back(
+ std::make_pair(SR, TopDiags->copyString(CodeToInsert)));
+ return std::error_code();
+}
- std::unique_ptr<CXLoadedDiagnostic> D(new CXLoadedDiagnostic());
- RecordData Record;
-
- while (true) {
- unsigned blockOrCode = 0;
- StreamResult Res = readToNextRecordOrBlock(Stream, "Diagnostic Block",
- blockOrCode);
- switch (Res) {
- case Read_EndOfStream:
- llvm_unreachable("EndOfStream handled in readToNextRecordOrBlock");
- case Read_Failure:
- return Failure;
- case Read_BlockBegin: {
- // The only blocks we care about are subdiagnostics.
- if (blockOrCode != serialized_diags::BLOCK_DIAG) {
- if (!Stream.SkipBlock()) {
- reportInvalidFile("Invalid subblock in Diagnostics block");
- return Failure;
- }
- } else if (readDiagnosticBlock(Stream, D->getChildDiagnostics(),
- TopDiags)) {
- return Failure;
- }
-
- continue;
- }
- case Read_BlockEnd:
- Diags.appendDiagnostic(D.release());
- return Success;
- case Read_Record:
- break;
- }
-
- // Read the record.
- Record.clear();
- StringRef Blob;
- unsigned recID = Stream.readRecord(blockOrCode, Record, &Blob);
-
- if (recID < serialized_diags::RECORD_FIRST ||
- recID > serialized_diags::RECORD_LAST)
- continue;
-
- switch ((serialized_diags::RecordIDs)recID) {
- case serialized_diags::RECORD_VERSION:
- continue;
- case serialized_diags::RECORD_CATEGORY:
- if (readString(TopDiags, TopDiags.Categories, "category", Record,
- Blob, /* allowEmptyString */ true))
- return Failure;
- continue;
-
- case serialized_diags::RECORD_DIAG_FLAG:
- if (readString(TopDiags, TopDiags.WarningFlags, "warning flag", Record,
- Blob))
- return Failure;
- continue;
-
- case serialized_diags::RECORD_FILENAME: {
- if (readString(TopDiags, TopDiags.FileNames, "filename", Record,
- Blob))
- return Failure;
-
- if (Record.size() < 3) {
- reportInvalidFile("Invalid file entry");
- return Failure;
- }
-
- const FileEntry *FE =
- TopDiags.FakeFiles.getVirtualFile(TopDiags.FileNames[Record[0]],
- /* size */ Record[1],
- /* time */ Record[2]);
-
- TopDiags.Files[Record[0]] = FE;
- continue;
- }
-
- case serialized_diags::RECORD_SOURCE_RANGE: {
- CXSourceRange SR;
- if (readRange(TopDiags, Record, 0, SR))
- return Failure;
- D->Ranges.push_back(SR);
- continue;
- }
-
- case serialized_diags::RECORD_FIXIT: {
- CXSourceRange SR;
- if (readRange(TopDiags, Record, 0, SR))
- return Failure;
- const char *RetStr;
- if (readString(TopDiags, RetStr, "FIXIT", Record, Blob,
- /* allowEmptyString */ true))
- return Failure;
- D->FixIts.push_back(std::make_pair(SR, RetStr));
- continue;
- }
-
- case serialized_diags::RECORD_DIAG: {
- D->severity = Record[0];
- unsigned offset = 1;
- if (readLocation(TopDiags, Record, offset, D->DiagLoc))
- return Failure;
- D->category = Record[offset++];
- unsigned diagFlag = Record[offset++];
- D->DiagOption = diagFlag ? TopDiags.WarningFlags[diagFlag] : "";
- D->CategoryText = D->category ? TopDiags.Categories[D->category] : "";
- D->Spelling = TopDiags.copyString(Blob);
- continue;
- }
- }
- }
+std::error_code DiagLoader::visitDiagnosticRecord(
+ unsigned Severity, const serialized_diags::Location &Location,
+ unsigned Category, unsigned Flag, StringRef Message) {
+ CXLoadedDiagnostic &D = *CurrentDiags.back();
+ D.severity = Severity;
+ if (std::error_code EC = readLocation(Location, D.DiagLoc))
+ return EC;
+ D.category = Category;
+ D.DiagOption = Flag ? TopDiags->WarningFlags[Flag] : "";
+ D.CategoryText = Category ? TopDiags->Categories[Category] : "";
+ D.Spelling = TopDiags->copyString(Message);
+ return std::error_code();
}
extern "C" {
diff --git a/tools/libclang/CXLoadedDiagnostic.h b/tools/libclang/CXLoadedDiagnostic.h
index c281f9b..54261be 100644
--- a/tools/libclang/CXLoadedDiagnostic.h
+++ b/tools/libclang/CXLoadedDiagnostic.h
@@ -11,8 +11,8 @@
|* *|
\*===----------------------------------------------------------------------===*/
-#ifndef LLVM_CLANG_CINDEX_LOADED_DIAGNOSTIC_H
-#define LLVM_CLANG_CINDEX_LOADED_DIAGNOSTIC_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
#include "CIndexDiagnostic.h"
#include "llvm/ADT/StringRef.h"
diff --git a/tools/libclang/CXSourceLocation.h b/tools/libclang/CXSourceLocation.h
index f97ac1f..f0b3f49 100644
--- a/tools/libclang/CXSourceLocation.h
+++ b/tools/libclang/CXSourceLocation.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXSOURCELOCATION_H
-#define LLVM_CLANG_CXSOURCELOCATION_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXSOURCELOCATION_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXSOURCELOCATION_H
#include "clang-c/Index.h"
#include "clang/AST/ASTContext.h"
diff --git a/tools/libclang/CXString.h b/tools/libclang/CXString.h
index ed3ed4a..f6b46f7 100644
--- a/tools/libclang/CXString.h
+++ b/tools/libclang/CXString.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXSTRING_H
-#define LLVM_CLANG_CXSTRING_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXSTRING_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXSTRING_H
#include "clang-c/Index.h"
#include "clang/Basic/LLVM.h"
diff --git a/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h
index d86ed2b..6022c9d 100644
--- a/tools/libclang/CXTranslationUnit.h
+++ b/tools/libclang/CXTranslationUnit.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXTRANSLATIONUNIT_H
-#define LLVM_CLANG_CXTRANSLATIONUNIT_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
#include "CLog.h"
#include "CXString.h"
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index fe45899..81cff5a 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -520,6 +520,7 @@ CXCallingConv clang_getFunctionTypeCallingConv(CXType X) {
TCALLINGCONV(X86FastCall);
TCALLINGCONV(X86ThisCall);
TCALLINGCONV(X86Pascal);
+ TCALLINGCONV(X86VectorCall);
TCALLINGCONV(X86_64Win64);
TCALLINGCONV(X86_64SysV);
TCALLINGCONV(AAPCS);
diff --git a/tools/libclang/CXType.h b/tools/libclang/CXType.h
index 7660beb..941cc0a9 100644
--- a/tools/libclang/CXType.h
+++ b/tools/libclang/CXType.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_CXTYPES_H
-#define LLVM_CLANG_CXTYPES_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXTYPE_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CXTYPE_H
#include "clang-c/Index.h"
#include "clang/AST/Type.h"
diff --git a/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h
index c4ec7b6..1b2a922 100644
--- a/tools/libclang/CursorVisitor.h
+++ b/tools/libclang/CursorVisitor.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_LIBCLANG_CURSORVISITOR_H
-#define LLVM_CLANG_LIBCLANG_CURSORVISITOR_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CURSORVISITOR_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_CURSORVISITOR_H
#include "CXCursor.h"
#include "CXTranslationUnit.h"
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp
index 7dc53a6..5539971 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -150,7 +150,7 @@ public:
}
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C) {
- if (C->capturesThis())
+ if (C->capturesThis() || C->capturesVLAType())
return true;
if (C->capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
diff --git a/tools/libclang/IndexTypeSourceInfo.cpp b/tools/libclang/IndexTypeSourceInfo.cpp
index f13c0af..706870e 100644
--- a/tools/libclang/IndexTypeSourceInfo.cpp
+++ b/tools/libclang/IndexTypeSourceInfo.cpp
@@ -129,6 +129,7 @@ void IndexingContext::indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
switch (NNS.getNestedNameSpecifier()->getKind()) {
case NestedNameSpecifier::Identifier:
case NestedNameSpecifier::Global:
+ case NestedNameSpecifier::Super:
break;
case NestedNameSpecifier::Namespace:
diff --git a/tools/libclang/Index_Internal.h b/tools/libclang/Index_Internal.h
index 2d42cb8..98f069c8 100644
--- a/tools/libclang/Index_Internal.h
+++ b/tools/libclang/Index_Internal.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBCLANG_INDEX_INTERNAL_H
-#define LLVM_LIBCLANG_INDEX_INTERNAL_H
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_INDEX_INTERNAL_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_INDEX_INTERNAL_H
#include "clang-c/Index.h"
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 58af618..20f4474 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -414,8 +414,8 @@ public:
: IndexCtx(clientData, indexCallbacks, indexOptions, cxTU),
CXTU(cxTU), SKData(skData) { }
- ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) override {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override {
PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
if (!PPOpts.ImplicitPCHInclude.empty()) {
@@ -425,17 +425,16 @@ public:
IndexCtx.setASTContext(CI.getASTContext());
Preprocessor &PP = CI.getPreprocessor();
- PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx));
+ PP.addPPCallbacks(llvm::make_unique<IndexPPCallbacks>(PP, IndexCtx));
IndexCtx.setPreprocessor(PP);
if (SKData) {
- PPConditionalDirectiveRecord *
- PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager());
- PP.addPPCallbacks(PPRec);
- SKCtrl.reset(new TUSkipBodyControl(*SKData, *PPRec, PP));
+ auto *PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager());
+ PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec));
+ SKCtrl = llvm::make_unique<TUSkipBodyControl>(*SKData, *PPRec, PP);
}
- return new IndexingConsumer(IndexCtx, SKCtrl.get());
+ return llvm::make_unique<IndexingConsumer>(IndexCtx, SKCtrl.get());
}
void EndSourceFileAction() override {
@@ -576,10 +575,10 @@ static void clang_indexSourceFile_Impl(void *UserData) {
BufOwner.get());
for (auto &UF : ITUI->unsaved_files) {
- llvm::MemoryBuffer *MB =
+ std::unique_ptr<llvm::MemoryBuffer> MB =
llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename);
- BufOwner->push_back(std::unique_ptr<llvm::MemoryBuffer>(MB));
- CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB);
+ CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB.get());
+ BufOwner->push_back(std::move(MB));
}
// Since libclang is primarily used by batch tools dealing with
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index c3851cd..31fddfb 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_TOOLS_LIBCLANG_INDEXINGCONTEXT_H
+#define LLVM_CLANG_TOOLS_LIBCLANG_INDEXINGCONTEXT_H
+
#include "CXCursor.h"
#include "Index_Internal.h"
#include "clang/AST/DeclGroup.h"
@@ -517,3 +520,5 @@ inline T *ScratchAlloc::allocate() {
}
}} // end clang::cxindex
+
+#endif
diff --git a/tools/libclang/Makefile b/tools/libclang/Makefile
index db3d4f8..97f663c 100644
--- a/tools/libclang/Makefile
+++ b/tools/libclang/Makefile
@@ -16,11 +16,11 @@ LINK_LIBS_IN_SHARED = 1
SHARED_LIBRARY = 1
include $(CLANG_LEVEL)/../../Makefile.config
-LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
+LINK_COMPONENTS := AsmParser BitReader Core MC MCParser Option Support
USEDLIBS = clangIndex.a clangARCMigrate.a \
clangRewriteFrontend.a \
clangFormat.a \
- clangTooling.a \
+ clangTooling.a clangToolingCore.a \
clangFrontend.a clangDriver.a \
clangSerialization.a \
clangParse.a clangSema.a \
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 48eec25..fa2c0e7 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -7,8 +7,14 @@ clang_CXXMethod_isPureVirtual
clang_CXXMethod_isStatic
clang_CXXMethod_isVirtual
clang_Cursor_getArgument
+clang_Cursor_getNumTemplateArguments
+clang_Cursor_getTemplateArgumentKind
+clang_Cursor_getTemplateArgumentType
+clang_Cursor_getTemplateArgumentValue
+clang_Cursor_getTemplateArgumentUnsignedValue
clang_Cursor_getBriefCommentText
clang_Cursor_getCommentRange
+clang_Cursor_getMangling
clang_Cursor_getParsedComment
clang_Cursor_getRawCommentText
clang_Cursor_getNumArguments
@@ -24,6 +30,8 @@ clang_Cursor_isNull
clang_Cursor_isObjCOptional
clang_Cursor_isVariadic
clang_Cursor_getModule
+clang_Cursor_getStorageClass
+clang_File_isEqual
clang_Module_getASTFile
clang_Module_getParent
clang_Module_getName
OpenPOWER on IntegriCloud