[cfe-commits] r138972 - in /cfe/trunk: include/clang/AST/Stmt.h include/clang/Lex/Preprocessor.h include/clang/Sema/Sema.h lib/Lex/PPMacroExpansion.cpp lib/Parse/ParseStmt.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterStmt.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Sep 1 14:53:45 PDT 2011
Author: akirtzidis
Date: Thu Sep 1 16:53:45 2011
New Revision: 138972
URL: http://llvm.org/viewvc/llvm-project?rev=138972&view=rev
Log:
Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Sep 1 16:53:45 2011
@@ -406,25 +406,25 @@
class NullStmt : public Stmt {
SourceLocation SemiLoc;
- /// \brief If the null statement was preceded by an empty macro this is
- /// its instantiation source location, e.g:
+ /// \brief True if the null statement was preceded by an empty macro, e.g:
/// @code
/// #define CALL(x)
/// CALL(0);
/// @endcode
- SourceLocation LeadingEmptyMacro;
+ bool HasLeadingEmptyMacro;
public:
- NullStmt(SourceLocation L, SourceLocation LeadingEmptyMacro =SourceLocation())
- : Stmt(NullStmtClass), SemiLoc(L), LeadingEmptyMacro(LeadingEmptyMacro) {}
+ NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
+ : Stmt(NullStmtClass), SemiLoc(L),
+ HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
/// \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; }
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
- bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro.isValid(); }
- SourceLocation getLeadingEmptyMacroLoc() const { return LeadingEmptyMacro; }
+ bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Sep 1 16:53:45 2011
@@ -227,10 +227,6 @@
/// previous macro value.
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.
unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma;
unsigned NumIf, NumElse, NumEndif;
@@ -399,12 +395,6 @@
macro_iterator macro_begin(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; }
/// setPredefines - Set the predefines for this Preprocessor. These
/// predefines are automatically injected when parsing the main file.
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 1 16:53:45 2011
@@ -2022,7 +2022,7 @@
StmtResult ActOnExprStmt(FullExprArg Expr);
StmtResult ActOnNullStmt(SourceLocation SemiLoc,
- SourceLocation LeadingEmptyMacroLoc = SourceLocation());
+ bool HasLeadingEmptyMacro = false);
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
MultiStmtArg Elts,
bool isStmtExpr);
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Sep 1 16:53:45 2011
@@ -257,7 +257,6 @@
if (HadLeadingSpace) Identifier.setFlag(Token::LeadingSpace);
}
Identifier.setFlag(Token::LeadingEmptyMacro);
- LastEmptyMacroExpansionLoc = ExpandLoc;
++NumFastMacroExpanded;
return false;
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Sep 1 16:53:45 2011
@@ -224,10 +224,8 @@
case tok::l_brace: // C99 6.8.2: compound-statement
return ParseCompoundStatement(attrs);
case tok::semi: { // C99 6.8.3p3: expression[opt] ';'
- SourceLocation LeadingEmptyMacroLoc;
- if (Tok.hasLeadingEmptyMacro())
- LeadingEmptyMacroLoc = PP.getLastEmptyMacroExpansionLoc();
- return Actions.ActOnNullStmt(ConsumeToken(), LeadingEmptyMacroLoc);
+ bool HasLeadingEmptyMacro = Tok.hasLeadingEmptyMacro();
+ return Actions.ActOnNullStmt(ConsumeToken(), HasLeadingEmptyMacro);
}
case tok::kw_if: // C99 6.8.4.1: if-statement
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Sep 1 16:53:45 2011
@@ -47,8 +47,8 @@
StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc,
- SourceLocation LeadingEmptyMacroLoc) {
- return Owned(new (Context) NullStmt(SemiLoc, LeadingEmptyMacroLoc));
+ bool HasLeadingEmptyMacro) {
+ return Owned(new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro));
}
StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Sep 1 16:53:45 2011
@@ -109,7 +109,7 @@
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
S->setSemiLoc(ReadSourceLocation(Record, Idx));
- S->LeadingEmptyMacro = ReadSourceLocation(Record, Idx);
+ S->HasLeadingEmptyMacro = Record[Idx++];
}
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=138972&r1=138971&r2=138972&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Thu Sep 1 16:53:45 2011
@@ -59,7 +59,7 @@
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
Writer.AddSourceLocation(S->getSemiLoc(), Record);
- Writer.AddSourceLocation(S->LeadingEmptyMacro, Record);
+ Record.push_back(S->HasLeadingEmptyMacro);
Code = serialization::STMT_NULL;
}
More information about the cfe-commits
mailing list