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/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 8104828..017fd0b 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2324,6 +2324,47 @@
   return result;
 }
 
+namespace {
+typedef llvm::SmallVector<SourceRange, 4> 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 @@
   *endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc());
 }
 
-namespace {
-typedef llvm::SmallVector<SourceRange, 4> 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) {