zcov: / tools/CIndex/CXSourceLocation.h


Files: 1 Branches Taken: 0.0% 0 / 0
Generated: 2010-02-10 01:31 Branches Executed: 0.0% 0 / 0
Line Coverage: 100.0% 13 / 13


Programs: 3 Runs 363


       1                 : //===- CXSourceLocation.h - Routines for manipulating CXSourceLocations ---===//
       2                 : //
       3                 : //                     The LLVM Compiler Infrastructure
       4                 : //
       5                 : // This file is distributed under the University of Illinois Open Source
       6                 : // License. See LICENSE.TXT for details.
       7                 : //
       8                 : //===----------------------------------------------------------------------===//
       9                 : //
      10                 : // This file defines routines for manipulating CXSourceLocations.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #ifndef LLVM_CLANG_CXSOURCELOCATION_H
      15                 : #define LLVM_CLANG_CXSOURCELOCATION_H
      16                 : 
      17                 : #include "clang-c/Index.h"
      18                 : #include "clang/Basic/SourceLocation.h"
      19                 : #include "clang/Basic/SourceManager.h"
      20                 : #include "clang/Basic/LangOptions.h"
      21                 : #include "clang/AST/ASTContext.h"
      22                 : 
      23                 : namespace clang {
      24                 :       
      25                 : class ASTContext;
      26                 : 
      27                 : namespace cxloc {
      28                 :   
      29                 : typedef llvm::PointerIntPair<const SourceManager *, 1, bool> 
      30                 :   CXSourceLocationPtr;
      31                 : 
      32                 : /// \brief Translate a Clang source location into a CIndex source location.
      33                 : static inline CXSourceLocation 
      34                 : translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
      35            13670:                         SourceLocation Loc, bool AtEnd = false) {
      36            13670:   CXSourceLocationPtr Ptr(&SM, AtEnd);
      37                 :   CXSourceLocation Result = { { Ptr.getOpaqueValue(), (void *)&LangOpts, },
      38            13670:                               Loc.getRawEncoding() };
      39                 :   return Result;
      40                 : }
      41                 :   
      42                 : /// \brief Translate a Clang source location into a CIndex source location.
      43                 : static inline CXSourceLocation translateSourceLocation(ASTContext &Context,
      44                 :                                                        SourceLocation Loc,
      45            13614:                                                        bool AtEnd = false) {
      46                 :   return translateSourceLocation(Context.getSourceManager(), 
      47                 :                                  Context.getLangOptions(),
      48            13614:                                  Loc, AtEnd);
      49                 : }
      50                 : 
      51                 : /// \brief Translate a Clang source range into a CIndex source range.
      52                 : static inline CXSourceRange translateSourceRange(const SourceManager &SM, 
      53                 :                                                  const LangOptions &LangOpts,
      54             3492:                                                  SourceRange R) {
      55                 :   CXSourceRange Result = { { (void *)&SM, (void *)&LangOpts },
      56                 :                            R.getBegin().getRawEncoding(),
      57             3492:                            R.getEnd().getRawEncoding() };
      58                 :   return Result;
      59                 : }
      60                 :   
      61                 : /// \brief Translate a Clang source range into a CIndex source range.
      62                 : static inline CXSourceRange translateSourceRange(ASTContext &Context,
      63             3479:                                                  SourceRange R) {
      64                 :   return translateSourceRange(Context.getSourceManager(),
      65                 :                               Context.getLangOptions(),
      66             3479:                               R);
      67                 : }
      68                 : 
      69            12827: static inline SourceLocation translateSourceLocation(CXSourceLocation L) {
      70            12827:   return SourceLocation::getFromRawEncoding(L.int_data);
      71                 : }
      72                 : 
      73             6383: static inline SourceRange translateSourceRange(CXSourceRange R) {
      74                 :   return SourceRange(SourceLocation::getFromRawEncoding(R.begin_int_data),
      75             6383:                      SourceLocation::getFromRawEncoding(R.end_int_data));
      76                 : }
      77                 : 
      78                 : 
      79                 : }} // end namespace: clang::cxloc
      80                 : 
      81                 : #endif

Generated: 2010-02-10 01:31 by zcov