forked from OSchip/llvm-project
Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies. llvm-svn: 138972
This commit is contained in:
parent
48d7798de1
commit
43ea78b48d
|
@ -406,25 +406,25 @@ public:
|
||||||
class NullStmt : public Stmt {
|
class NullStmt : public Stmt {
|
||||||
SourceLocation SemiLoc;
|
SourceLocation SemiLoc;
|
||||||
|
|
||||||
/// \brief If the null statement was preceded by an empty macro this is
|
/// \brief True if the null statement was preceded by an empty macro, e.g:
|
||||||
/// its instantiation source location, e.g:
|
|
||||||
/// @code
|
/// @code
|
||||||
/// #define CALL(x)
|
/// #define CALL(x)
|
||||||
/// CALL(0);
|
/// CALL(0);
|
||||||
/// @endcode
|
/// @endcode
|
||||||
SourceLocation LeadingEmptyMacro;
|
bool HasLeadingEmptyMacro;
|
||||||
public:
|
public:
|
||||||
NullStmt(SourceLocation L, SourceLocation LeadingEmptyMacro =SourceLocation())
|
NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
|
||||||
: Stmt(NullStmtClass), SemiLoc(L), LeadingEmptyMacro(LeadingEmptyMacro) {}
|
: Stmt(NullStmtClass), SemiLoc(L),
|
||||||
|
HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
|
||||||
|
|
||||||
/// \brief Build an empty null statement.
|
/// \brief Build an empty null statement.
|
||||||
explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) { }
|
explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty),
|
||||||
|
HasLeadingEmptyMacro(false) { }
|
||||||
|
|
||||||
SourceLocation getSemiLoc() const { return SemiLoc; }
|
SourceLocation getSemiLoc() const { return SemiLoc; }
|
||||||
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
|
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
|
||||||
|
|
||||||
bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro.isValid(); }
|
bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
|
||||||
SourceLocation getLeadingEmptyMacroLoc() const { return LeadingEmptyMacro; }
|
|
||||||
|
|
||||||
SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
|
SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
|
||||||
|
|
||||||
|
|
|
@ -227,10 +227,6 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
|
||||||
/// previous macro value.
|
/// previous macro value.
|
||||||
llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> > PragmaPushMacroInfo;
|
llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> > PragmaPushMacroInfo;
|
||||||
|
|
||||||
/// \brief Expansion source location for the last macro that expanded
|
|
||||||
/// to no tokens.
|
|
||||||
SourceLocation LastEmptyMacroExpansionLoc;
|
|
||||||
|
|
||||||
// Various statistics we track for performance analysis.
|
// Various statistics we track for performance analysis.
|
||||||
unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma;
|
unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma;
|
||||||
unsigned NumIf, NumElse, NumEndif;
|
unsigned NumIf, NumElse, NumEndif;
|
||||||
|
@ -399,12 +395,6 @@ public:
|
||||||
macro_iterator macro_begin(bool IncludeExternalMacros = true) const;
|
macro_iterator macro_begin(bool IncludeExternalMacros = true) const;
|
||||||
macro_iterator macro_end(bool IncludeExternalMacros = true) const;
|
macro_iterator macro_end(bool IncludeExternalMacros = true) const;
|
||||||
|
|
||||||
/// \brief Expansion source location for the last macro that expanded
|
|
||||||
/// to no tokens.
|
|
||||||
SourceLocation getLastEmptyMacroExpansionLoc() const {
|
|
||||||
return LastEmptyMacroExpansionLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &getPredefines() const { return Predefines; }
|
const std::string &getPredefines() const { return Predefines; }
|
||||||
/// setPredefines - Set the predefines for this Preprocessor. These
|
/// setPredefines - Set the predefines for this Preprocessor. These
|
||||||
/// predefines are automatically injected when parsing the main file.
|
/// predefines are automatically injected when parsing the main file.
|
||||||
|
|
|
@ -2022,7 +2022,7 @@ public:
|
||||||
StmtResult ActOnExprStmt(FullExprArg Expr);
|
StmtResult ActOnExprStmt(FullExprArg Expr);
|
||||||
|
|
||||||
StmtResult ActOnNullStmt(SourceLocation SemiLoc,
|
StmtResult ActOnNullStmt(SourceLocation SemiLoc,
|
||||||
SourceLocation LeadingEmptyMacroLoc = SourceLocation());
|
bool HasLeadingEmptyMacro = false);
|
||||||
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
|
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
|
||||||
MultiStmtArg Elts,
|
MultiStmtArg Elts,
|
||||||
bool isStmtExpr);
|
bool isStmtExpr);
|
||||||
|
|
|
@ -257,7 +257,6 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
|
||||||
if (HadLeadingSpace) Identifier.setFlag(Token::LeadingSpace);
|
if (HadLeadingSpace) Identifier.setFlag(Token::LeadingSpace);
|
||||||
}
|
}
|
||||||
Identifier.setFlag(Token::LeadingEmptyMacro);
|
Identifier.setFlag(Token::LeadingEmptyMacro);
|
||||||
LastEmptyMacroExpansionLoc = ExpandLoc;
|
|
||||||
++NumFastMacroExpanded;
|
++NumFastMacroExpanded;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -224,10 +224,8 @@ Retry:
|
||||||
case tok::l_brace: // C99 6.8.2: compound-statement
|
case tok::l_brace: // C99 6.8.2: compound-statement
|
||||||
return ParseCompoundStatement(attrs);
|
return ParseCompoundStatement(attrs);
|
||||||
case tok::semi: { // C99 6.8.3p3: expression[opt] ';'
|
case tok::semi: { // C99 6.8.3p3: expression[opt] ';'
|
||||||
SourceLocation LeadingEmptyMacroLoc;
|
bool HasLeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
|
||||||
if (Tok.hasLeadingEmptyMacro())
|
return Actions.ActOnNullStmt(ConsumeToken(), HasLeadingEmptyMacro);
|
||||||
LeadingEmptyMacroLoc = PP.getLastEmptyMacroExpansionLoc();
|
|
||||||
return Actions.ActOnNullStmt(ConsumeToken(), LeadingEmptyMacroLoc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case tok::kw_if: // C99 6.8.4.1: if-statement
|
case tok::kw_if: // C99 6.8.4.1: if-statement
|
||||||
|
|
|
@ -47,8 +47,8 @@ StmtResult Sema::ActOnExprStmt(FullExprArg expr) {
|
||||||
|
|
||||||
|
|
||||||
StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc,
|
StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc,
|
||||||
SourceLocation LeadingEmptyMacroLoc) {
|
bool HasLeadingEmptyMacro) {
|
||||||
return Owned(new (Context) NullStmt(SemiLoc, LeadingEmptyMacroLoc));
|
return Owned(new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro));
|
||||||
}
|
}
|
||||||
|
|
||||||
StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
|
StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
|
||||||
|
|
|
@ -109,7 +109,7 @@ void ASTStmtReader::VisitStmt(Stmt *S) {
|
||||||
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
|
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
|
||||||
VisitStmt(S);
|
VisitStmt(S);
|
||||||
S->setSemiLoc(ReadSourceLocation(Record, Idx));
|
S->setSemiLoc(ReadSourceLocation(Record, Idx));
|
||||||
S->LeadingEmptyMacro = ReadSourceLocation(Record, Idx);
|
S->HasLeadingEmptyMacro = Record[Idx++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
|
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ void ASTStmtWriter::VisitStmt(Stmt *S) {
|
||||||
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
|
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
|
||||||
VisitStmt(S);
|
VisitStmt(S);
|
||||||
Writer.AddSourceLocation(S->getSemiLoc(), Record);
|
Writer.AddSourceLocation(S->getSemiLoc(), Record);
|
||||||
Writer.AddSourceLocation(S->LeadingEmptyMacro, Record);
|
Record.push_back(S->HasLeadingEmptyMacro);
|
||||||
Code = serialization::STMT_NULL;
|
Code = serialization::STMT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue