zcov: / include/clang/Parse/AttributeList.h


Files: 1 Branches Taken: 37.5% 3 / 8
Generated: 2010-02-10 01:31 Branches Executed: 62.5% 5 / 8
Line Coverage: 100.0% 44 / 44


Programs: 24 Runs 36216


       1                 : //===--- AttributeList.h ----------------------------------------*- 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 AttributeList class interface.
      11                 : //
      12                 : //===----------------------------------------------------------------------===//
      13                 : 
      14                 : #ifndef LLVM_CLANG_ATTRLIST_H
      15                 : #define LLVM_CLANG_ATTRLIST_H
      16                 : 
      17                 : #include "clang/Parse/Ownership.h"
      18                 : #include "clang/Basic/SourceLocation.h"
      19                 : #include <cassert>
      20                 : 
      21                 : namespace clang {
      22                 :   class IdentifierInfo;
      23                 :   class Action;
      24                 : 
      25                 : /// AttributeList - Represents GCC's __attribute__ declaration. There are
      26                 : /// 4 forms of this construct...they are:
      27                 : ///
      28                 : /// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
      29                 : /// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
      30                 : /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
      31                 : /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
      32                 : ///
      33                 : class AttributeList {
      34                 :   IdentifierInfo *AttrName;
      35                 :   SourceLocation AttrLoc;
      36                 :   IdentifierInfo *ScopeName;
      37                 :   SourceLocation ScopeLoc;
      38                 :   IdentifierInfo *ParmName;
      39                 :   SourceLocation ParmLoc;
      40                 :   ActionBase::ExprTy **Args;
      41                 :   unsigned NumArgs;
      42                 :   AttributeList *Next;
      43                 :   bool DeclspecAttribute, CXX0XAttribute;
      44                 :   AttributeList(const AttributeList &); // DO NOT IMPLEMENT
      45                 :   void operator=(const AttributeList &); // DO NOT IMPLEMENT
      46                 : public:
      47                 :   AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
      48                 :                 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
      49                 :                 IdentifierInfo *ParmName, SourceLocation ParmLoc,
      50                 :                 ActionBase::ExprTy **args, unsigned numargs,
      51                 :                 AttributeList *Next, bool declspec = false, bool cxx0x = false);
      52                 :   ~AttributeList();
      53                 : 
      54                 :   enum Kind {              // Please keep this list alphabetized.
      55                 :     AT_IBOutlet,          // Clang-specific.
      56                 :     AT_address_space,
      57                 :     AT_alias,
      58                 :     AT_aligned,
      59                 :     AT_always_inline,
      60                 :     AT_analyzer_noreturn,
      61                 :     AT_annotate,
      62                 :     AT_base_check,
      63                 :     AT_blocks,
      64                 :     AT_carries_dependency,
      65                 :     AT_cdecl,
      66                 :     AT_cleanup,
      67                 :     AT_const,
      68                 :     AT_constructor,
      69                 :     AT_deprecated,
      70                 :     AT_destructor,
      71                 :     AT_dllexport,
      72                 :     AT_dllimport,
      73                 :     AT_ext_vector_type,
      74                 :     AT_fastcall,
      75                 :     AT_final,
      76                 :     AT_format,
      77                 :     AT_format_arg,
      78                 :     AT_gnu_inline,
      79                 :     AT_hiding,
      80                 :     AT_malloc,
      81                 :     AT_mode,
      82                 :     AT_nodebug,
      83                 :     AT_noinline,
      84                 :     AT_no_instrument_function,
      85                 :     AT_nonnull,
      86                 :     AT_noreturn,
      87                 :     AT_nothrow,
      88                 :     AT_nsobject,
      89                 :     AT_objc_exception,
      90                 :     AT_override,
      91                 :     AT_cf_returns_retained,   // Clang-specific.
      92                 :     AT_ns_returns_retained,   // Clang-specific.
      93                 :     AT_objc_gc,
      94                 :     AT_overloadable,       // Clang-specific.
      95                 :     AT_packed,
      96                 :     AT_pure,
      97                 :     AT_regparm,
      98                 :     AT_section,
      99                 :     AT_sentinel,
     100                 :     AT_stdcall,
     101                 :     AT_transparent_union,
     102                 :     AT_unavailable,
     103                 :     AT_unused,
     104                 :     AT_used,
     105                 :     AT_vector_size,
     106                 :     AT_visibility,
     107                 :     AT_warn_unused_result,
     108                 :     AT_weak,
     109                 :     AT_weak_import,
     110                 :     AT_reqd_wg_size,
     111                 :     IgnoredAttribute,
     112                 :     UnknownAttribute
     113                 :   };
     114                 : 
     115            12945:   IdentifierInfo *getName() const { return AttrName; }
     116              218:   SourceLocation getLoc() const { return AttrLoc; }
     117                 :   
     118                 :   bool hasScope() const { return ScopeName; }
     119                 :   IdentifierInfo *getScopeName() const { return ScopeName; }
     120                 :   SourceLocation getScopeLoc() const { return ScopeLoc; }
     121                 :   
     122              913:   IdentifierInfo *getParameterName() const { return ParmName; }
     123                 : 
     124             4890:   bool isDeclspecAttribute() const { return DeclspecAttribute; }
     125                4:   bool isCXX0XAttribute() const { return CXX0XAttribute; }
     126                 : 
     127            12917:   Kind getKind() const { return getKind(getName()); }
     128                 :   static Kind getKind(const IdentifierInfo *Name);
     129                 : 
     130            12735:   AttributeList *getNext() const { return Next; }
     131                4:   void setNext(AttributeList *N) { Next = N; }
     132                 : 
     133                 :   /// getNumArgs - Return the number of actual arguments to this attribute.
     134             4574:   unsigned getNumArgs() const { return NumArgs; }
     135                 : 
     136                 :   /// getArg - Return the specified argument.
     137              573:   ActionBase::ExprTy *getArg(unsigned Arg) const {
                        0: branch 0 not taken
                      573: branch 1 taken
     138              573:     assert(Arg < NumArgs && "Arg access out of range!");
     139              573:     return Args[Arg];
     140                 :   }
     141                 : 
     142                 :   class arg_iterator {
     143                 :     ActionBase::ExprTy** X;
     144                 :     unsigned Idx;
     145                 :   public:
     146              818:     arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
     147                 : 
     148              582:     arg_iterator& operator++() {
     149              582:       ++Idx;
     150              582:       return *this;
     151                 :     }
     152                 : 
     153              991:     bool operator==(const arg_iterator& I) const {
     154                 :       assert (X == I.X &&
                        0: branch 0 not taken
                      991: branch 1 taken
     155              991:               "compared arg_iterators are for different argument lists");
     156              991:       return Idx == I.Idx;
     157                 :     }
     158                 : 
     159              991:     bool operator!=(const arg_iterator& I) const {
     160              991:       return !operator==(I);
     161                 :     }
     162                 : 
     163              583:     ActionBase::ExprTy* operator*() const {
     164              583:       return X[Idx];
     165                 :     }
     166                 : 
     167                1:     unsigned getArgNum() const {
     168                1:       return Idx+1;
     169                 :     }
     170                 :   };
     171                 : 
     172              409:   arg_iterator arg_begin() const {
     173              409:     return arg_iterator(Args, 0);
     174                 :   }
     175                 : 
     176              409:   arg_iterator arg_end() const {
     177              409:     return arg_iterator(Args, NumArgs);
     178                 :   }
     179                 : };
     180                 : 
     181                 : /// addAttributeLists - Add two AttributeLists together
     182                 : /// The right-hand list is appended to the left-hand list, if any
     183                 : /// A pointer to the joined list is returned.
     184                 : /// Note: the lists are not left unmodified.
     185                 : inline AttributeList* addAttributeLists (AttributeList *Left,
     186             8162:                                          AttributeList *Right) {
                     8158: branch 1 taken
                        0: branch 1 not taken
     187             8162:   if (!Left)
     188             8158:     return Right;
     189                 : 
     190                4:   AttributeList *next = Left, *prev;
                        0: branch 0 not taken
                        0: branch 1 not taken
     191                4:   do {
     192                4:     prev = next;
     193                4:     next = next->getNext();
     194                 :   } while (next);
     195                4:   prev->setNext(Right);
     196                4:   return Left;
     197                 : }
     198                 : 
     199                 : /// CXX0XAttributeList - A wrapper around a C++0x attribute list.
     200                 : /// Stores, in addition to the list proper, whether or not an actual list was
     201                 : /// (as opposed to an empty list, which may be ill-formed in some places) and
     202                 : /// the source range of the list.
     203                 : struct CXX0XAttributeList { 
     204                 :   AttributeList *AttrList;
     205                 :   SourceRange Range;
     206                 :   bool HasAttr;
     207               51:   CXX0XAttributeList (AttributeList *attrList, SourceRange range, bool hasAttr)
     208               51:     : AttrList(attrList), Range(range), HasAttr (hasAttr) {
     209               51:   }
     210            63392:   CXX0XAttributeList ()
     211            63392:     : AttrList(0), Range(), HasAttr(false) {
     212            63392:   }
     213                 : };
     214                 : 
     215                 : }  // end namespace clang
     216                 : 
     217                 : #endif

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