forked from OSchip/llvm-project
parent
4f8eb127e1
commit
81a5a69682
|
@ -326,7 +326,9 @@ void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
|
|||
|
||||
|
||||
void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
|
||||
Indent() << "asm (/*todo*/);\n";
|
||||
Indent() << "asm (";
|
||||
VisitStringLiteral(Node->getAsmString());
|
||||
OS << ");\n";
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitObjcAtTryStmt(ObjcAtTryStmt *Node) {
|
||||
|
|
|
@ -197,14 +197,16 @@ ArraySubscriptExpr* ArraySubscriptExpr::CreateImpl(Deserializer& D) {
|
|||
|
||||
void AsmStmt::EmitImpl(Serializer& S) const {
|
||||
S.Emit(AsmLoc);
|
||||
getAsmString()->EmitImpl(S);
|
||||
S.Emit(RParenLoc);
|
||||
}
|
||||
|
||||
AsmStmt* AsmStmt::CreateImpl(Deserializer& D) {
|
||||
SourceLocation ALoc = SourceLocation::ReadVal(D);
|
||||
StringLiteral *AsmStr = StringLiteral::CreateImpl(D);
|
||||
SourceLocation PLoc = SourceLocation::ReadVal(D);
|
||||
|
||||
return new AsmStmt(ALoc,PLoc);
|
||||
return new AsmStmt(ALoc, AsmStr, PLoc);
|
||||
}
|
||||
|
||||
void BinaryOperator::EmitImpl(Serializer& S) const {
|
||||
|
|
|
@ -943,7 +943,9 @@ Parser::StmtResult Parser::ParseAsmStatement() {
|
|||
}
|
||||
Loc = ConsumeParen();
|
||||
|
||||
ParseAsmStringLiteral();
|
||||
ExprResult AsmString = ParseAsmStringLiteral();
|
||||
if (AsmString.isInvalid)
|
||||
return true;
|
||||
|
||||
// Parse Outputs, if present.
|
||||
ParseAsmOperandsOpt();
|
||||
|
@ -969,7 +971,7 @@ Parser::StmtResult Parser::ParseAsmStatement() {
|
|||
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
|
||||
|
||||
// FIXME: Pass all the details down to the action.
|
||||
return Actions.ActOnAsmStmt(AsmLoc, RParenLoc);
|
||||
return Actions.ActOnAsmStmt(AsmLoc, AsmString.Val, RParenLoc);
|
||||
}
|
||||
|
||||
/// ParseAsmOperands - Parse the asm-operands production as used by
|
||||
|
|
|
@ -575,16 +575,18 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) {
|
|||
/// [GNU] asm-string-literal:
|
||||
/// string-literal
|
||||
///
|
||||
void Parser::ParseAsmStringLiteral() {
|
||||
Parser::ExprResult Parser::ParseAsmStringLiteral() {
|
||||
if (!isTokenStringLiteral()) {
|
||||
Diag(Tok, diag::err_expected_string_literal);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
ExprResult Res = ParseStringLiteralExpression();
|
||||
if (Res.isInvalid) return;
|
||||
if (Res.isInvalid) return true;
|
||||
|
||||
// TODO: Diagnose: wide string literal in 'asm'
|
||||
|
||||
return Res;
|
||||
}
|
||||
|
||||
/// ParseSimpleAsm
|
||||
|
|
|
@ -347,6 +347,7 @@ public:
|
|||
ExprTy *RetValExp);
|
||||
|
||||
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
|
||||
ExprTy *AsmString,
|
||||
SourceLocation RParenLoc);
|
||||
|
||||
virtual StmtResult ActOnObjcAtCatchStmt(SourceLocation AtLoc,
|
||||
|
|
|
@ -645,8 +645,11 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
|
|||
}
|
||||
|
||||
Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
||||
ExprTy *AsmString,
|
||||
SourceLocation RParenLoc) {
|
||||
return new AsmStmt(AsmLoc, RParenLoc);
|
||||
Expr *E = (Expr *)AsmString;
|
||||
|
||||
return new AsmStmt(AsmLoc, cast<StringLiteral>(E), RParenLoc);
|
||||
}
|
||||
|
||||
Action::StmtResult
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace clang {
|
|||
class ScopedDecl;
|
||||
class IdentifierInfo;
|
||||
class SourceManager;
|
||||
class StringLiteral;
|
||||
class SwitchStmt;
|
||||
class PrinterHelper;
|
||||
|
||||
|
@ -704,10 +705,16 @@ public:
|
|||
///
|
||||
class AsmStmt : public Stmt {
|
||||
SourceLocation AsmLoc, RParenLoc;
|
||||
StringLiteral *AsmStr;
|
||||
// FIXME: This doesn't capture most of the interesting pieces.
|
||||
public:
|
||||
AsmStmt(SourceLocation asmloc, SourceLocation rparenloc)
|
||||
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc) {}
|
||||
AsmStmt(SourceLocation asmloc, StringLiteral *asmstr,
|
||||
SourceLocation rparenloc)
|
||||
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc),
|
||||
AsmStr(asmstr) {}
|
||||
|
||||
const StringLiteral *getAsmString() const { return AsmStr; }
|
||||
StringLiteral *getAsmString() { return AsmStr; }
|
||||
|
||||
virtual SourceRange getSourceRange() const {
|
||||
return SourceRange(AsmLoc, RParenLoc);
|
||||
|
|
|
@ -287,6 +287,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
|
||||
ExprTy *AsmString,
|
||||
SourceLocation RParenLoc) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -245,6 +245,9 @@ private:
|
|||
bool SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
|
||||
bool StopAtSemi = true, bool DontConsume = false);
|
||||
|
||||
typedef Action::ExprResult ExprResult;
|
||||
typedef Action::StmtResult StmtResult;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// C99 6.9: External Definitions.
|
||||
DeclTy *ParseExternalDeclaration();
|
||||
|
@ -252,7 +255,7 @@ private:
|
|||
DeclTy *ParseFunctionDefinition(Declarator &D);
|
||||
void ParseKNRParamDeclarations(Declarator &D);
|
||||
void ParseSimpleAsm();
|
||||
void ParseAsmStringLiteral();
|
||||
ExprResult ParseAsmStringLiteral();
|
||||
|
||||
// Objective-C External Declarations
|
||||
DeclTy *ParseObjCAtDirectives();
|
||||
|
@ -305,9 +308,6 @@ private:
|
|||
//===--------------------------------------------------------------------===//
|
||||
// C99 6.5: Expressions.
|
||||
|
||||
typedef Action::ExprResult ExprResult;
|
||||
typedef Action::StmtResult StmtResult;
|
||||
|
||||
ExprResult ParseExpression();
|
||||
ExprResult ParseConstantExpression();
|
||||
ExprResult ParseAssignmentExpression(); // Expr that doesn't include commas.
|
||||
|
|
Loading…
Reference in New Issue