From: Francois Pichet Date: Mon, 25 Jul 2011 22:00:44 +0000 (+0000) Subject: Fix the MSVC build. 2 problems: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48a8d14fc6f064a5297024c2b34733a4080b2efe;p=clang Fix the MSVC build. 2 problems: - buildPieces was return a C++ object from inside an extern "C". (MSVC didn't like that) - clang_getCursorReferenceNameRange was missing a CINDEX_LINKAGE causing a link error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 8d35419a43..d4fa9a2453 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -2404,7 +2404,8 @@ CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); * \returns The piece of the name pointed to by the given cursor. If there is no * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. */ -CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags, +CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, + unsigned NameFlags, unsigned PieceIndex); enum CXNameRefFlags { diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 8104828ecc..017fd0bcfa 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2324,6 +2324,47 @@ bool CursorVisitor::Visit(Stmt *S) { return result; } +namespace { +typedef llvm::SmallVector RefNamePieces; +RefNamePieces buildPieces(unsigned NameFlags, bool IsMemberRefExpr, + const DeclarationNameInfo &NI, + const SourceRange &QLoc, + const ExplicitTemplateArgumentList *TemplateArgs = 0){ + const bool WantQualifier = NameFlags & CXNameRange_WantQualifier; + const bool WantTemplateArgs = NameFlags & CXNameRange_WantTemplateArgs; + const bool WantSinglePiece = NameFlags & CXNameRange_WantSinglePiece; + + const DeclarationName::NameKind Kind = NI.getName().getNameKind(); + + RefNamePieces Pieces; + + if (WantQualifier && QLoc.isValid()) + Pieces.push_back(QLoc); + + if (Kind != DeclarationName::CXXOperatorName || IsMemberRefExpr) + Pieces.push_back(NI.getLoc()); + + if (WantTemplateArgs && TemplateArgs) + Pieces.push_back(SourceRange(TemplateArgs->LAngleLoc, + TemplateArgs->RAngleLoc)); + + if (Kind == DeclarationName::CXXOperatorName) { + Pieces.push_back(SourceLocation::getFromRawEncoding( + NI.getInfo().CXXOperatorName.BeginOpNameLoc)); + Pieces.push_back(SourceLocation::getFromRawEncoding( + NI.getInfo().CXXOperatorName.EndOpNameLoc)); + } + + if (WantSinglePiece) { + SourceRange R(Pieces.front().getBegin(), Pieces.back().getEnd()); + Pieces.clear(); + Pieces.push_back(R); + } + + return Pieces; +} +} + //===----------------------------------------------------------------------===// // Misc. API hooks. //===----------------------------------------------------------------------===// @@ -4252,46 +4293,6 @@ void clang_getDefinitionSpellingAndExtent(CXCursor C, *endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc()); } -namespace { -typedef llvm::SmallVector RefNamePieces; -RefNamePieces buildPieces(unsigned NameFlags, bool IsMemberRefExpr, - const DeclarationNameInfo &NI, - const SourceRange &QLoc, - const ExplicitTemplateArgumentList *TemplateArgs = 0){ - const bool WantQualifier = NameFlags & CXNameRange_WantQualifier; - const bool WantTemplateArgs = NameFlags & CXNameRange_WantTemplateArgs; - const bool WantSinglePiece = NameFlags & CXNameRange_WantSinglePiece; - - const DeclarationName::NameKind Kind = NI.getName().getNameKind(); - - RefNamePieces Pieces; - - if (WantQualifier && QLoc.isValid()) - Pieces.push_back(QLoc); - - if (Kind != DeclarationName::CXXOperatorName || IsMemberRefExpr) - Pieces.push_back(NI.getLoc()); - - if (WantTemplateArgs && TemplateArgs) - Pieces.push_back(SourceRange(TemplateArgs->LAngleLoc, - TemplateArgs->RAngleLoc)); - - if (Kind == DeclarationName::CXXOperatorName) { - Pieces.push_back(SourceLocation::getFromRawEncoding( - NI.getInfo().CXXOperatorName.BeginOpNameLoc)); - Pieces.push_back(SourceLocation::getFromRawEncoding( - NI.getInfo().CXXOperatorName.EndOpNameLoc)); - } - - if (WantSinglePiece) { - SourceRange R(Pieces.front().getBegin(), Pieces.back().getEnd()); - Pieces.clear(); - Pieces.push_back(R); - } - - return Pieces; -} -} CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags, unsigned PieceIndex) {