zcov: / include/clang/Lex/DirectoryLookup.h


Files: 1 Branches Taken: 25.0% 2 / 8
Generated: 2010-02-10 01:31 Branches Executed: 50.0% 4 / 8
Line Coverage: 52.6% 10 / 19


Programs: 4 Runs 6036


       1                 : //===--- DirectoryLookup.h - Info for searching for headers -----*- C++ -*-===//
       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 the DirectoryLookup interface.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #ifndef LLVM_CLANG_LEX_DIRECTORYLOOKUP_H
      15                 : #define LLVM_CLANG_LEX_DIRECTORYLOOKUP_H
      16                 : 
      17                 : #include "clang/Basic/SourceManager.h"
      18                 : 
      19                 : namespace llvm {
      20                 :   class StringRef;
      21                 : }
      22                 : namespace clang {
      23                 : class HeaderMap;
      24                 : class DirectoryEntry;
      25                 : class FileEntry;
      26                 : class HeaderSearch;
      27                 : 
      28                 : /// DirectoryLookup - This class represents one entry in the search list that
      29                 : /// specifies the search order for directories in #include directives.  It
      30                 : /// represents either a directory, a framework, or a headermap.
      31                 : ///
      32             6321: class DirectoryLookup {
      33                 : public:
      34                 :   enum LookupType_t {
      35                 :     LT_NormalDir,
      36                 :     LT_Framework,
      37                 :     LT_HeaderMap
      38                 :   };
      39                 : private:
      40                 :   union {  // This union is discriminated by isHeaderMap.
      41                 :     /// Dir - This is the actual directory that we're referring to for a normal
      42                 :     /// directory or a framework.
      43                 :     const DirectoryEntry *Dir;
      44                 : 
      45                 :     /// Map - This is the HeaderMap if this is a headermap lookup.
      46                 :     ///
      47                 :     const HeaderMap *Map;
      48                 :   } u;
      49                 : 
      50                 :   /// DirCharacteristic - The type of directory this is: this is an instance of
      51                 :   /// SrcMgr::CharacteristicKind.
      52                 :   unsigned DirCharacteristic : 2;
      53                 : 
      54                 :   /// UserSupplied - True if this is a user-supplied directory.
      55                 :   ///
      56                 :   bool UserSupplied : 1;
      57                 : 
      58                 :   /// LookupType - This indicates whether this DirectoryLookup object is a
      59                 :   /// normal directory, a framework, or a headermap.
      60                 :   unsigned LookupType : 2;
      61                 : public:
      62                 :   /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
      63                 :   /// 'dir'.
      64                 :   DirectoryLookup(const DirectoryEntry *dir, SrcMgr::CharacteristicKind DT,
      65            16253:                   bool isUser, bool isFramework)
      66                 :     : DirCharacteristic(DT), UserSupplied(isUser),
                        0: branch 0 not taken
                    16253: branch 1 taken
      67            16253:      LookupType(isFramework ? LT_Framework : LT_NormalDir) {
      68            16253:     u.Dir = dir;
      69            16253:   }
      70                 : 
      71                 :   /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
      72                 :   /// 'map'.
      73                 :   DirectoryLookup(const HeaderMap *map, SrcMgr::CharacteristicKind DT,
      74                0:                   bool isUser)
      75                0:     : DirCharacteristic(DT), UserSupplied(isUser), LookupType(LT_HeaderMap) {
      76                0:     u.Map = map;
      77                0:   }
      78                 : 
      79                 :   /// getLookupType - Return the kind of directory lookup that this is: either a
      80                 :   /// normal directory, a framework path, or a HeaderMap.
      81           114524:   LookupType_t getLookupType() const { return (LookupType_t)LookupType; }
      82                 : 
      83                 :   /// getName - Return the directory or filename corresponding to this lookup
      84                 :   /// object.
      85                 :   const char *getName() const;
      86                 : 
      87                 :   /// getDir - Return the directory that this entry refers to.
      88                 :   ///
                    49360: branch 1 taken
                        0: branch 2 not taken
      89            49360:   const DirectoryEntry *getDir() const { return isNormalDir() ? u.Dir : 0; }
      90                 : 
      91                 :   /// getFrameworkDir - Return the directory that this framework refers to.
      92                 :   ///
      93                0:   const DirectoryEntry *getFrameworkDir() const {
                        0: branch 1 not taken
                        0: branch 2 not taken
      94                0:     return isFramework() ? u.Dir : 0;
      95                 :   }
      96                 : 
      97                 :   /// getHeaderMap - Return the directory that this entry refers to.
      98                 :   ///
                        0: branch 1 not taken
                        0: branch 2 not taken
      99                0:   const HeaderMap *getHeaderMap() const { return isHeaderMap() ? u.Map : 0; }
     100                 : 
     101                 :   /// isNormalDir - Return true if this is a normal directory, not a header map.
     102            82922:   bool isNormalDir() const { return getLookupType() == LT_NormalDir; }
     103                 : 
     104                 :   /// isFramework - True if this is a framework directory.
     105                 :   ///
     106                0:   bool isFramework() const { return getLookupType() == LT_Framework; }
     107                 : 
     108                 :   /// isHeaderMap - Return true if this is a header map, not a normal directory.
     109                0:   bool isHeaderMap() const { return getLookupType() == LT_HeaderMap; }
     110                 : 
     111                 :   /// DirCharacteristic - The type of directory this is, one of the DirType enum
     112                 :   /// values.
     113            13283:   SrcMgr::CharacteristicKind getDirCharacteristic() const {
     114            13283:     return (SrcMgr::CharacteristicKind)DirCharacteristic;
     115                 :   }
     116                 : 
     117                 :   /// isUserSupplied - True if this is a user-supplied directory.
     118                 :   ///
     119                 :   bool isUserSupplied() const { return UserSupplied; }
     120                 : 
     121                 : 
     122                 :   /// LookupFile - Lookup the specified file in this search path, returning it
     123                 :   /// if it exists or returning null if not.
     124                 :   const FileEntry *LookupFile(llvm::StringRef Filename, HeaderSearch &HS) const;
     125                 : 
     126                 : private:
     127                 :   const FileEntry *DoFrameworkLookup(llvm::StringRef Filename,
     128                 :                                      HeaderSearch &HS) const;
     129                 : 
     130                 : };
     131                 : 
     132                 : }  // end namespace clang
     133                 : 
     134                 : #endif

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