/// and 'Init' specifies the initializer if any. This is for things like:
/// "int X = 4" or "typedef int foo".
virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,
- DeclTy *LastInGroup, ExprTy *AsmLabel) {
+ DeclTy *LastInGroup) {
llvm::cout << __FUNCTION__ << " ";
if (IdentifierInfo *II = D.getIdentifier()) {
llvm::cout << "'" << II->getName() << "'";
llvm::cout << "\n";
// Pass up to EmptyActions so that the symbol table is maintained right.
- return MinimalAction::ActOnDeclarator(S, D, LastInGroup, AsmLabel);
+ return MinimalAction::ActOnDeclarator(S, D, LastInGroup);
}
/// ActOnPopScope - This callback is called immediately before the specified
/// scope is popped and deleted.
/// LastInGroup is non-null for cases where one declspec has multiple
/// declarators on it. For example in 'int A, B', ActOnDeclarator will be
/// called with LastInGroup=A when invoked for B.
- ///
- /// AsmLabel is non-null only for top-level function declarations
- /// which use the GCC asm-label extension (the expression must be a
- /// constant string).
- virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
- ExprTy *AsmLabel) {
+ virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,DeclTy *LastInGroup) {
return 0;
}
virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
// Default to ActOnDeclarator.
return ActOnStartOfFunctionDef(FnBodyScope,
- ActOnDeclarator(FnBodyScope, D, 0, 0));
+ ActOnDeclarator(FnBodyScope, D, 0));
}
/// ActOnStartOfFunctionDef - This is called at the start of a function
/// ActOnDeclarator - If this is a typedef declarator, we modify the
/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
/// popped.
- virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
- ExprTy *AsmLabel);
+ virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
/// ActOnPopScope - When a scope is popped, if any typedefs are now
/// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.
// InvalidType - Set by Sema::GetTypeForDeclarator().
bool InvalidType;
- // attributes.
+ /// AttrList - Attributes.
AttributeList *AttrList;
+
+ /// AsmLabel - The asm label, if specified.
+ Action::ExprTy *AsmLabel;
+
public:
Declarator(DeclSpec &ds, TheContext C)
- : DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0) {
+ : DS(ds), Identifier(0), Context(C), InvalidType(false), AttrList(0),
+ AsmLabel(0) {
}
~Declarator() {
}
const AttributeList *getAttributes() const { return AttrList; }
AttributeList *getAttributes() { return AttrList; }
-
+
+ void setAsmLabel(Action::ExprTy *E) { AsmLabel = E; }
+ Action::ExprTy *getAsmLabel() const { return AsmLabel; }
+
void setInvalidType(bool flag) { InvalidType = flag; }
bool getInvalidType() const { return InvalidType; }
};
/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
/// popped.
Action::DeclTy *
-MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
- ExprTy *AsmLabel) {
+MinimalAction::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) {
IdentifierInfo *II = D.getIdentifier();
// If there is no identifier associated with this declarator, bail out.
// rest of the init-declarator-list.
while (1) {
// If a simple-asm-expr is present, parse it.
- ExprResult AsmLabel;
if (Tok.is(tok::kw_asm)) {
- AsmLabel = ParseSimpleAsm();
+ ExprResult AsmLabel = ParseSimpleAsm();
if (AsmLabel.isInvalid) {
SkipUntil(tok::semi);
return 0;
}
+
+ D.setAsmLabel(AsmLabel.Val);
}
// If attributes are present, parse them.
// Inform the current actions module that we just parsed this declarator.
// FIXME: pass asm & attributes.
- LastDeclInGroup = Actions.ActOnDeclarator(CurScope, D, LastDeclInGroup,
- AsmLabel.Val);
+ LastDeclInGroup = Actions.ActOnDeclarator(CurScope, D, LastDeclInGroup);
// Parse declarator '=' initializer.
if (Tok.is(tok::equal)) {
ParseDeclarator(DeclaratorInfo);
if (DeclaratorInfo.getIdentifier()) {
DeclTy *aBlockVarDecl = Actions.ActOnDeclarator(CurScope,
- DeclaratorInfo, 0, 0);
+ DeclaratorInfo, 0);
StmtResult stmtResult =
Actions.ActOnDeclStmt(aBlockVarDecl,
DS.getSourceRange().getBegin(),
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
virtual TypeTy *isTypeName(const IdentifierInfo &II, Scope *S);
- virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup,
- ExprTy *AsmLabel);
+ virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D);
virtual void ActOnParamDefaultArgument(DeclTy *param,
SourceLocation EqualLoc,
}
Sema::DeclTy *
-Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl, ExprTy *AsmLabel) {
+Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl);
IdentifierInfo *II = D.getIdentifier();
ProcessDeclAttributes(NewFD, D);
// Handle GNU asm-label extension (encoded as an attribute).
- if (Expr *E = (Expr*) AsmLabel) {
+ if (Expr *E = (Expr*) D.getAsmLabel()) {
// The parser guarantees this is a string.
StringLiteral *SE = cast<StringLiteral>(E);
NewFD->addAttr(new AsmLabelAttr(std::string(SE->getStrData(),
}
return ActOnStartOfFunctionDef(FnBodyScope,
- ActOnDeclarator(GlobalScope, D, 0, 0));
+ ActOnDeclarator(GlobalScope, D, 0));
}
Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
CurContext = Context.getTranslationUnitDecl();
FunctionDecl *FD =
- dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0, 0)));
+ dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(TUScope, D, 0)));
FD->setImplicit();
CurContext = PrevDC;
if (isInstField)
Member = static_cast<Decl*>(ActOnField(S, Loc, D, BitWidth));
else
- Member = static_cast<Decl*>(ActOnDeclarator(S, D, LastInGroup, 0));
+ Member = static_cast<Decl*>(ActOnDeclarator(S, D, LastInGroup));
if (!Member) return LastInGroup;