aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/AST/Stmt.h33
-rw-r--r--include/clang/Lex/Preprocessor.h17
-rw-r--r--include/clang/Lex/Token.h11
-rw-r--r--include/clang/Parse/Parser.h3
-rw-r--r--include/clang/Sema/Sema.h5
5 files changed, 29 insertions, 40 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 8726bfb417..1318532653 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -360,8 +360,16 @@ public:
///
class NullStmt : public Stmt {
SourceLocation SemiLoc;
+
+ /// \brief Whether the null statement was preceded by an empty macro, e.g:
+ /// @code
+ /// #define CALL(x)
+ /// CALL(0);
+ /// @endcode
+ bool LeadingEmptyMacro;
public:
- NullStmt(SourceLocation L) : Stmt(NullStmtClass), SemiLoc(L) {}
+ NullStmt(SourceLocation L, bool LeadingEmptyMacro = false)
+ : Stmt(NullStmtClass), SemiLoc(L), LeadingEmptyMacro(LeadingEmptyMacro) {}
/// \brief Build an empty null statement.
explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) { }
@@ -369,6 +377,8 @@ public:
SourceLocation getSemiLoc() const { return SemiLoc; }
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
+ bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro; }
+
virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
static bool classof(const Stmt *T) {
@@ -379,6 +389,9 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+ friend class ASTStmtReader;
+ friend class ASTStmtWriter;
};
/// CompoundStmt - This represents a group of statements like { stmt stmt }.
@@ -651,19 +664,10 @@ class IfStmt : public Stmt {
SourceLocation IfLoc;
SourceLocation ElseLoc;
-
- /// \brief True if we have code like:
- /// @code
- /// #define CALL(x)
- /// if (condition)
- /// CALL(0);
- /// @endcode
- bool MacroExpandedInThenStmt;
-
+
public:
IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
- Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0,
- bool macroExpandedInThenStmt = false);
+ Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0);
/// \brief Build an empty if/then/else statement
explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
@@ -695,8 +699,6 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; }
- bool hasMacroExpandedInThenStmt() const { return MacroExpandedInThenStmt; }
-
virtual SourceRange getSourceRange() const {
if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
@@ -713,9 +715,6 @@ public:
// over the initialization expression referenced by the condition variable.
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
- friend class ASTStmtReader;
- friend class ASTStmtWriter;
};
/// SwitchStmt - This represents a 'switch' stmt.
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 2194d6fe62..261daed75b 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -47,7 +47,6 @@ class PPCallbacks;
class CodeCompletionHandler;
class DirectoryLookup;
class PreprocessingRecord;
-class PPMacroExpansionTrap;
/// Preprocessor - This object engages in a tight little dance with the lexer to
/// efficiently preprocess tokens. Lexers know only about tokens within a
@@ -111,11 +110,6 @@ class Preprocessor {
/// DisableMacroExpansion - True if macro expansion is disabled.
bool DisableMacroExpansion : 1;
- /// \brief This is set to true when a macro is expanded.
- /// Used by PPMacroExpansionTrap.
- bool MacroExpansionFlag : 1;
- friend class PPMacroExpansionTrap;
-
/// \brief Whether we have already loaded macros from the external source.
mutable bool ReadMacrosFromExternalSource : 1;
@@ -1035,17 +1029,6 @@ public:
virtual bool HandleComment(Preprocessor &PP, SourceRange Comment) = 0;
};
-/// \brief RAII class that determines when any macro expansion has occurred
-/// between the time the instance was created and the time it was
-/// queried.
-class PPMacroExpansionTrap {
- Preprocessor &PP;
-public:
- PPMacroExpansionTrap(Preprocessor &PP) : PP(PP) { reset(); }
- bool hasMacroExpansionOccured() const { return PP.MacroExpansionFlag; }
- void reset() { PP.MacroExpansionFlag = false; }
-};
-
} // end namespace clang
#endif
diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h
index 954b36ec6d..2a19083906 100644
--- a/include/clang/Lex/Token.h
+++ b/include/clang/Lex/Token.h
@@ -76,7 +76,8 @@ public:
StartOfLine = 0x01, // At start of line or only after whitespace.
LeadingSpace = 0x02, // Whitespace exists before this token.
DisableExpand = 0x04, // This identifier may never be macro expanded.
- NeedsCleaning = 0x08 // Contained an escaped newline or trigraph.
+ NeedsCleaning = 0x08, // Contained an escaped newline or trigraph.
+ LeadingEmptyMacro = 0x10 // Empty macro exists before this token.
};
tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }
@@ -231,7 +232,13 @@ public:
/// newlines in it.
///
bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
-
+
+ /// \brief Return true if this token has an empty macro before it.
+ ///
+ bool hasLeadingEmptyMacro() const {
+ return (Flags & LeadingEmptyMacro) ? true : false;
+ }
+
};
/// PPConditionalInfo - Information about the conditional stack (#if directives)
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index 325b47d1cc..e94225813e 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -1199,8 +1199,7 @@ private:
bool ParseParenExprOrCondition(ExprResult &ExprResult,
Decl *&DeclResult,
SourceLocation Loc,
- bool ConvertToBoolean,
- bool *MacroExpandedAfterRParen = 0);
+ bool ConvertToBoolean);
StmtResult ParseIfStatement(AttributeList *Attr);
StmtResult ParseSwitchStatement(AttributeList *Attr);
StmtResult ParseWhileStatement(AttributeList *Attr);
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 2f220dbb67..9c36ce0347 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -1566,7 +1566,8 @@ public:
StmtResult ActOnExprStmt(FullExprArg Expr);
- StmtResult ActOnNullStmt(SourceLocation SemiLoc);
+ StmtResult ActOnNullStmt(SourceLocation SemiLoc,
+ bool LeadingEmptyMacro = false);
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
MultiStmtArg Elts,
bool isStmtExpr);
@@ -1590,7 +1591,7 @@ public:
bool HasUnusedAttr);
StmtResult ActOnIfStmt(SourceLocation IfLoc,
FullExprArg CondVal, Decl *CondVar,
- Stmt *ThenVal, bool MacroExpandedInThenStmt,
+ Stmt *ThenVal,
SourceLocation ElseLoc, Stmt *ElseVal);
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
Expr *Cond,