 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
95.5% |
21 / 22 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
63.6% |
14 / 22 |
| |
|
Line Coverage: |
100.0% |
17 / 17 |
| |
 |
|
 |
1 : //===--- AttributeList.cpp --------------------------------------*- 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 implementation
11 : //
12 : //===----------------------------------------------------------------------===//
13 :
14 : #include "clang/Parse/AttributeList.h"
15 : #include "clang/Basic/IdentifierTable.h"
16 : #include "llvm/ADT/StringSwitch.h"
17 : using namespace clang;
18 :
19 : AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
20 : IdentifierInfo *sName, SourceLocation sLoc,
21 : IdentifierInfo *pName, SourceLocation pLoc,
22 : ActionBase::ExprTy **ExprList, unsigned numArgs,
23 4891: AttributeList *n, bool declspec, bool cxx0x)
24 : : AttrName(aName), AttrLoc(aLoc), ScopeName(sName), ScopeLoc(sLoc),
25 : ParmName(pName), ParmLoc(pLoc), NumArgs(numArgs), Next(n),
26 4891: DeclspecAttribute(declspec), CXX0XAttribute(cxx0x) {
27 :
3970: branch 0 taken
921: branch 1 taken
921: branch 2 taken
921: branch 3 taken
28 4891: if (numArgs == 0)
29 3970: Args = 0;
30 : else {
31 921: Args = new ActionBase::ExprTy*[numArgs];
32 921: memcpy(Args, ExprList, numArgs*sizeof(Args[0]));
33 : }
34 4891: }
35 :
36 4791: AttributeList::~AttributeList() {
896: branch 0 taken
3895: branch 1 taken
3895: branch 2 taken
3895: branch 3 taken
37 4791: if (Args) {
38 : // FIXME: before we delete the vector, we need to make sure the Expr's
39 : // have been deleted. Since ActionBase::ExprTy is "void", we are dependent
40 : // on the actions module for actually freeing the memory. The specific
41 : // hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType,
42 : // ParseField, ParseTag. Once these routines have freed the expression,
43 : // they should zero out the Args slot (to indicate the memory has been
44 : // freed). If any element of the vector is non-null, we should assert.
896: branch 0 taken
0: branch 1 not taken
896: branch 3 taken
896: branch 4 taken
45 896: delete [] Args;
46 : }
1610: branch 0 taken
3181: branch 1 taken
1610: branch 4 taken
1610: branch 5 taken
47 4791: delete Next;
48 4791: }
49 :
50 12936: AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
51 12936: llvm::StringRef AttrName = Name->getName();
52 :
53 : // Normalize the attribute name, __foo__ becomes foo.
10454: branch 2 taken
2482: branch 3 taken
10432: branch 6 taken
22: branch 7 taken
10432: branch 8 taken
2504: branch 9 taken
54 12936: if (AttrName.startswith("__") && AttrName.endswith("__"))
55 10432: AttrName = AttrName.substr(2, AttrName.size() - 4);
56 :
57 : // FIXME: Hand generating this is neither smart nor efficient.
58 : return llvm::StringSwitch<AttributeList::Kind>(AttrName)
59 : .Case("weak", AT_weak)
60 : .Case("pure", AT_pure)
61 : .Case("mode", AT_mode)
62 : .Case("used", AT_used)
63 : .Case("alias", AT_alias)
64 : .Case("align", AT_aligned)
65 : .Case("final", AT_final)
66 : .Case("cdecl", AT_cdecl)
67 : .Case("const", AT_const)
68 : .Case("blocks", AT_blocks)
69 : .Case("format", AT_format)
70 : .Case("hiding", AT_hiding)
71 : .Case("malloc", AT_malloc)
72 : .Case("packed", AT_packed)
73 : .Case("unused", AT_unused)
74 : .Case("aligned", AT_aligned)
75 : .Case("cleanup", AT_cleanup)
76 : .Case("nodebug", AT_nodebug)
77 : .Case("nonnull", AT_nonnull)
78 : .Case("nothrow", AT_nothrow)
79 : .Case("objc_gc", AT_objc_gc)
80 : .Case("regparm", AT_regparm)
81 : .Case("section", AT_section)
82 : .Case("stdcall", AT_stdcall)
83 : .Case("annotate", AT_annotate)
84 : .Case("fastcall", AT_fastcall)
85 : .Case("iboutlet", AT_IBOutlet)
86 : .Case("noreturn", AT_noreturn)
87 : .Case("noinline", AT_noinline)
88 : .Case("override", AT_override)
89 : .Case("sentinel", AT_sentinel)
90 : .Case("NSObject", AT_nsobject)
91 : .Case("dllimport", AT_dllimport)
92 : .Case("dllexport", AT_dllexport)
93 : .Case("may_alias", IgnoredAttribute) // FIXME: TBAA
94 : .Case("base_check", AT_base_check)
95 : .Case("deprecated", AT_deprecated)
96 : .Case("visibility", AT_visibility)
97 : .Case("destructor", AT_destructor)
98 : .Case("format_arg", AT_format_arg)
99 : .Case("gnu_inline", AT_gnu_inline)
100 : .Case("weak_import", AT_weak_import)
101 : .Case("vector_size", AT_vector_size)
102 : .Case("constructor", AT_constructor)
103 : .Case("unavailable", AT_unavailable)
104 : .Case("overloadable", AT_overloadable)
105 : .Case("address_space", AT_address_space)
106 : .Case("always_inline", AT_always_inline)
107 : .Case("vec_type_hint", IgnoredAttribute)
108 : .Case("objc_exception", AT_objc_exception)
109 : .Case("ext_vector_type", AT_ext_vector_type)
110 : .Case("transparent_union", AT_transparent_union)
111 : .Case("analyzer_noreturn", AT_analyzer_noreturn)
112 : .Case("warn_unused_result", AT_warn_unused_result)
113 : .Case("carries_dependency", AT_carries_dependency)
114 : .Case("ns_returns_retained", AT_ns_returns_retained)
115 : .Case("cf_returns_retained", AT_cf_returns_retained)
116 : .Case("reqd_work_group_size", AT_reqd_wg_size)
117 : .Case("no_instrument_function", AT_no_instrument_function)
118 12936: .Default(UnknownAttribute);
119 : }
Generated: 2010-02-10 01:31 by zcov