[cfe-commits] r96427 - /cfe/trunk/tools/CIndex/CIndex.cpp

Ted Kremenek kremenek at apple.com
Tue Feb 16 16:41:40 PST 2010


Author: kremenek
Date: Tue Feb 16 18:41:40 2010
New Revision: 96427

URL: http://llvm.org/viewvc/llvm-project?rev=96427&view=rev
Log:
Remove trailing spaces.

Modified:
    cfe/trunk/tools/CIndex/CIndex.cpp

Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=96427&r1=96426&r2=96427&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Tue Feb 16 18:41:40 2010
@@ -54,7 +54,7 @@
 
 static unsigned SetCrashTracerInfo(const char *str,
                                    llvm::SmallString<1024> &AggStr) {
-  
+
   unsigned slot = 0;
   while (crashtracer_strings[slot]) {
     if (++slot == NUM_CRASH_STRINGS)
@@ -69,7 +69,7 @@
   // of this function.  Race conditions can still cause this goal
   // to not be achieved.
   {
-    llvm::raw_svector_ostream Out(AggStr);      
+    llvm::raw_svector_ostream Out(AggStr);
     for (unsigned i = 0; i < NUM_CRASH_STRINGS; ++i)
       if (crashtracer_strings[i]) Out << crashtracer_strings[i] << '\n';
   }
@@ -80,7 +80,7 @@
 static void ResetCrashTracerInfo(unsigned slot) {
   unsigned max_slot = 0;
   unsigned max_value = 0;
-  
+
   crashtracer_strings[slot] = agg_crashtracer_strings[slot] = 0;
 
   for (unsigned i = 0 ; i < NUM_CRASH_STRINGS; ++i)
@@ -112,7 +112,7 @@
     crashtracerSlot = SetCrashTracerInfo(CrashString.c_str(),
                                          AggregateString);
   }
-  
+
   ~ArgsCrashTracerInfo() {
     ResetCrashTracerInfo(crashtracerSlot);
   }
@@ -125,18 +125,18 @@
 enum RangeComparisonResult {
   /// \brief Either the ranges overlap or one of the ranges is invalid.
   RangeOverlap,
-  
+
   /// \brief The first range ends before the second range starts.
   RangeBefore,
-  
+
   /// \brief The first range starts after the second range ends.
   RangeAfter
 };
 
-/// \brief Compare two source ranges to determine their relative position in 
+/// \brief Compare two source ranges to determine their relative position in
 /// the translation unit.
-static RangeComparisonResult RangeCompare(SourceManager &SM, 
-                                          SourceRange R1, 
+static RangeComparisonResult RangeCompare(SourceManager &SM,
+                                          SourceRange R1,
                                           SourceRange R2) {
   assert(R1.isValid() && "First range is invalid?");
   assert(R2.isValid() && "Second range is invalid?");
@@ -155,7 +155,7 @@
 /// start of the token at the end. However, for external clients it is more
 /// useful to have a CXSourceRange be a proper half-open interval. This routine
 /// does the appropriate translation.
-CXSourceRange cxloc::translateSourceRange(const SourceManager &SM, 
+CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
                                           const LangOptions &LangOpts,
                                           SourceRange R) {
   // FIXME: This is largely copy-paste from
@@ -197,7 +197,7 @@
 //===----------------------------------------------------------------------===//
 
 namespace {
-  
+
 // Cursor visitor.
 class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
                       public TypeLocVisitor<CursorVisitor, bool>,
@@ -205,20 +205,20 @@
 {
   /// \brief The translation unit we are traversing.
   ASTUnit *TU;
-  
+
   /// \brief The parent cursor whose children we are traversing.
   CXCursor Parent;
-  
+
   /// \brief The declaration that serves at the parent of any statement or
   /// expression nodes.
   Decl *StmtParent;
-  
+
   /// \brief The visitor function.
   CXCursorVisitor Visitor;
-  
+
   /// \brief The opaque client data, to be passed along to the visitor.
   CXClientData ClientData;
-  
+
   // MaxPCHLevel - the maximum PCH level of declarations that we will pass on
   // to the visitor. Declarations with a PCH level greater than this value will
   // be suppressed.
@@ -227,22 +227,22 @@
   /// \brief When valid, a source range to which the cursor should restrict
   /// its search.
   SourceRange RegionOfInterest;
-    
+
   using DeclVisitor<CursorVisitor, bool>::Visit;
   using TypeLocVisitor<CursorVisitor, bool>::Visit;
   using StmtVisitor<CursorVisitor, bool>::Visit;
-    
-  /// \brief Determine whether this particular source range comes before, comes 
-  /// after, or overlaps the region of interest. 
+
+  /// \brief Determine whether this particular source range comes before, comes
+  /// after, or overlaps the region of interest.
   ///
   /// \param R a half-open source range retrieved from the abstract syntax tree.
-  RangeComparisonResult CompareRegionOfInterest(SourceRange R); 
-  
+  RangeComparisonResult CompareRegionOfInterest(SourceRange R);
+
 public:
-  CursorVisitor(ASTUnit *TU, CXCursorVisitor Visitor, CXClientData ClientData, 
-                unsigned MaxPCHLevel, 
+  CursorVisitor(ASTUnit *TU, CXCursorVisitor Visitor, CXClientData ClientData,
+                unsigned MaxPCHLevel,
                 SourceRange RegionOfInterest = SourceRange())
-    : TU(TU), Visitor(Visitor), ClientData(ClientData), 
+    : TU(TU), Visitor(Visitor), ClientData(ClientData),
       MaxPCHLevel(MaxPCHLevel), RegionOfInterest(RegionOfInterest)
   {
     Parent.kind = CXCursor_NoDeclFound;
@@ -251,10 +251,10 @@
     Parent.data[2] = 0;
     StmtParent = 0;
   }
-  
+
   bool Visit(CXCursor Cursor, bool CheckedRegionOfInterest = false);
   bool VisitChildren(CXCursor Parent);
-  
+
   // Declaration visitors
   bool VisitDeclContext(DeclContext *DC);
   bool VisitTranslationUnitDecl(TranslationUnitDecl *D);
@@ -300,7 +300,7 @@
   // implemented
   bool VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL);
   bool VisitTypeOfTypeLoc(TypeOfTypeLoc TL);
-  
+
   // Statement visitors
   bool VisitStmt(Stmt *S);
   bool VisitDeclStmt(DeclStmt *S);
@@ -309,13 +309,13 @@
   bool VisitSwitchStmt(SwitchStmt *S);
   bool VisitWhileStmt(WhileStmt *S);
   bool VisitForStmt(ForStmt *S);
-  
+
   // Expression visitors
   bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
   bool VisitExplicitCastExpr(ExplicitCastExpr *E);
   bool VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
 };
-  
+
 } // end anonymous namespace
 
 RangeComparisonResult CursorVisitor::CompareRegionOfInterest(SourceRange R) {
@@ -335,7 +335,7 @@
 bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
   if (clang_isInvalid(Cursor.kind))
     return false;
-  
+
   if (clang_isDeclaration(Cursor.kind)) {
     Decl *D = getCursorDecl(Cursor);
     assert(D && "Invalid declaration cursor");
@@ -354,7 +354,7 @@
     if (Range.isInvalid() || CompareRegionOfInterest(Range))
       return false;
   }
-  
+
   switch (Visitor(Cursor, Parent, ClientData)) {
   case CXChildVisit_Break:
     return true;
@@ -373,13 +373,13 @@
 ///
 /// \returns true if the visitation should be aborted, false if it
 /// should continue.
-bool CursorVisitor::VisitChildren(CXCursor Cursor) { 
+bool CursorVisitor::VisitChildren(CXCursor Cursor) {
   if (clang_isReference(Cursor.kind)) {
     // By definition, references have no children.
     return false;
   }
-  
-  // Set the Parent field to Cursor, then back to its old value once we're 
+
+  // Set the Parent field to Cursor, then back to its old value once we're
   // done.
   class SetParentRAII {
     CXCursor &Parent;
@@ -388,31 +388,31 @@
 
   public:
     SetParentRAII(CXCursor &Parent, Decl *&StmtParent, CXCursor NewParent)
-      : Parent(Parent), StmtParent(StmtParent), OldParent(Parent) 
+      : Parent(Parent), StmtParent(StmtParent), OldParent(Parent)
     {
       Parent = NewParent;
       if (clang_isDeclaration(Parent.kind))
         StmtParent = getCursorDecl(Parent);
     }
-    
+
     ~SetParentRAII() {
       Parent = OldParent;
       if (clang_isDeclaration(Parent.kind))
         StmtParent = getCursorDecl(Parent);
     }
   } SetParent(Parent, StmtParent, Cursor);
-  
+
   if (clang_isDeclaration(Cursor.kind)) {
     Decl *D = getCursorDecl(Cursor);
     assert(D && "Invalid declaration cursor");
     return Visit(D);
   }
-  
+
   if (clang_isStatement(Cursor.kind))
     return Visit(getCursorStmt(Cursor));
   if (clang_isExpression(Cursor.kind))
     return Visit(getCursorExpr(Cursor));
-  
+
   if (clang_isTranslationUnit(Cursor.kind)) {
     ASTUnit *CXXUnit = getCursorASTUnit(Cursor);
     if (!CXXUnit->isMainFileAST() && CXXUnit->getOnlyLocalDecls() &&
@@ -427,10 +427,10 @@
       return VisitDeclContext(
                             CXXUnit->getASTContext().getTranslationUnitDecl());
     }
-    
+
     return false;
   }
-  
+
   // Nothing to visit at the moment.
   return false;
 }
@@ -450,21 +450,21 @@
       case RangeBefore:
         // This declaration comes before the region of interest; skip it.
         continue;
-      
+
       case RangeAfter:
         // This declaration comes after the region of interest; we're done.
         return false;
-      
+
       case RangeOverlap:
         // This declaration overlaps the region of interest; visit it.
         break;
-      }      
+      }
     }
-    
+
     if (Visit(Cursor, true))
       return true;
   }
-  
+
   return false;
 }
 
@@ -476,7 +476,7 @@
 bool CursorVisitor::VisitTypedefDecl(TypedefDecl *D) {
   if (TypeSourceInfo *TSInfo = D->getTypeSourceInfo())
     return Visit(TSInfo->getTypeLoc());
-  
+
   return false;
 }
 
@@ -505,45 +505,45 @@
   if (ND->isThisDeclarationADefinition() &&
       Visit(MakeCXCursor(ND->getBody(), StmtParent, TU)))
     return true;
-  
+
   return false;
 }
 
 bool CursorVisitor::VisitFieldDecl(FieldDecl *D) {
   if (VisitDeclaratorDecl(D))
     return true;
-  
+
   if (Expr *BitWidth = D->getBitWidth())
     return Visit(MakeCXCursor(BitWidth, StmtParent, TU));
-  
+
   return false;
 }
 
 bool CursorVisitor::VisitVarDecl(VarDecl *D) {
   if (VisitDeclaratorDecl(D))
     return true;
-  
+
   if (Expr *Init = D->getInit())
     return Visit(MakeCXCursor(Init, StmtParent, TU));
-  
+
   return false;
 }
 
 bool CursorVisitor::VisitObjCMethodDecl(ObjCMethodDecl *ND) {
   // FIXME: We really need a TypeLoc covering Objective-C method declarations.
-  // At the moment, we don't have information about locations in the return 
+  // At the moment, we don't have information about locations in the return
   // type.
-  for (ObjCMethodDecl::param_iterator P = ND->param_begin(), 
+  for (ObjCMethodDecl::param_iterator P = ND->param_begin(),
        PEnd = ND->param_end();
        P != PEnd; ++P) {
     if (Visit(MakeCXCursor(*P, TU)))
       return true;
   }
-  
+
   if (ND->isThisDeclarationADefinition() &&
       Visit(MakeCXCursor(ND->getBody(), StmtParent, TU)))
     return true;
-  
+
   return false;
 }
 
@@ -555,13 +555,13 @@
   if (Visit(MakeCursorObjCClassRef(ND->getClassInterface(), ND->getLocation(),
                                    TU)))
     return true;
-  
+
   ObjCCategoryDecl::protocol_loc_iterator PL = ND->protocol_loc_begin();
   for (ObjCCategoryDecl::protocol_iterator I = ND->protocol_begin(),
          E = ND->protocol_end(); I != E; ++I, ++PL)
     if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
       return true;
-  
+
   return VisitObjCContainerDecl(ND);
 }
 
@@ -571,7 +571,7 @@
        E = PID->protocol_end(); I != E; ++I, ++PL)
     if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
       return true;
-  
+
   return VisitObjCContainerDecl(PID);
 }
 
@@ -579,16 +579,16 @@
   // Issue callbacks for super class.
   if (D->getSuperClass() &&
       Visit(MakeCursorObjCSuperClassRef(D->getSuperClass(),
-                                        D->getSuperClassLoc(), 
+                                        D->getSuperClassLoc(),
                                         TU)))
     return true;
-  
+
   ObjCInterfaceDecl::protocol_loc_iterator PL = D->protocol_loc_begin();
   for (ObjCInterfaceDecl::protocol_iterator I = D->protocol_begin(),
          E = D->protocol_end(); I != E; ++I, ++PL)
     if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
       return true;
-  
+
   return VisitObjCContainerDecl(D);
 }
 
@@ -597,10 +597,10 @@
 }
 
 bool CursorVisitor::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
-  if (Visit(MakeCursorObjCClassRef(D->getCategoryDecl()->getClassInterface(), 
+  if (Visit(MakeCursorObjCClassRef(D->getCategoryDecl()->getClassInterface(),
                                    D->getLocation(), TU)))
     return true;
-  
+
   return VisitObjCImplDecl(D);
 }
 
@@ -610,11 +610,11 @@
   // FIXME: No source location information!
   if (D->getSuperClass() &&
       Visit(MakeCursorObjCSuperClassRef(D->getSuperClass(),
-                                        D->getSuperClassLoc(), 
+                                        D->getSuperClassLoc(),
                                         TU)))
     return true;
 #endif
-  
+
   return VisitObjCImplDecl(D);
 }
 
@@ -625,15 +625,15 @@
        I != E; ++I, ++PL)
     if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
       return true;
-  
-  return false; 
+
+  return false;
 }
 
 bool CursorVisitor::VisitObjCClassDecl(ObjCClassDecl *D) {
   for (ObjCClassDecl::iterator C = D->begin(), CEnd = D->end(); C != CEnd; ++C)
     if (Visit(MakeCursorObjCClassRef(C->getInterface(), C->getLocation(), TU)))
       return true;
-       
+
   return false;
 }
 
@@ -663,8 +663,8 @@
   case BuiltinType::Long:
   case BuiltinType::LongLong:
   case BuiltinType::Int128:
-  case BuiltinType::Float: 
-  case BuiltinType::Double: 
+  case BuiltinType::Float:
+  case BuiltinType::Double:
   case BuiltinType::LongDouble:
   case BuiltinType::NullPtr:
   case BuiltinType::Overload:
@@ -689,7 +689,7 @@
 
   if (!VisitType.isNull()) {
     if (const TypedefType *Typedef = VisitType->getAs<TypedefType>())
-      return Visit(MakeCursorTypeRef(Typedef->getDecl(), TL.getBuiltinLoc(), 
+      return Visit(MakeCursorTypeRef(Typedef->getDecl(), TL.getBuiltinLoc(),
                                      TU));
   }
 
@@ -727,13 +727,13 @@
 
   if (TL.hasProtocolsAsWritten()) {
     for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
-      if (Visit(MakeCursorObjCProtocolRef(TL.getProtocol(I), 
+      if (Visit(MakeCursorObjCProtocolRef(TL.getProtocol(I),
                                           TL.getProtocolLoc(I),
                                           TU)))
         return true;
     }
   }
-  
+
   return false;
 }
 
@@ -750,11 +750,11 @@
 }
 
 bool CursorVisitor::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
-  return Visit(TL.getPointeeLoc());  
+  return Visit(TL.getPointeeLoc());
 }
 
 bool CursorVisitor::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
-  return Visit(TL.getPointeeLoc());  
+  return Visit(TL.getPointeeLoc());
 }
 
 bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
@@ -795,7 +795,7 @@
     if (*Child && Visit(MakeCXCursor(*Child, StmtParent, TU)))
       return true;
   }
-  
+
   return false;
 }
 
@@ -805,7 +805,7 @@
     if (*D && Visit(MakeCXCursor(*D, TU)))
       return true;
   }
-  
+
   return false;
 }
 
@@ -813,8 +813,8 @@
   if (VarDecl *Var = S->getConditionVariable()) {
     if (Visit(MakeCXCursor(Var, TU)))
       return true;
-  } 
-  
+  }
+
   if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
     return true;
   if (S->getThen() && Visit(MakeCXCursor(S->getThen(), StmtParent, TU)))
@@ -829,13 +829,13 @@
   if (VarDecl *Var = S->getConditionVariable()) {
     if (Visit(MakeCXCursor(Var, TU)))
       return true;
-  } 
-  
+  }
+
   if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
     return true;
   if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
     return true;
-  
+
   return false;
 }
 
@@ -843,8 +843,8 @@
   if (VarDecl *Var = S->getConditionVariable()) {
     if (Visit(MakeCXCursor(Var, TU)))
       return true;
-  } 
-  
+  }
+
   if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
     return true;
   if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
@@ -859,15 +859,15 @@
   if (VarDecl *Var = S->getConditionVariable()) {
     if (Visit(MakeCXCursor(Var, TU)))
       return true;
-  } 
-  
+  }
+
   if (S->getCond() && Visit(MakeCXCursor(S->getCond(), StmtParent, TU)))
     return true;
   if (S->getInc() && Visit(MakeCXCursor(S->getInc(), StmtParent, TU)))
     return true;
   if (S->getBody() && Visit(MakeCXCursor(S->getBody(), StmtParent, TU)))
     return true;
-  
+
   return false;
 }
 
@@ -875,10 +875,10 @@
   if (E->isArgumentType()) {
     if (TypeSourceInfo *TSInfo = E->getArgumentTypeInfo())
       return Visit(TSInfo->getTypeLoc());
-    
+
     return false;
   }
-  
+
   return VisitExpr(E);
 }
 
@@ -886,7 +886,7 @@
   if (TypeSourceInfo *TSInfo = E->getTypeInfoAsWritten())
     if (Visit(TSInfo->getTypeLoc()))
       return true;
-  
+
   return VisitCastExpr(E);
 }
 
@@ -894,7 +894,7 @@
   if (TypeSourceInfo *TSInfo = E->getTypeSourceInfo())
     if (Visit(TSInfo->getTypeLoc()))
       return true;
-  
+
   return VisitExpr(E);
 }
 
@@ -924,7 +924,7 @@
                                               CXClientData diag_client_data) {
   if (!CIdx)
     return 0;
-  
+
   CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
 
   // Configure the diagnostics.
@@ -933,7 +933,7 @@
   Diags.reset(CompilerInstance::createDiagnostics(DiagOpts, 0, 0));
   CIndexDiagnosticClient DiagClient(diag_callback, diag_client_data);
   Diags->setClient(&DiagClient);
-  
+
   return ASTUnit::LoadFromPCHFile(ast_filename, *Diags,
                                   CXXIdx->getOnlyLocalDecls());
 }
@@ -949,7 +949,7 @@
                                           CXClientData diag_client_data) {
   if (!CIdx)
     return 0;
-  
+
   CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
 
   // Configure the diagnostics.
@@ -958,17 +958,17 @@
   Diags.reset(CompilerInstance::createDiagnostics(DiagOpts, 0, 0));
   CIndexDiagnosticClient DiagClient(diag_callback, diag_client_data);
   Diags->setClient(&DiagClient);
-                               
+
   llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
   for (unsigned I = 0; I != num_unsaved_files; ++I) {
-    const llvm::MemoryBuffer *Buffer 
+    const llvm::MemoryBuffer *Buffer
     = llvm::MemoryBuffer::getMemBuffer(unsaved_files[I].Contents,
                                        unsaved_files[I].Contents + unsaved_files[I].Length,
                                        unsaved_files[I].Filename);
     RemappedFiles.push_back(std::make_pair(unsaved_files[I].Filename,
                                            Buffer));
   }
-    
+
   if (!CXXIdx->getUseExternalASTGeneration()) {
     llvm::SmallVector<const char *, 16> Args;
 
@@ -981,19 +981,19 @@
                 command_line_args + num_command_line_args);
 
     unsigned NumErrors = Diags->getNumErrors();
-    
+
 #ifdef USE_CRASHTRACER
     ArgsCrashTracerInfo ACTI(Args);
 #endif
-    
+
     llvm::OwningPtr<ASTUnit> Unit(
       ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
-                                   *Diags, 
+                                   *Diags,
                                    CXXIdx->getClangResourcesPath(),
                                    CXXIdx->getOnlyLocalDecls(),
                                    RemappedFiles.data(),
                                    RemappedFiles.size()));
-    
+
     // FIXME: Until we have broader testing, just drop the entire AST if we
     // encountered an error.
     if (NumErrors != Diags->getNumErrors())
@@ -1028,12 +1028,12 @@
   std::vector<std::string> RemapArgs;
   if (RemapFiles(num_unsaved_files, unsaved_files, RemapArgs, TemporaryFiles))
     return 0;
-  
+
   // The pointers into the elements of RemapArgs are stable because we
   // won't be adding anything to RemapArgs after this point.
   for (unsigned i = 0, e = RemapArgs.size(); i != e; ++i)
     argv.push_back(RemapArgs[i].c_str());
-  
+
   // Process the compiler options, stripping off '-o', '-c', '-fsyntax-only'.
   for (int i = 0; i < num_command_line_args; ++i)
     if (const char *arg = command_line_args[i]) {
@@ -1079,7 +1079,7 @@
       if (*I)
         AllArgs += *I;
     }
-    
+
     Diags->Report(diag::err_fe_clang) << AllArgs << ErrMsg;
   }
 
@@ -1091,16 +1091,16 @@
                                           RemappedFiles.size());
   if (ATU)
     ATU->unlinkTemporaryFile();
-  
+
   // FIXME: Currently we don't report diagnostics on invalid ASTs.
   if (ATU)
-    ReportSerializedDiagnostics(DiagnosticsFile, *Diags, 
+    ReportSerializedDiagnostics(DiagnosticsFile, *Diags,
                                 num_unsaved_files, unsaved_files,
                                 ATU->getASTContext().getLangOptions());
 
   for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
     TemporaryFiles[i].eraseFromDisk();
-  
+
   return ATU;
 }
 
@@ -1112,7 +1112,7 @@
 CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) {
   if (!CTUnit)
     return createCXString("");
-  
+
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
   return createCXString(CXXUnit->getOriginalSourceFileName(), true);
 }
@@ -1146,13 +1146,13 @@
                                    unsigned column) {
   if (!tu)
     return clang_getNullLocation();
-  
+
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(tu);
   SourceLocation SLoc
     = CXXUnit->getSourceManager().getLocation(
-                                        static_cast<const FileEntry *>(file), 
+                                        static_cast<const FileEntry *>(file),
                                               line, column);
-  
+
   return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
 }
 
@@ -1165,8 +1165,8 @@
   if (begin.ptr_data[0] != end.ptr_data[0] ||
       begin.ptr_data[1] != end.ptr_data[1])
     return clang_getNullRange();
-  
-  CXSourceRange Result = { { begin.ptr_data[0], begin.ptr_data[1] }, 
+
+  CXSourceRange Result = { { begin.ptr_data[0], begin.ptr_data[1] },
                            begin.int_data, end.int_data };
   return Result;
 }
@@ -1205,7 +1205,7 @@
 }
 
 CXSourceLocation clang_getRangeStart(CXSourceRange range) {
-  CXSourceLocation Result = { { range.ptr_data[0], range.ptr_data[1] }, 
+  CXSourceLocation Result = { { range.ptr_data[0], range.ptr_data[1] },
                               range.begin_int_data };
   return Result;
 }
@@ -1226,7 +1226,7 @@
 CXString clang_getFileName(CXFile SFile) {
   if (!SFile)
     return createCXString(NULL);
-  
+
   FileEntry *FEnt = static_cast<FileEntry *>(SFile);
   return createCXString(FEnt->getName());
 }
@@ -1234,22 +1234,22 @@
 time_t clang_getFileTime(CXFile SFile) {
   if (!SFile)
     return 0;
-  
+
   FileEntry *FEnt = static_cast<FileEntry *>(SFile);
   return FEnt->getModificationTime();
 }
-  
+
 CXFile clang_getFile(CXTranslationUnit tu, const char *file_name) {
   if (!tu)
     return 0;
-  
+
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(tu);
-  
+
   FileManager &FMgr = CXXUnit->getFileManager();
   const FileEntry *File = FMgr.getFile(file_name, file_name+strlen(file_name));
   return const_cast<FileEntry *>(File);
 }
-  
+
 } // end: extern "C"
 
 //===----------------------------------------------------------------------===//
@@ -1263,14 +1263,14 @@
     return ME->getMemberDecl();
   if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
     return RE->getDecl();
-  
+
   if (CallExpr *CE = dyn_cast<CallExpr>(E))
     return getDeclFromExpr(CE->getCallee());
   if (CastExpr *CE = dyn_cast<CastExpr>(E))
     return getDeclFromExpr(CE->getSubExpr());
   if (ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(E))
     return OME->getMethodDecl();
-  
+
   return 0;
 }
 
@@ -1287,23 +1287,23 @@
 }
 
 extern "C" {
-  
-unsigned clang_visitChildren(CXCursor parent, 
+
+unsigned clang_visitChildren(CXCursor parent,
                              CXCursorVisitor visitor,
                              CXClientData client_data) {
   ASTUnit *CXXUnit = getCursorASTUnit(parent);
 
   unsigned PCHLevel = Decl::MaxPCHLevel;
-  
+
   // Set the PCHLevel to filter out unwanted decls if requested.
   if (CXXUnit->getOnlyLocalDecls()) {
     PCHLevel = 0;
-    
+
     // If the main input was an AST, bump the level.
     if (CXXUnit->isMainFileAST())
       ++PCHLevel;
   }
-  
+
   CursorVisitor CursorVis(CXXUnit, visitor, client_data, PCHLevel);
   return CursorVis.VisitChildren(parent);
 }
@@ -1312,22 +1312,22 @@
   NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D);
   if (!ND)
     return createCXString("");
-  
+
   if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
     return createCXString(OMD->getSelector().getAsString());
-  
+
   if (ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
     // No, this isn't the same as the code below. getIdentifier() is non-virtual
     // and returns different names. NamedDecl returns the class name and
     // ObjCCategoryImplDecl returns the category name.
     return createCXString(CIMP->getIdentifier()->getNameStart());
-  
+
   if (ND->getIdentifier())
     return createCXString(ND->getIdentifier()->getNameStart());
-  
+
   return createCXString("");
 }
-    
+
 CXString clang_getCursorSpelling(CXCursor C) {
   if (clang_isTranslationUnit(C.kind))
     return clang_getTranslationUnitSpelling(C.data[2]);
@@ -1518,29 +1518,29 @@
 CXSourceLocation clang_getCursorLocation(CXCursor C) {
   if (clang_isReference(C.kind)) {
     switch (C.kind) {
-    case CXCursor_ObjCSuperClassRef: {       
+    case CXCursor_ObjCSuperClassRef: {
       std::pair<ObjCInterfaceDecl *, SourceLocation> P
         = getCursorObjCSuperClassRef(C);
       return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
     }
 
-    case CXCursor_ObjCProtocolRef: {       
+    case CXCursor_ObjCProtocolRef: {
       std::pair<ObjCProtocolDecl *, SourceLocation> P
         = getCursorObjCProtocolRef(C);
       return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
     }
 
-    case CXCursor_ObjCClassRef: {       
+    case CXCursor_ObjCClassRef: {
       std::pair<ObjCInterfaceDecl *, SourceLocation> P
         = getCursorObjCClassRef(C);
       return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
     }
 
-    case CXCursor_TypeRef: {       
+    case CXCursor_TypeRef: {
       std::pair<TypeDecl *, SourceLocation> P = getCursorTypeRef(C);
       return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
     }
-      
+
     default:
       // FIXME: Need a way to enumerate all non-reference cases.
       llvm_unreachable("Missed a reference kind");
@@ -1548,7 +1548,7 @@
   }
 
   if (clang_isExpression(C.kind))
-    return cxloc::translateSourceLocation(getCursorContext(C), 
+    return cxloc::translateSourceLocation(getCursorContext(C),
                                    getLocationFromExpr(getCursorExpr(C)));
 
   if (!getCursorDecl(C))
@@ -1564,30 +1564,30 @@
 CXSourceRange clang_getCursorExtent(CXCursor C) {
   if (clang_isReference(C.kind)) {
     switch (C.kind) {
-      case CXCursor_ObjCSuperClassRef: {       
+      case CXCursor_ObjCSuperClassRef: {
         std::pair<ObjCInterfaceDecl *, SourceLocation> P
           = getCursorObjCSuperClassRef(C);
         return cxloc::translateSourceRange(P.first->getASTContext(), P.second);
       }
-        
-      case CXCursor_ObjCProtocolRef: {       
+
+      case CXCursor_ObjCProtocolRef: {
         std::pair<ObjCProtocolDecl *, SourceLocation> P
           = getCursorObjCProtocolRef(C);
         return cxloc::translateSourceRange(P.first->getASTContext(), P.second);
       }
-        
-      case CXCursor_ObjCClassRef: {       
+
+      case CXCursor_ObjCClassRef: {
         std::pair<ObjCInterfaceDecl *, SourceLocation> P
           = getCursorObjCClassRef(C);
-        
+
         return cxloc::translateSourceRange(P.first->getASTContext(), P.second);
       }
 
-      case CXCursor_TypeRef: {       
+      case CXCursor_TypeRef: {
         std::pair<TypeDecl *, SourceLocation> P = getCursorTypeRef(C);
         return cxloc::translateSourceRange(P.first->getASTContext(), P.second);
       }
-        
+
       default:
         // FIXME: Need a way to enumerate all non-reference cases.
         llvm_unreachable("Missed a reference kind");
@@ -1595,16 +1595,16 @@
   }
 
   if (clang_isExpression(C.kind))
-    return cxloc::translateSourceRange(getCursorContext(C), 
+    return cxloc::translateSourceRange(getCursorContext(C),
                                 getCursorExpr(C)->getSourceRange());
 
   if (clang_isStatement(C.kind))
-    return cxloc::translateSourceRange(getCursorContext(C), 
+    return cxloc::translateSourceRange(getCursorContext(C),
                                 getCursorStmt(C)->getSourceRange());
-  
+
   if (!getCursorDecl(C))
     return clang_getNullRange();
-  
+
   Decl *D = getCursorDecl(C);
   return cxloc::translateSourceRange(D->getASTContext(), D->getSourceRange());
 }
@@ -1612,11 +1612,11 @@
 CXCursor clang_getCursorReferenced(CXCursor C) {
   if (clang_isInvalid(C.kind))
     return clang_getNullCursor();
-  
+
   ASTUnit *CXXUnit = getCursorASTUnit(C);
   if (clang_isDeclaration(C.kind))
     return C;
-  
+
   if (clang_isExpression(C.kind)) {
     Decl *D = getDeclFromExpr(getCursorExpr(C));
     if (D)
@@ -1626,36 +1626,36 @@
 
   if (!clang_isReference(C.kind))
     return clang_getNullCursor();
-  
+
   switch (C.kind) {
     case CXCursor_ObjCSuperClassRef:
       return MakeCXCursor(getCursorObjCSuperClassRef(C).first, CXXUnit);
-      
-    case CXCursor_ObjCProtocolRef: {       
+
+    case CXCursor_ObjCProtocolRef: {
       return MakeCXCursor(getCursorObjCProtocolRef(C).first, CXXUnit);
-      
-    case CXCursor_ObjCClassRef:      
+
+    case CXCursor_ObjCClassRef:
       return MakeCXCursor(getCursorObjCClassRef(C).first, CXXUnit);
 
-    case CXCursor_TypeRef:      
+    case CXCursor_TypeRef:
       return MakeCXCursor(getCursorTypeRef(C).first, CXXUnit);
-      
+
     default:
       // We would prefer to enumerate all non-reference cursor kinds here.
       llvm_unreachable("Unhandled reference cursor kind");
       break;
     }
   }
-  
+
   return clang_getNullCursor();
 }
 
 CXCursor clang_getCursorDefinition(CXCursor C) {
   if (clang_isInvalid(C.kind))
     return clang_getNullCursor();
-  
+
   ASTUnit *CXXUnit = getCursorASTUnit(C);
-  
+
   bool WasReference = false;
   if (clang_isReference(C.kind) || clang_isExpression(C.kind)) {
     C = clang_getCursorReferenced(C);
@@ -1668,7 +1668,7 @@
   Decl *D = getCursorDecl(C);
   if (!D)
     return clang_getNullCursor();
-  
+
   switch (D->getKind()) {
   // Declaration kinds that don't really separate the notions of
   // declaration and definition.
@@ -1737,19 +1737,19 @@
       return MakeCXCursor(Def, CXXUnit);
     return clang_getNullCursor();
   }
-   
+
   case Decl::FunctionTemplate: {
     const FunctionDecl *Def = 0;
     if (cast<FunctionTemplateDecl>(D)->getTemplatedDecl()->getBody(Def))
       return MakeCXCursor(Def->getDescribedFunctionTemplate(), CXXUnit);
     return clang_getNullCursor();
   }
-   
+
   case Decl::ClassTemplate: {
     if (RecordDecl *Def = cast<ClassTemplateDecl>(D)->getTemplatedDecl()
                                                             ->getDefinition())
       return MakeCXCursor(
-                         cast<CXXRecordDecl>(Def)->getDescribedClassTemplate(), 
+                         cast<CXXRecordDecl>(Def)->getDescribedClassTemplate(),
                           CXXUnit);
     return clang_getNullCursor();
   }
@@ -1757,15 +1757,15 @@
   case Decl::Using: {
     UsingDecl *Using = cast<UsingDecl>(D);
     CXCursor Def = clang_getNullCursor();
-    for (UsingDecl::shadow_iterator S = Using->shadow_begin(), 
-                                 SEnd = Using->shadow_end(); 
+    for (UsingDecl::shadow_iterator S = Using->shadow_begin(),
+                                 SEnd = Using->shadow_end();
          S != SEnd; ++S) {
       if (Def != clang_getNullCursor()) {
         // FIXME: We have no way to return multiple results.
         return clang_getNullCursor();
       }
 
-      Def = clang_getCursorDefinition(MakeCXCursor((*S)->getTargetDecl(), 
+      Def = clang_getCursorDefinition(MakeCXCursor((*S)->getTargetDecl(),
                                                    CXXUnit));
     }
 
@@ -1774,7 +1774,7 @@
 
   case Decl::UsingShadow:
     return clang_getCursorDefinition(
-                       MakeCXCursor(cast<UsingShadowDecl>(D)->getTargetDecl(), 
+                       MakeCXCursor(cast<UsingShadowDecl>(D)->getTargetDecl(),
                                     CXXUnit));
 
   case Decl::ObjCMethod: {
@@ -1820,7 +1820,7 @@
                               = cast<ObjCInterfaceDecl>(D)->getImplementation())
       return MakeCXCursor(Impl, CXXUnit);
     return clang_getNullCursor();
-  
+
   case Decl::ObjCProperty:
     // FIXME: We don't really know where to find the
     // ObjCPropertyImplDecls that implement this property.
@@ -1831,14 +1831,14 @@
           = cast<ObjCCompatibleAliasDecl>(D)->getClassInterface())
       if (!Class->isForwardDecl())
         return MakeCXCursor(Class, CXXUnit);
-    
+
     return clang_getNullCursor();
 
   case Decl::ObjCForwardProtocol: {
     ObjCForwardProtocolDecl *Forward = cast<ObjCForwardProtocolDecl>(D);
     if (Forward->protocol_size() == 1)
       return clang_getCursorDefinition(
-                                     MakeCXCursor(*Forward->protocol_begin(), 
+                                     MakeCXCursor(*Forward->protocol_begin(),
                                                   CXXUnit));
 
     // FIXME: Cannot return multiple definitions.
@@ -1890,7 +1890,7 @@
   NamedDecl *ND = static_cast<NamedDecl *>(getCursorDecl(C));
   FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
   CompoundStmt *Body = dyn_cast<CompoundStmt>(FD->getBody());
-  
+
   SourceManager &SM = FD->getASTContext().getSourceManager();
   *startBuf = SM.getCharacterData(Body->getLBracLoc());
   *endBuf = SM.getCharacterData(Body->getRBracLoc());
@@ -1899,7 +1899,7 @@
   *endLine = SM.getSpellingLineNumber(Body->getRBracLoc());
   *endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc());
 }
-  
+
 } // end: extern "C"
 
 //===----------------------------------------------------------------------===//
@@ -1911,7 +1911,7 @@
  *   int_data[1]: starting token location
  *   int_data[2]: token length
  *   int_data[3]: reserved
- *   ptr_data: for identifiers and keywords, an IdentifierInfo*. 
+ *   ptr_data: for identifiers and keywords, an IdentifierInfo*.
  *   otherwise unused.
  */
 extern "C" {
@@ -1933,18 +1933,18 @@
     const char *Text = static_cast<const char *>(CXTok.ptr_data);
     return createCXString(llvm::StringRef(Text, CXTok.int_data[2]));
   }
-      
+
   case CXToken_Punctuation:
   case CXToken_Comment:
     break;
   }
-  
-  // We have to find the starting buffer pointer the hard way, by 
+
+  // We have to find the starting buffer pointer the hard way, by
   // deconstructing the source location.
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU);
   if (!CXXUnit)
     return createCXString("");
-  
+
   SourceLocation Loc = SourceLocation::getFromRawEncoding(CXTok.int_data[1]);
   std::pair<FileID, unsigned> LocInfo
     = CXXUnit->getSourceManager().getDecomposedLoc(Loc);
@@ -1954,12 +1954,12 @@
   return createCXString(llvm::StringRef(Buffer.first+LocInfo.second,
                                         CXTok.int_data[2]));
 }
- 
+
 CXSourceLocation clang_getTokenLocation(CXTranslationUnit TU, CXToken CXTok) {
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU);
   if (!CXXUnit)
     return clang_getNullLocation();
-  
+
   return cxloc::translateSourceLocation(CXXUnit->getASTContext(),
                         SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
 }
@@ -1968,44 +1968,44 @@
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU);
   if (!CXXUnit)
     return clang_getNullRange();
-  
-  return cxloc::translateSourceRange(CXXUnit->getASTContext(), 
+
+  return cxloc::translateSourceRange(CXXUnit->getASTContext(),
                         SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
 }
-  
+
 void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
                     CXToken **Tokens, unsigned *NumTokens) {
   if (Tokens)
     *Tokens = 0;
   if (NumTokens)
     *NumTokens = 0;
-  
+
   ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU);
   if (!CXXUnit || !Tokens || !NumTokens)
     return;
-  
+
   SourceRange R = cxloc::translateCXSourceRange(Range);
   if (R.isInvalid())
     return;
-  
+
   SourceManager &SourceMgr = CXXUnit->getSourceManager();
   std::pair<FileID, unsigned> BeginLocInfo
     = SourceMgr.getDecomposedLoc(R.getBegin());
   std::pair<FileID, unsigned> EndLocInfo
     = SourceMgr.getDecomposedLoc(R.getEnd());
-  
+
   // Cannot tokenize across files.
   if (BeginLocInfo.first != EndLocInfo.first)
     return;
-  
-  // Create a lexer 
+
+  // Create a lexer
   std::pair<const char *,const char *> Buffer
     = SourceMgr.getBufferData(BeginLocInfo.first);
   Lexer Lex(SourceMgr.getLocForStartOfFile(BeginLocInfo.first),
             CXXUnit->getASTContext().getLangOptions(),
             Buffer.first, Buffer.first + BeginLocInfo.second, Buffer.second);
   Lex.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we hit the end of the range.
   const char *EffectiveBufferEnd = Buffer.first + EndLocInfo.second;
   llvm::SmallVector<CXToken, 32> CXTokens;
@@ -2015,25 +2015,25 @@
     Lex.LexFromRawLexer(Tok);
     if (Tok.is(tok::eof))
       break;
-    
+
     // Initialize the CXToken.
     CXToken CXTok;
-    
+
     //   - Common fields
     CXTok.int_data[1] = Tok.getLocation().getRawEncoding();
     CXTok.int_data[2] = Tok.getLength();
     CXTok.int_data[3] = 0;
-    
+
     //   - Kind-specific fields
     if (Tok.isLiteral()) {
       CXTok.int_data[0] = CXToken_Literal;
       CXTok.ptr_data = (void *)Tok.getLiteralData();
     } else if (Tok.is(tok::identifier)) {
-      // Lookup the identifier to determine whether we have a 
+      // Lookup the identifier to determine whether we have a
       std::pair<FileID, unsigned> LocInfo
         = SourceMgr.getDecomposedLoc(Tok.getLocation());
-      const char *StartPos 
-        = CXXUnit->getSourceManager().getBufferData(LocInfo.first).first + 
+      const char *StartPos
+        = CXXUnit->getSourceManager().getBufferData(LocInfo.first).first +
           LocInfo.second;
       IdentifierInfo *II
         = CXXUnit->getPreprocessor().LookUpIdentifierInfo(Tok, StartPos);
@@ -2050,10 +2050,10 @@
     }
     CXTokens.push_back(CXTok);
   } while (Lex.getBufferLocation() <= EffectiveBufferEnd);
-  
+
   if (CXTokens.empty())
     return;
-  
+
   *Tokens = (CXToken *)malloc(sizeof(CXToken) * CXTokens.size());
   memmove(*Tokens, CXTokens.data(), sizeof(CXToken) * CXTokens.size());
   *NumTokens = CXTokens.size();
@@ -2061,8 +2061,8 @@
 
 typedef llvm::DenseMap<unsigned, CXCursor> AnnotateTokensData;
 
-enum CXChildVisitResult AnnotateTokensVisitor(CXCursor cursor, 
-                                              CXCursor parent, 
+enum CXChildVisitResult AnnotateTokensVisitor(CXCursor cursor,
+                                              CXCursor parent,
                                               CXClientData client_data) {
   AnnotateTokensData *Data = static_cast<AnnotateTokensData *>(client_data);
 
@@ -2081,13 +2081,13 @@
     CXCursor Referenced = clang_getCursorReferenced(cursor);
     if (Referenced == cursor || Referenced == clang_getNullCursor())
       return CXChildVisit_Recurse;
-    
+
     // Okay: we can annotate the location of this expression
   } else {
     // Nothing to annotate
     return CXChildVisit_Recurse;
   }
-  
+
   CXSourceLocation Loc = clang_getCursorLocation(cursor);
   (*Data)[Loc.int_data] = cursor;
   return CXChildVisit_Recurse;
@@ -2107,12 +2107,12 @@
   if (!CXXUnit || !Tokens)
     return;
 
-  // Annotate all of the source locations in the region of interest that map 
+  // Annotate all of the source locations in the region of interest that map
   SourceRange RegionOfInterest;
   RegionOfInterest.setBegin(
         cxloc::translateSourceLocation(clang_getTokenLocation(TU, Tokens[0])));
   SourceLocation End
-    = cxloc::translateSourceLocation(clang_getTokenLocation(TU, 
+    = cxloc::translateSourceLocation(clang_getTokenLocation(TU,
                                                      Tokens[NumTokens - 1]));
   RegionOfInterest.setEnd(CXXUnit->getPreprocessor().getLocForEndOfToken(End));
   // FIXME: Would be great to have a "hint" cursor, then walk from that
@@ -2120,7 +2120,7 @@
   // the region of interest, rather than starting from the translation unit.
   AnnotateTokensData Annotated;
   CXCursor Parent = clang_getTranslationUnitCursor(CXXUnit);
-  CursorVisitor AnnotateVis(CXXUnit, AnnotateTokensVisitor, &Annotated, 
+  CursorVisitor AnnotateVis(CXXUnit, AnnotateTokensVisitor, &Annotated,
                             Decl::MaxPCHLevel, RegionOfInterest);
   AnnotateVis.VisitChildren(Parent);
 
@@ -2134,11 +2134,11 @@
   }
 }
 
-void clang_disposeTokens(CXTranslationUnit TU, 
+void clang_disposeTokens(CXTranslationUnit TU,
                          CXToken *Tokens, unsigned NumTokens) {
   free(Tokens);
 }
-  
+
 } // end: extern "C"
 
 //===----------------------------------------------------------------------===//
@@ -2189,7 +2189,7 @@
 //===----------------------------------------------------------------------===//
 // Misc. utility functions.
 //===----------------------------------------------------------------------===//
-  
+
 extern "C" {
 
 CXString clang_getClangVersion() {





More information about the cfe-commits mailing list