]> granicus.if.org Git - clang/commitdiff
Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 1 Sep 2011 21:53:45 +0000 (21:53 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 1 Sep 2011 21:53:45 +0000 (21:53 +0000)
in the face of buffering C++/ObjC method bodies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138972 91177308-0d34-0410-b5e6-96231b3b80d8

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

index e67f1f2a289fecf51b6cfdc223688fd5fe9bf106..0e696a9781296882ad132bf903c5565f4e99b64f 100644 (file)
@@ -406,25 +406,25 @@ public:
 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); }
 
index c9e45d0c97e72966799afe0cc7a6bbaebb848ecf..7044e34cd34a5105748fa850cab5b397123f875e 100644 (file)
@@ -227,10 +227,6 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
   /// 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 @@ public:
   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.
index b5dec1193a8a50b0e7cda5218903609f27b7b785..814fd27469d4135caf474595b4f9c7725a3edf08 100644 (file)
@@ -2022,7 +2022,7 @@ public:
   StmtResult ActOnExprStmt(FullExprArg Expr);
 
   StmtResult ActOnNullStmt(SourceLocation SemiLoc,
-                        SourceLocation LeadingEmptyMacroLoc = SourceLocation());
+                           bool HasLeadingEmptyMacro = false);
   StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
                                        MultiStmtArg Elts,
                                        bool isStmtExpr);
index 5e498f837c55ae34040bfd532e40c94f6ab93cf4..96b729af1aae29635d6c4f487205622fc4a57a1f 100644 (file)
@@ -257,7 +257,6 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
       if (HadLeadingSpace) Identifier.setFlag(Token::LeadingSpace);
     }
     Identifier.setFlag(Token::LeadingEmptyMacro);
-    LastEmptyMacroExpansionLoc = ExpandLoc;
     ++NumFastMacroExpanded;
     return false;
 
index d57e52799039005ed02c67ce393a7657c54bbc98..df768c9a0655ff0ee9b66daf391543fd70dcbcb3 100644 (file)
@@ -224,10 +224,8 @@ Retry:
   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
index e17188757b5b61825cf7cb78bc38d35b7cdbd126..d03a6ac1680796a4683a37de249cb8257f52d71b 100644 (file)
@@ -47,8 +47,8 @@ StmtResult Sema::ActOnExprStmt(FullExprArg expr) {
 
 
 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,
index cfe46d75b1eb8337a4fe2386636263792ca0b2f0..a402ad05a09492ea950b310e4f095dc3d6154789 100644 (file)
@@ -109,7 +109,7 @@ void ASTStmtReader::VisitStmt(Stmt *S) {
 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) {
index f0636a1aa1cd0baa3da960a9c7e679a867211da6..8f68b12aacc14a49a301ca440b005f026325d3d5 100644 (file)
@@ -59,7 +59,7 @@ void ASTStmtWriter::VisitStmt(Stmt *S) {
 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;
 }