blob: db0779f8b362270bf94e2aef498bc8d5a4e317e1 [file] [log] [blame]
Douglas Gregor87c30072010-07-26 04:08:02 +00001//===--- Action.cpp - Implement the Action class --------------------------===//
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 Action interface.
11//
12//===----------------------------------------------------------------------===//
13
John McCall19510852010-08-20 18:27:03 +000014#include "clang/Sema/DeclSpec.h"
15#include "clang/Sema/Scope.h"
Douglas Gregor87c30072010-07-26 04:08:02 +000016#include "clang/Basic/TargetInfo.h"
17#include "llvm/Support/Allocator.h"
18#include "llvm/Support/RecyclingAllocator.h"
19#include "llvm/Support/raw_ostream.h"
20using namespace clang;
21
22void PrettyStackTraceActionsDecl::print(llvm::raw_ostream &OS) const {
23 if (Loc.isValid()) {
24 Loc.print(OS, SM);
25 OS << ": ";
26 }
27 OS << Message;
28
29 std::string Name = Actions.getDeclName(TheDecl);
30 if (!Name.empty())
31 OS << " '" << Name << '\'';
32
33 OS << '\n';
34}
35
36/// Out-of-line virtual destructor to provide home for ActionBase class.
37ActionBase::~ActionBase() {}
38
39/// Out-of-line virtual destructor to provide home for Action class.
40Action::~Action() {}
41
42Action::ObjCMessageKind Action::getObjCMessageKind(Scope *S,
43 IdentifierInfo *Name,
44 SourceLocation NameLoc,
45 bool IsSuper,
46 bool HasTrailingDot,
47 TypeTy *&ReceiverType) {
48 ReceiverType = 0;
49
50 if (IsSuper && !HasTrailingDot && S->isInObjcMethodScope())
51 return ObjCSuperMessage;
52
53 if (TypeTy *TyName = getTypeName(*Name, NameLoc, S)) {
54 DeclSpec DS;
55 const char *PrevSpec = 0;
56 unsigned DiagID = 0;
57 if (!DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec,
58 DiagID, TyName)) {
59 DS.SetRangeEnd(NameLoc);
60 Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
61 TypeResult Ty = ActOnTypeName(S, DeclaratorInfo);
62 if (!Ty.isInvalid())
63 ReceiverType = Ty.get();
64 }
65 return ObjCClassMessage;
66 }
67
68 return ObjCInstanceMessage;
69}
70
71// Defined out-of-line here because of dependecy on AttributeList
72Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope,
73 SourceLocation UsingLoc,
74 SourceLocation NamespcLoc,
75 CXXScopeSpec &SS,
76 SourceLocation IdentLoc,
77 IdentifierInfo *NamespcName,
78 AttributeList *AttrList) {
79
80 // FIXME: Parser seems to assume that Action::ActOn* takes ownership over
81 // passed AttributeList, however other actions don't free it, is it
82 // temporary state or bug?
83 delete AttrList;
84 return DeclPtrTy();
85}
86
87// Defined out-of-line here because of dependency on AttributeList
88Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope,
89 AccessSpecifier AS,
90 bool HasUsingKeyword,
91 SourceLocation UsingLoc,
92 CXXScopeSpec &SS,
93 UnqualifiedId &Name,
94 AttributeList *AttrList,
95 bool IsTypeName,
96 SourceLocation TypenameLoc) {
97
98 // FIXME: Parser seems to assume that Action::ActOn* takes ownership over
99 // passed AttributeList, however other actions don't free it, is it
100 // temporary state or bug?
101 delete AttrList;
102 return DeclPtrTy();
103}