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