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


Files: 1 Branches Taken: 58.3% 7 / 12
Generated: 2010-02-10 01:31 Branches Executed: 50.0% 6 / 12
Line Coverage: 48.8% 21 / 43


Programs: 5 Runs 8933


       1                 : //===--- PPCallbacks.h - Callbacks for Preprocessor actions -----*- 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 PPCallbacks interface.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #ifndef LLVM_CLANG_LEX_PPCALLBACKS_H
      15                 : #define LLVM_CLANG_LEX_PPCALLBACKS_H
      16                 : 
      17                 : #include "clang/Lex/DirectoryLookup.h"
      18                 : #include "clang/Basic/SourceLocation.h"
      19                 : #include <string>
      20                 : 
      21                 : namespace clang {
      22                 :   class SourceLocation;
      23                 :   class Token;
      24                 :   class IdentifierInfo;
      25                 :   class MacroInfo;
      26                 : 
      27                 : /// PPCallbacks - This interface provides a way to observe the actions of the
      28                 : /// preprocessor as it does its thing.  Clients can define their hooks here to
      29                 : /// implement preprocessor level tools.
      30              204: class PPCallbacks {
      31                 : public:
      32                 :   virtual ~PPCallbacks();
      33                 : 
      34                 :   enum FileChangeReason {
      35                 :     EnterFile, ExitFile, SystemHeaderPragma, RenameFile
      36                 :   };
      37                 : 
      38                 :   /// FileChanged - This callback is invoked whenever a source file is
      39                 :   /// entered or exited.  The SourceLocation indicates the new location, and
      40                 :   /// EnteringFile indicates whether this is because we are entering a new
      41                 :   /// #include'd file (when true) or whether we're exiting one because we ran
      42                 :   /// off the end (when false).
      43                 :   virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
      44                0:                            SrcMgr::CharacteristicKind FileType) {
      45                0:   }
      46                 : 
      47                 :   /// Ident - This callback is invoked when a #ident or #sccs directive is read.
      48                 :   ///
      49                0:   virtual void Ident(SourceLocation Loc, const std::string &str) {
      50                0:   }
      51                 : 
      52                 :   /// PragmaComment - This callback is invoked when a #pragma comment directive
      53                 :   /// is read.
      54                 :   ///
      55                 :   virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
      56                0:                              const std::string &Str) {
      57                0:   }
      58                 : 
      59                 :   /// MacroExpands - This is called by
      60                 :   /// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is
      61                 :   /// found.
      62             5323:   virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
      63             5323:   }
      64                 : 
      65                 :   /// MacroDefined - This hook is called whenever a macro definition is seen.
      66              321:   virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
      67              321:   }
      68                 : 
      69                 :   /// MacroUndefined - This hook is called whenever a macro #undef is seen.
      70                 :   /// MI is released immediately following this callback.
      71               71:   virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI) {
      72               71:   }
      73                 : };
      74                 : 
      75                 : /// PPChainedCallbacks - Simple wrapper class for chaining callbacks.
      76                 : class PPChainedCallbacks : public PPCallbacks {
      77                 :   PPCallbacks *First, *Second;
      78                 : 
      79                 : public:
      80                1:   PPChainedCallbacks(PPCallbacks *_First, PPCallbacks *_Second)
      81                1:     : First(_First), Second(_Second) {}
      82                1:   ~PPChainedCallbacks() {
                        1: branch 0 taken
                        0: branch 1 not taken
                        1: branch 3 taken
                        1: branch 4 taken
      83                1:     delete Second;
                        1: branch 0 taken
                        0: branch 1 not taken
                        1: branch 3 taken
                        1: branch 4 taken
      84                1:     delete First;
                        1: branch 1 taken
                        0: branch 2 not taken
                        0: branch 5 not taken
                        0: branch 6 not taken
      85                1:   }
      86                 : 
      87                 :   virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
      88                6:                            SrcMgr::CharacteristicKind FileType) {
      89                6:     First->FileChanged(Loc, Reason, FileType);
      90                6:     Second->FileChanged(Loc, Reason, FileType);
      91                6:   }
      92                 : 
      93                0:   virtual void Ident(SourceLocation Loc, const std::string &str) {
      94                0:     First->Ident(Loc, str);
      95                0:     Second->Ident(Loc, str);
      96                0:   }
      97                 : 
      98                 :   virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
      99                0:                              const std::string &Str) {
     100                0:     First->PragmaComment(Loc, Kind, Str);
     101                0:     Second->PragmaComment(Loc, Kind, Str);
     102                0:   }
     103                 : 
     104                0:   virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
     105                0:     First->MacroExpands(Id, MI);
     106                0:     Second->MacroExpands(Id, MI);
     107                0:   }
     108                 : 
     109              107:   virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
     110              107:     First->MacroDefined(II, MI);
     111              107:     Second->MacroDefined(II, MI);
     112              107:   }
     113                 : 
     114                0:   virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI) {
     115                0:     First->MacroUndefined(II, MI);
     116                0:     Second->MacroUndefined(II, MI);
     117                0:   }
     118                 : };
     119                 : 
     120                 : }  // end namespace clang
     121                 : 
     122                 : #endif

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