From 822bde9df508e0b9afac5e581b0d6ab403417a28 Mon Sep 17 00:00:00 2001 From: dim Date: Thu, 3 May 2012 16:53:59 +0000 Subject: Vendor import of clang release_31 branch r155985: http://llvm.org/svn/llvm-project/cfe/branches/release_31@155985 --- tools/arcmt-test/Makefile | 2 +- tools/c-arcmt-test/Makefile | 2 +- tools/c-index-test/Makefile | 2 +- tools/c-index-test/c-index-test.c | 1 + tools/clang-check/ClangCheck.cpp | 16 ++++++++++------ tools/driver/CMakeLists.txt | 1 - tools/driver/Makefile | 2 +- tools/libclang/CIndex.cpp | 34 +++++++++++++++++++++++++++++++++- tools/libclang/CMakeLists.txt | 1 - tools/libclang/CXCursor.cpp | 14 +++++++++----- tools/libclang/Makefile | 5 +++++ tools/scan-build/ccc-analyzer | 2 ++ 12 files changed, 64 insertions(+), 18 deletions(-) (limited to 'tools') diff --git a/tools/arcmt-test/Makefile b/tools/arcmt-test/Makefile index f5ca81a..57cd574 100644 --- a/tools/arcmt-test/Makefile +++ b/tools/arcmt-test/Makefile @@ -17,7 +17,7 @@ TOOL_NO_EXPORTS = 1 NO_INSTALL = 1 LINK_COMPONENTS := support mc -USEDLIBS = clangIndex.a clangARCMigrate.a clangRewrite.a \ +USEDLIBS = clangARCMigrate.a clangRewrite.a \ clangFrontend.a clangDriver.a clangSerialization.a clangParse.a \ clangSema.a clangEdit.a clangAnalysis.a clangAST.a clangLex.a clangBasic.a diff --git a/tools/c-arcmt-test/Makefile b/tools/c-arcmt-test/Makefile index 878eb6f..818f648 100644 --- a/tools/c-arcmt-test/Makefile +++ b/tools/c-arcmt-test/Makefile @@ -17,7 +17,7 @@ TOOL_NO_EXPORTS = 1 NO_INSTALL = 1 LINK_COMPONENTS := support mc -USEDLIBS = clang.a clangIndex.a clangARCMigrate.a clangRewrite.a \ +USEDLIBS = clang.a clangARCMigrate.a clangRewrite.a \ clangFrontend.a clangDriver.a \ clangSerialization.a clangParse.a clangSema.a \ clangAnalysis.a clangEdit.a clangAST.a clangLex.a clangBasic.a diff --git a/tools/c-index-test/Makefile b/tools/c-index-test/Makefile index 95a961f..03519b3 100644 --- a/tools/c-index-test/Makefile +++ b/tools/c-index-test/Makefile @@ -18,7 +18,7 @@ INTERNAL_TOOL = 1 TOOL_NO_EXPORTS = 1 LINK_COMPONENTS := support mc -USEDLIBS = clang.a clangIndex.a clangFrontend.a clangDriver.a \ +USEDLIBS = clang.a clangFrontend.a clangDriver.a \ clangSerialization.a clangParse.a clangSema.a \ clangAnalysis.a clangEdit.a clangAST.a clangLex.a clangBasic.a diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 573e6dc..eb2a406 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -2243,6 +2243,7 @@ int perform_token_annotation(int argc, const char **argv) { clang_getSpellingLocation(clang_getRangeEnd(extent), 0, &end_line, &end_column, 0); printf("%s: \"%s\" ", kind, clang_getCString(spelling)); + clang_disposeString(spelling); PrintExtent(stdout, start_line, start_column, end_line, end_column); if (!clang_isInvalid(cursors[i].kind)) { printf(" "); diff --git a/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp index b5b6bd5..d68e282 100644 --- a/tools/clang-check/ClangCheck.cpp +++ b/tools/clang-check/ClangCheck.cpp @@ -50,13 +50,17 @@ cl::list SourcePaths( cl::desc(" [... ]"), cl::OneOrMore); -int main(int argc, char **argv) { - cl::ParseCommandLineOptions(argc, argv); - std::string ErrorMessage; +int main(int argc, const char **argv) { llvm::OwningPtr Compilations( - CompilationDatabase::loadFromDirectory(BuildPath, ErrorMessage)); - if (!Compilations) - llvm::report_fatal_error(ErrorMessage); + FixedCompilationDatabase::loadFromCommandLine(argc, argv)); + cl::ParseCommandLineOptions(argc, argv); + if (!Compilations) { + std::string ErrorMessage; + Compilations.reset(CompilationDatabase::loadFromDirectory(BuildPath, + ErrorMessage)); + if (!Compilations) + llvm::report_fatal_error(ErrorMessage); + } ClangTool Tool(*Compilations, SourcePaths); return Tool.run(newFrontendActionFactory()); } diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index c4c864b..ae49ac1 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -7,7 +7,6 @@ set( LLVM_USED_LIBS clangDriver clangEdit clangFrontend - clangIndex clangLex clangParse clangEdit diff --git a/tools/driver/Makefile b/tools/driver/Makefile index d828f67..270d4fd 100644 --- a/tools/driver/Makefile +++ b/tools/driver/Makefile @@ -35,7 +35,7 @@ USEDLIBS = clangFrontendTool.a clangFrontend.a clangDriver.a \ clangSerialization.a clangCodeGen.a clangParse.a clangSema.a \ clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \ clangStaticAnalyzerCore.a \ - clangAnalysis.a clangIndex.a clangARCMigrate.a clangRewrite.a \ + clangAnalysis.a clangARCMigrate.a clangRewrite.a \ clangEdit.a clangAST.a clangLex.a clangBasic.a include $(CLANG_LEVEL)/Makefile diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index ece91ce..605cc8b 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3196,6 +3196,18 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C, } } + if (C.kind == CXCursor_ObjCCategoryDecl || + C.kind == CXCursor_ObjCCategoryImplDecl) { + if (pieceIndex > 0) + return clang_getNullRange(); + if (ObjCCategoryDecl * + CD = dyn_cast_or_null(getCursorDecl(C))) + return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc()); + if (ObjCCategoryImplDecl * + CID = dyn_cast_or_null(getCursorDecl(C))) + return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc()); + } + // FIXME: A CXCursor_InclusionDirective should give the location of the // filename, but we don't keep track of this. @@ -3620,9 +3632,29 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor, if (clang_isDeclaration(cursor.kind)) { // Avoid having the implicit methods override the property decls. - if (ObjCMethodDecl *MD = dyn_cast_or_null(getCursorDecl(cursor))) + if (ObjCMethodDecl *MD + = dyn_cast_or_null(getCursorDecl(cursor))) { if (MD->isImplicit()) return CXChildVisit_Break; + + } else if (ObjCInterfaceDecl *ID + = dyn_cast_or_null(getCursorDecl(cursor))) { + // Check that when we have multiple @class references in the same line, + // that later ones do not override the previous ones. + // If we have: + // @class Foo, Bar; + // source ranges for both start at '@', so 'Bar' will end up overriding + // 'Foo' even though the cursor location was at 'Foo'. + if (BestCursor->kind == CXCursor_ObjCInterfaceDecl || + BestCursor->kind == CXCursor_ObjCClassRef) + if (ObjCInterfaceDecl *PrevID + = dyn_cast_or_null(getCursorDecl(*BestCursor))){ + if (PrevID != ID && + !PrevID->isThisDeclarationADefinition() && + !ID->isThisDeclarationADefinition()) + return CXChildVisit_Break; + } + } } if (clang_isExpression(cursor.kind) && diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt index 66a1710..fb0b91f 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt @@ -4,7 +4,6 @@ set(LLVM_USED_LIBS clangFrontend clangDriver clangSerialization - clangIndex clangSema clangEdit clangAST diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index d84cf29..a298759 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -247,19 +247,23 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU, case Stmt::CompoundStmtClass: K = CXCursor_CompoundStmt; break; - + case Stmt::NullStmtClass: K = CXCursor_NullStmt; break; - + case Stmt::LabelStmtClass: K = CXCursor_LabelStmt; break; - + + case Stmt::AttributedStmtClass: + K = CXCursor_UnexposedStmt; + break; + case Stmt::DeclStmtClass: K = CXCursor_DeclStmt; break; - + case Stmt::IntegerLiteralClass: K = CXCursor_IntegerLiteral; break; @@ -287,7 +291,7 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU, case Stmt::UnaryOperatorClass: K = CXCursor_UnaryOperator; break; - + case Stmt::CXXNoexceptExprClass: K = CXCursor_UnaryExpr; break; diff --git a/tools/libclang/Makefile b/tools/libclang/Makefile index 1fff166..08bf3c6 100644 --- a/tools/libclang/Makefile +++ b/tools/libclang/Makefile @@ -23,6 +23,11 @@ USEDLIBS = clangARCMigrate.a clangRewrite.a clangFrontend.a clangDriver.a \ include $(CLANG_LEVEL)/Makefile +# Add soname to the library. +ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux FreeBSD GNU)) + LDFLAGS += -Wl,-soname,lib$(LIBRARYNAME)$(SHLIBEXT) +endif + ##===----------------------------------------------------------------------===## # FIXME: This is copied from the 'lto' makefile. Should we share this? ##===----------------------------------------------------------------------===## diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer index 32a7301..d01bd0f 100755 --- a/tools/scan-build/ccc-analyzer +++ b/tools/scan-build/ccc-analyzer @@ -387,6 +387,8 @@ my %LangMap = ( 'c' => 'c', 'cp' => 'c++', 'cpp' => 'c++', + 'cxx' => 'c++', + 'txx' => 'c++', 'cc' => 'c++', 'ii' => 'c++', 'i' => 'c-cpp-output', -- cgit v1.1