[cfe-commits] r135983 - in /cfe/trunk: include/clang-c/Index.h tools/libclang/CIndex.cpp

Francois Pichet pichet2000 at gmail.com
Mon Jul 25 15:00:44 PDT 2011


Author: fpichet
Date: Mon Jul 25 17:00:44 2011
New Revision: 135983

URL: http://llvm.org/viewvc/llvm-project?rev=135983&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=135983&r1=135982&r2=135983&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Jul 25 17:00:44 2011
@@ -2404,7 +2404,8 @@
  * \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 {

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=135983&r1=135982&r2=135983&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Jul 25 17:00:44 2011
@@ -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) {





More information about the cfe-commits mailing list