split ParseStringExpr into semantic/minimal actions

llvm-svn: 39147
This commit is contained in:
Chris Lattner 2006-11-08 06:03:59 +00:00
parent 87ca807e15
commit 3503cefbba
2 changed files with 30 additions and 12 deletions

View File

@ -932,6 +932,12 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() {
ConsumeStringToken(); ConsumeStringToken();
} while (isTokenStringLiteral()); } while (isTokenStringLiteral());
// If using minimal actions, don't do any semantic analysis of the parsed
// string fragments.
if (MinimalActions)
return MinimalActions->ParseStringExpr(&StringToks[0], StringToks.size());
// Include space for the null terminator. // Include space for the null terminator.
++SizeBound; ++SizeBound;
@ -1098,8 +1104,8 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() {
StringTokLocs.push_back(StringToks[i].getLocation()); StringTokLocs.push_back(StringToks[i].getLocation());
// Hand this off to the Actions. // Hand this off to the Actions.
return Actions.ParseStringExpr(&ResultBuf[0], ResultPtr-&ResultBuf[0], return SemaActions->ParseStringExpr(&ResultBuf[0], ResultPtr-&ResultBuf[0],
AnyWide, &StringTokLocs[0], AnyWide, &StringTokLocs[0],
StringTokLocs.size()); StringTokLocs.size());
} }

View File

@ -26,6 +26,7 @@ namespace clang {
class Action; class Action;
// Lex. // Lex.
class IdentifierInfo; class IdentifierInfo;
class LexerToken;
/// Action - As the parser reads the input file and recognizes the productions /// Action - As the parser reads the input file and recognizes the productions
/// of the grammar, it invokes methods on this class to turn the parsed input /// of the grammar, it invokes methods on this class to turn the parsed input
@ -208,15 +209,6 @@ public:
return Val; // Default impl returns operand. return Val; // Default impl returns operand.
} }
/// ParseStringExpr - The (null terminated) string data is specified with
/// StrData+StrLen. isWide is true if this is a wide string. The Toks/NumToks
/// array exposes the input tokens to provide location information.
virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
bool isWide,
SourceLocation *TokLocs, unsigned NumToks){
return 0;
}
// Postfix Expressions. // Postfix Expressions.
virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc, virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
tok::TokenKind Kind, ExprTy *Input) { tok::TokenKind Kind, ExprTy *Input) {
@ -300,6 +292,17 @@ public:
virtual DeclTy *ParsedClassDeclaration(Scope *S, virtual DeclTy *ParsedClassDeclaration(Scope *S,
IdentifierInfo **IdentList, IdentifierInfo **IdentList,
unsigned NumElts); unsigned NumElts);
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
//===--------------------------------------------------------------------===//
/// ParseStringExpr - The specified tokens were lexed as pasted string
/// fragments (e.g. "foo" "bar" L"baz").
virtual ExprResult ParseStringExpr(const LexerToken *Toks, unsigned NumToks){
return 0;
}
}; };
/// SemanticAction - Clients the implement this interface expect Decl nodes to /// SemanticAction - Clients the implement this interface expect Decl nodes to
@ -308,6 +311,15 @@ public:
class SemanticAction : public Action { class SemanticAction : public Action {
public: public:
/// ParseStringExpr - The (null terminated) string data is specified with
/// StrData+StrLen. isWide is true if this is a wide string. The Toks/NumToks
/// array exposes the input tokens to provide location information.
virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
bool isWide,
SourceLocation *TokLocs, unsigned NumToks){
return 0;
}
}; };
} // end namespace clang } // end namespace clang