Convert "#pragma unused(...)" into tokens for the parser.
This allows us to cache a "#pragma unused" that occurs inside an inline C++ member function.
Fixes rdar://8829590&8770988.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123666 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index de1e1bf..a67c4fb 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -263,37 +263,31 @@
}
}
-void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers,
- Scope *curScope,
- SourceLocation PragmaLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc) {
+void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope,
+ SourceLocation PragmaLoc) {
- for (unsigned i = 0; i < NumIdentifiers; ++i) {
- const Token &Tok = Identifiers[i];
- IdentifierInfo *Name = Tok.getIdentifierInfo();
- LookupResult Lookup(*this, Name, Tok.getLocation(), LookupOrdinaryName);
- LookupParsedName(Lookup, curScope, NULL, true);
+ IdentifierInfo *Name = IdTok.getIdentifierInfo();
+ LookupResult Lookup(*this, Name, IdTok.getLocation(), LookupOrdinaryName);
+ LookupParsedName(Lookup, curScope, NULL, true);
- if (Lookup.empty()) {
- Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
- << Name << SourceRange(Tok.getLocation());
- continue;
- }
-
- VarDecl *VD = Lookup.getAsSingle<VarDecl>();
- if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) {
- Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar)
- << Name << SourceRange(Tok.getLocation());
- continue;
- }
-
- // Warn if this was used before being marked unused.
- if (VD->isUsed())
- Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
-
- VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context));
+ if (Lookup.empty()) {
+ Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
+ << Name << SourceRange(IdTok.getLocation());
+ return;
}
+
+ VarDecl *VD = Lookup.getAsSingle<VarDecl>();
+ if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) {
+ Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar)
+ << Name << SourceRange(IdTok.getLocation());
+ return;
+ }
+
+ // Warn if this was used before being marked unused.
+ if (VD->isUsed())
+ Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name;
+
+ VD->addAttr(::new (Context) UnusedAttr(IdTok.getLocation(), Context));
}
typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack;