zcov: / lib/Lex/MacroInfo.cpp


Files: 1 Branches Taken: 73.7% 28 / 38
Generated: 2010-02-10 01:31 Branches Executed: 100.0% 38 / 38
Line Coverage: 89.7% 26 / 29


Programs: 2 Runs 3018


       1                 : //===--- MacroInfo.cpp - Information about #defined identifiers -----------===//
       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 implements the MacroInfo interface.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #include "clang/Lex/MacroInfo.h"
      15                 : #include "clang/Lex/Preprocessor.h"
      16                 : using namespace clang;
      17                 : 
      18           303204: MacroInfo::MacroInfo(SourceLocation DefLoc) : Location(DefLoc) {
      19           303204:   IsFunctionLike = false;
      20           303204:   IsC99Varargs = false;
      21           303204:   IsGNUVarargs = false;
      22           303204:   IsBuiltinMacro = false;
      23           303204:   IsDisabled = false;
      24           303204:   IsUsed = true;
      25                 : 
      26           303204:   ArgumentList = 0;
      27           303204:   NumArguments = 0;
      28           303204: }
      29                 : 
      30                 : /// isIdenticalTo - Return true if the specified macro definition is equal to
      31                 : /// this macro in spelling, arguments, and whitespace.  This is used to emit
      32                 : /// duplicate definition warnings.  This implements the rules in C99 6.10.3.
      33                 : ///
      34                9: bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const {
      35                 :   // Check # tokens in replacement, number of args, and various flags all match.
                        6: branch 2 taken
                        3: branch 3 taken
                        6: branch 6 taken
                        0: branch 7 not taken
                        6: branch 10 taken
                        0: branch 11 not taken
                        6: branch 14 taken
                        0: branch 15 not taken
                        0: branch 18 not taken
                        6: branch 19 taken
                        3: branch 20 taken
                        6: branch 21 taken
      36                9:   if (ReplacementTokens.size() != Other.ReplacementTokens.size() ||
      37                 :       getNumArgs() != Other.getNumArgs() ||
      38                 :       isFunctionLike() != Other.isFunctionLike() ||
      39                 :       isC99Varargs() != Other.isC99Varargs() ||
      40                 :       isGNUVarargs() != Other.isGNUVarargs())
      41                3:     return false;
      42                 : 
      43                 :   // Check arguments.
                        5: branch 3 taken
                        6: branch 4 taken
      44               11:   for (arg_iterator I = arg_begin(), OI = Other.arg_begin(), E = arg_end();
      45                 :        I != E; ++I, ++OI)
                        0: branch 0 not taken
                        5: branch 1 taken
      46                5:     if (*I != *OI) return false;
      47                 : 
      48                 :   // Check all the tokens.
                       15: branch 1 taken
                        5: branch 2 taken
      49               20:   for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) {
      50               15:     const Token &A = ReplacementTokens[i];
      51               15:     const Token &B = Other.ReplacementTokens[i];
                        0: branch 2 not taken
                       15: branch 3 taken
      52               15:     if (A.getKind() != B.getKind())
      53                0:       return false;
      54                 : 
      55                 :     // If this isn't the first first token, check that the whitespace and
      56                 :     // start-of-line characteristics match.
                       10: branch 0 taken
                        5: branch 1 taken
                       10: branch 4 taken
                        0: branch 5 not taken
                        1: branch 8 taken
                        9: branch 9 taken
                        1: branch 10 taken
                       14: branch 11 taken
      57               15:     if (i != 0 &&
      58                 :         (A.isAtStartOfLine() != B.isAtStartOfLine() ||
      59                 :          A.hasLeadingSpace() != B.hasLeadingSpace()))
      60                1:       return false;
      61                 : 
      62                 :     // If this is an identifier, it is easy.
                        8: branch 1 taken
                        6: branch 2 taken
                        0: branch 4 not taken
                        8: branch 5 taken
                        6: branch 6 taken
                        8: branch 7 taken
      63               14:     if (A.getIdentifierInfo() || B.getIdentifierInfo()) {
                        0: branch 2 not taken
                        6: branch 3 taken
      64                6:       if (A.getIdentifierInfo() != B.getIdentifierInfo())
      65                0:         return false;
      66                6:       continue;
      67                 :     }
      68                 : 
      69                 :     // Otherwise, check the spelling.
                        0: branch 5 not taken
                        8: branch 6 taken
      70                8:     if (PP.getSpelling(A) != PP.getSpelling(B))
      71                0:       return false;
      72                 :   }
      73                 : 
      74                5:   return true;
      75                 : }

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