summaryrefslogtreecommitdiffstats
path: root/tools/libclang
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-07-13 17:21:42 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-07-13 17:21:42 +0000
commit1928da94b55683957759d5c5ff4593a118773394 (patch)
tree48b44512b5db8ced345df4a1a56b5065cf2a14d9 /tools/libclang
parent53992adde3eda3ccf9da63bc7e45673f043de18f (diff)
downloadFreeBSD-src-1928da94b55683957759d5c5ff4593a118773394.zip
FreeBSD-src-1928da94b55683957759d5c5ff4593a118773394.tar.gz
Update clang to r108243.
Diffstat (limited to 'tools/libclang')
-rw-r--r--tools/libclang/CIndex.cpp41
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp5
-rw-r--r--tools/libclang/CIndexer.cpp1
-rw-r--r--tools/libclang/CMakeLists.txt3
-rw-r--r--tools/libclang/CXCursor.cpp8
-rw-r--r--tools/libclang/CXSourceLocation.h7
-rw-r--r--tools/libclang/CXTypes.cpp39
-rw-r--r--tools/libclang/Makefile11
-rw-r--r--tools/libclang/libclang.darwin.exports3
-rw-r--r--tools/libclang/libclang.exports4
10 files changed, 84 insertions, 38 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index a077589..7f32a1c 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -177,12 +177,12 @@ static RangeComparisonResult LocationCompare(SourceManager &SM,
/// does the appropriate translation.
CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
const LangOptions &LangOpts,
- SourceRange R) {
+ const CharSourceRange &R) {
// We want the last character in this location, so we will adjust the
// location accordingly.
// FIXME: How do do this with a macro instantiation location?
SourceLocation EndLoc = R.getEnd();
- if (!EndLoc.isInvalid() && EndLoc.isFileID()) {
+ if (R.isTokenRange() && !EndLoc.isInvalid() && EndLoc.isFileID()) {
unsigned Length = Lexer::MeasureTokenLength(EndLoc, SM, LangOpts);
EndLoc = EndLoc.getFileLocWithOffset(Length);
}
@@ -517,10 +517,8 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
}
bool CursorVisitor::VisitBlockDecl(BlockDecl *B) {
- for (BlockDecl::param_iterator I=B->param_begin(), E=B->param_end(); I!=E;++I)
- if (Decl *D = *I)
- if (Visit(D))
- return true;
+ if (Visit(B->getSignatureAsWritten()->getTypeLoc()))
+ return true;
return Visit(MakeCXCursor(B->getBody(), StmtParent, TU));
}
@@ -672,6 +670,9 @@ bool CursorVisitor::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
}
bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) {
+ if (Visit(PD->getTypeSourceInfo()->getTypeLoc()))
+ return true;
+
// FIXME: This implements a workaround with @property declarations also being
// installed in the DeclContext for the @interface. Eventually this code
// should be removed.
@@ -1183,6 +1184,15 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
// in the actual argument list.
if (source_filename)
Args.push_back(source_filename);
+
+ // Since the Clang C library is primarily used by batch tools dealing with
+ // (often very broken) source code, where spell-checking can have a
+ // significant negative impact on performance (particularly when
+ // precompiled headers are involved), we disable it by default.
+ // Note that we place this argument early in the list, so that it can be
+ // overridden by the caller with "-fspell-checking".
+ Args.push_back("-fno-spell-checking");
+
Args.insert(Args.end(), command_line_args,
command_line_args + num_command_line_args);
Args.push_back("-Xclang");
@@ -1246,6 +1256,14 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
argv.push_back("-o");
char astTmpFile[L_tmpnam];
argv.push_back(tmpnam(astTmpFile));
+
+ // Since the Clang C library is primarily used by batch tools dealing with
+ // (often very broken) source code, where spell-checking can have a
+ // significant negative impact on performance (particularly when
+ // precompiled headers are involved), we disable it by default.
+ // Note that we place this argument early in the list, so that it can be
+ // overridden by the caller with "-fspell-checking".
+ argv.push_back("-fno-spell-checking");
// Remap any unsaved files to temporary files.
std::vector<llvm::sys::Path> TemporaryFiles;
@@ -1479,16 +1497,6 @@ CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
return Result;
}
-unsigned clang_isFromMainFile(CXSourceLocation loc) {
- SourceLocation Loc = SourceLocation::getFromRawEncoding(loc.int_data);
- if (!loc.ptr_data[0] || Loc.isInvalid())
- return 0;
-
- const SourceManager &SM =
- *static_cast<const SourceManager*>(loc.ptr_data[0]);
- return SM.isFromMainFile(Loc) ? 1 : 0;
-}
-
} // end: extern "C"
//===----------------------------------------------------------------------===//
@@ -2048,6 +2056,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
case Decl::TemplateTemplateParm:
case Decl::ObjCCategoryImpl:
case Decl::ObjCImplementation:
+ case Decl::AccessSpec:
case Decl::LinkageSpec:
case Decl::ObjCPropertyImpl:
case Decl::FileScopeAsm:
diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index 481a375..277fadf 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/tools/libclang/CIndexCodeCompletion.cpp
@@ -202,7 +202,7 @@ unsigned clang_getNumCompletionChunks(CXCompletionString completion_string) {
unsigned clang_getCompletionPriority(CXCompletionString completion_string) {
CXStoredCodeCompletionString *CCStr
= (CXStoredCodeCompletionString *)completion_string;
- return CCStr? CCStr->getPriority() : CCP_Unlikely;
+ return CCStr? CCStr->getPriority() : unsigned(CCP_Unlikely);
}
static bool ReadUnsigned(const char *&Memory, const char *MemoryEnd,
@@ -291,6 +291,9 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
llvm::sys::Path ClangPath = CXXIdx->getClangPath();
argv.push_back(ClangPath.c_str());
+ // Always use Clang C++ support.
+ argv.push_back("-ccc-clang-cxx");
+
// Add the '-fsyntax-only' argument so that we only perform a basic
// syntax check of the code.
argv.push_back("-fsyntax-only");
diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp
index d5131ff..cdf6c61 100644
--- a/tools/libclang/CIndexer.cpp
+++ b/tools/libclang/CIndexer.cpp
@@ -135,6 +135,7 @@ bool clang::RemapFiles(unsigned num_unsaved_files,
OS.close();
if (OS.has_error()) {
SavedFile.eraseFromDisk();
+ OS.clear_error();
return true;
}
diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
index 62c9738..ab4acca 100644
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -3,7 +3,7 @@ set(SHARED_LIBRARY TRUE)
set(LLVM_NO_RTTI 1)
set(LLVM_USED_LIBS
- clangFrontend
+ clangFrontend
clangDriver
clangSema
clangAnalysis
@@ -29,7 +29,6 @@ add_clang_library(libclang
CXTypes.cpp
../../include/clang-c/Index.h
)
-set_target_properties(libclang PROPERTIES OUTPUT_NAME clang)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# FIXME: Deal with LLVM_SUBMIT_VERSION?
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index f7192dd..be3623f 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -78,9 +78,9 @@ static CXCursorKind GetCursorKind(const Attr *A) {
assert(A && "Invalid arguments!");
switch (A->getKind()) {
default: break;
- case Attr::IBActionKind: return CXCursor_IBActionAttr;
- case Attr::IBOutletKind: return CXCursor_IBOutletAttr;
- case Attr::IBOutletCollectionKind: return CXCursor_IBOutletCollectionAttr;
+ case attr::IBAction: return CXCursor_IBActionAttr;
+ case attr::IBOutlet: return CXCursor_IBOutletAttr;
+ case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr;
}
return CXCursor_UnexposedAttr;
@@ -174,7 +174,7 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) {
case Stmt::CXXThisExprClass:
case Stmt::CXXThrowExprClass:
case Stmt::CXXDefaultArgExprClass:
- case Stmt::CXXZeroInitValueExprClass:
+ case Stmt::CXXScalarValueInitExprClass:
case Stmt::CXXNewExprClass:
case Stmt::CXXDeleteExprClass:
case Stmt::CXXPseudoDestructorExprClass:
diff --git a/tools/libclang/CXSourceLocation.h b/tools/libclang/CXSourceLocation.h
index 66566c1..7a50205 100644
--- a/tools/libclang/CXSourceLocation.h
+++ b/tools/libclang/CXSourceLocation.h
@@ -29,6 +29,9 @@ namespace cxloc {
static inline CXSourceLocation
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
SourceLocation Loc) {
+ if (Loc.isInvalid())
+ clang_getNullLocation();
+
CXSourceLocation Result = { { (void*) &SM, (void*) &LangOpts, },
Loc.getRawEncoding() };
return Result;
@@ -50,14 +53,14 @@ static inline CXSourceLocation translateSourceLocation(ASTContext &Context,
/// does the appropriate translation.
CXSourceRange translateSourceRange(const SourceManager &SM,
const LangOptions &LangOpts,
- SourceRange R);
+ const CharSourceRange &R);
/// \brief Translate a Clang source range into a CIndex source range.
static inline CXSourceRange translateSourceRange(ASTContext &Context,
SourceRange R) {
return translateSourceRange(Context.getSourceManager(),
Context.getLangOptions(),
- R);
+ CharSourceRange::getTokenRange(R));
}
static inline SourceLocation translateSourceLocation(CXSourceLocation L) {
diff --git a/tools/libclang/CXTypes.cpp b/tools/libclang/CXTypes.cpp
index 137370a..d5c9f45 100644
--- a/tools/libclang/CXTypes.cpp
+++ b/tools/libclang/CXTypes.cpp
@@ -77,6 +77,8 @@ static CXTypeKind GetTypeKind(QualType T) {
TKCASE(Typedef);
TKCASE(ObjCInterface);
TKCASE(ObjCObjectPointer);
+ TKCASE(FunctionNoProto);
+ TKCASE(FunctionProto);
default:
return CXType_Unexposed;
}
@@ -116,7 +118,10 @@ CXType clang_getCursorType(CXCursor C) {
return MakeCXType(QualType(ID->getTypeForDecl(), 0), AU);
if (ValueDecl *VD = dyn_cast<ValueDecl>(D))
return MakeCXType(VD->getType(), AU);
-
+ if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
+ return MakeCXType(PD->getType(), AU);
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+ return MakeCXType(FD->getType(), AU);
return MakeCXType(QualType(), AU);
}
@@ -165,8 +170,15 @@ CXType clang_getPointeeType(CXType CT) {
}
CXCursor clang_getTypeDeclaration(CXType CT) {
+ if (CT.kind == CXType_Invalid)
+ return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
+
QualType T = GetQualType(CT);
Type *TP = T.getTypePtr();
+
+ if (!TP)
+ return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
+
Decl *D = 0;
switch (TP->getTypeClass()) {
@@ -237,6 +249,8 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) {
TKIND(Typedef);
TKIND(ObjCInterface);
TKIND(ObjCObjectPointer);
+ TKIND(FunctionNoProto);
+ TKIND(FunctionProto);
}
#undef TKIND
return cxstring::createCXString(s);
@@ -246,4 +260,27 @@ unsigned clang_equalTypes(CXType A, CXType B) {
return A.data[0] == B.data[0] && A.data[1] == B.data[1];;
}
+CXType clang_getResultType(CXType X) {
+ QualType T = GetQualType(X);
+ if (!T.getTypePtr())
+ return MakeCXType(QualType(), GetASTU(X));
+
+ if (const FunctionType *FD = T->getAs<FunctionType>())
+ return MakeCXType(FD->getResultType(), GetASTU(X));
+
+ return MakeCXType(QualType(), GetASTU(X));
+}
+
+CXType clang_getCursorResultType(CXCursor C) {
+ if (clang_isDeclaration(C.kind)) {
+ Decl *D = cxcursor::getCursorDecl(C);
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
+ return MakeCXType(MD->getResultType(), cxcursor::getCursorASTUnit(C));
+
+ return clang_getResultType(clang_getCursorType(C));
+ }
+
+ return MakeCXType(QualType(), cxcursor::getCursorASTUnit(C));
+}
+
} // end: extern "C"
diff --git a/tools/libclang/Makefile b/tools/libclang/Makefile
index ff0fa33..253ea38 100644
--- a/tools/libclang/Makefile
+++ b/tools/libclang/Makefile
@@ -7,18 +7,11 @@
#
##===----------------------------------------------------------------------===##
-LEVEL = ../../../..
+CLANG_LEVEL := ../..
LIBRARYNAME = clang
EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/libclang.exports
-CPP.Flags += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
-
-# Include this here so we can get the configuration of the targets
-# that have been configured for construction. We have to do this
-# early so we can set up LINK_COMPONENTS before including Makefile.rules
-include $(LEVEL)/Makefile.config
-
LINK_LIBS_IN_SHARED = 1
SHARED_LIBRARY = 1
@@ -26,7 +19,7 @@ LINK_COMPONENTS := bitreader mc core
USEDLIBS = clangFrontend.a clangDriver.a clangSema.a \
clangAnalysis.a clangAST.a clangParse.a clangLex.a clangBasic.a
-include $(LEVEL)/Makefile.common
+include $(CLANG_LEVEL)/Makefile
##===----------------------------------------------------------------------===##
# FIXME: This is copied from the 'lto' makefile. Should we share this?
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index a9f4f07..f21fec6 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -41,6 +41,7 @@ _clang_getCursorLinkage
_clang_getCursorLocation
_clang_getCursorReferenced
_clang_getCursorSpelling
+_clang_getCursorResultType
_clang_getCursorType
_clang_getCursorUSR
_clang_getDefinitionSpellingAndExtent
@@ -67,6 +68,7 @@ _clang_getPointeeType
_clang_getRange
_clang_getRangeEnd
_clang_getRangeStart
+_clang_getResultType
_clang_getTokenExtent
_clang_getTokenKind
_clang_getTokenLocation
@@ -78,7 +80,6 @@ _clang_getTypeKindSpelling
_clang_isCursorDefinition
_clang_isDeclaration
_clang_isExpression
-_clang_isFromMainFile
_clang_isInvalid
_clang_isPreprocessing
_clang_isReference
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index b09e6ac..dcb40d4 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -41,6 +41,7 @@ clang_getCursorLinkage
clang_getCursorLocation
clang_getCursorReferenced
clang_getCursorSpelling
+clang_getCursorResultType
clang_getCursorType
clang_getCursorUSR
clang_getDefinitionSpellingAndExtent
@@ -67,6 +68,7 @@ clang_getPointeeType
clang_getRange
clang_getRangeEnd
clang_getRangeStart
+clang_getResultType
clang_getTokenExtent
clang_getTokenKind
clang_getTokenLocation
@@ -78,7 +80,6 @@ clang_getTypeKindSpelling
clang_isCursorDefinition
clang_isDeclaration
clang_isExpression
-clang_isFromMainFile
clang_isInvalid
clang_isPreprocessing
clang_isReference
@@ -88,4 +89,3 @@ clang_isUnexposed
clang_setUseExternalASTGeneration
clang_tokenize
clang_visitChildren
-
OpenPOWER on IntegriCloud