aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParsePragma.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Parse/ParsePragma.cpp')
-rw-r--r--lib/Parse/ParsePragma.cpp65
1 files changed, 24 insertions, 41 deletions
diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp
index 58c729aef29e..812d8e2af901 100644
--- a/lib/Parse/ParsePragma.cpp
+++ b/lib/Parse/ParsePragma.cpp
@@ -37,7 +37,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
IdentifierInfo *Name = 0;
Action::OwningExprResult Alignment(Actions);
SourceLocation LParenLoc = Tok.getLocation();
- PP.Lex(Tok);
+ PP.Lex(Tok);
if (Tok.is(tok::numeric_constant)) {
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
@@ -57,12 +57,12 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
} else {
PP.Diag(Tok.getLocation(), diag::warn_pragma_pack_invalid_action);
return;
- }
+ }
PP.Lex(Tok);
-
+
if (Tok.is(tok::comma)) {
PP.Lex(Tok);
-
+
if (Tok.is(tok::numeric_constant)) {
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
@@ -72,15 +72,15 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
} else if (Tok.is(tok::identifier)) {
Name = Tok.getIdentifierInfo();
PP.Lex(Tok);
-
+
if (Tok.is(tok::comma)) {
PP.Lex(Tok);
-
+
if (Tok.isNot(tok::numeric_constant)) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_pack_malformed);
return;
}
-
+
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
return;
@@ -115,7 +115,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
// FIXME: Should we be expanding macros here? My guess is no.
SourceLocation UnusedLoc = UnusedTok.getLocation();
-
+
// Lex the left '('.
Token Tok;
PP.Lex(Tok);
@@ -124,57 +124,39 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
return;
}
SourceLocation LParenLoc = Tok.getLocation();
-
+
// Lex the declaration reference(s).
- llvm::SmallVector<Action::ExprTy*, 5> Ex;
+ llvm::SmallVector<Token, 5> Identifiers;
SourceLocation RParenLoc;
bool LexID = true;
-
+
while (true) {
PP.Lex(Tok);
-
+
if (LexID) {
- if (Tok.is(tok::identifier)) {
- Action::OwningExprResult Name =
- Actions.ActOnIdentifierExpr(parser.CurScope, Tok.getLocation(),
- *Tok.getIdentifierInfo(), false);
-
- if (Name.isInvalid()) {
- if (!Ex.empty())
- Action::MultiExprArg Release(Actions, &Ex[0], Ex.size());
- return;
- }
-
- Ex.push_back(Name.release());
+ if (Tok.is(tok::identifier)) {
+ Identifiers.push_back(Tok);
LexID = false;
continue;
}
- // Illegal token! Release the parsed expressions (if any) and emit
- // a warning.
- if (!Ex.empty())
- Action::MultiExprArg Release(Actions, &Ex[0], Ex.size());
-
+ // Illegal token!
PP.Diag(Tok.getLocation(), diag::warn_pragma_unused_expected_var);
return;
}
-
+
// We are execting a ')' or a ','.
if (Tok.is(tok::comma)) {
LexID = true;
continue;
}
-
+
if (Tok.is(tok::r_paren)) {
RParenLoc = Tok.getLocation();
break;
}
-
- // Illegal token! Release the parsed expressions (if any) and emit
- // a warning.
- if (!Ex.empty())
- Action::MultiExprArg Release(Actions, &Ex[0], Ex.size());
-
+
+ // Illegal token!
PP.Diag(Tok.getLocation(), diag::warn_pragma_unused_expected_punc);
return;
}
@@ -188,10 +170,11 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
// Verify that we have a location for the right parenthesis.
assert(RParenLoc.isValid() && "Valid '#pragma unused' must have ')'");
- assert(!Ex.empty() && "Valid '#pragma unused' must have arguments");
+ assert(!Identifiers.empty() && "Valid '#pragma unused' must have arguments");
- // Perform the action to handle the pragma.
- Actions.ActOnPragmaUnused(&Ex[0], Ex.size(), UnusedLoc, LParenLoc, RParenLoc);
+ // Perform the action to handle the pragma.
+ Actions.ActOnPragmaUnused(Identifiers.data(), Identifiers.size(),
+ parser.CurScope, UnusedLoc, LParenLoc, RParenLoc);
}
// #pragma weak identifier
@@ -214,7 +197,7 @@ void PragmaWeakHandler::HandlePragma(Preprocessor &PP, Token &WeakTok) {
if (Tok.is(tok::equal)) {
PP.Lex(Tok);
if (Tok.isNot(tok::identifier)) {
- PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
<< "weak";
return;
}