summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-22 20:57:11 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-22 20:57:11 +0000
commit0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c (patch)
treefdae8a15a6b8ae4c84458c65df95cd3cc651270c /clang/lib/Sema/Sema.h
parent8cbbc7944d30c38c2f8e235ebbcfb3fba9427f6a (diff)
downloadbcm5719-llvm-0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c.tar.gz
bcm5719-llvm-0b6a6242ede6620b90c8b1d5db1c85e5cb29d91c.zip
Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the "potentially evaluated" state at all of the necessary places within Sema and Parser. Other changes: - Set the unevaluated/potentially-evaluated context appropriately during template instantiation. - We now recognize three different states while parsing or instantiating expressions: unevaluated, potentially evaluated, and potentially potentially evaluated (for C++'s typeid). - When we're in a potentially potentially-evaluated context, queue up MarkDeclarationReferenced calls in a stack. For C++ typeid expressions that are potentially evaluated, we will play back these MarkDeclarationReferenced calls when we exit the corresponding potentially potentially-evaluated context. - Non-type template arguments are now parsed as constant expressions, so they are not potentially-evaluated. llvm-svn: 73899
Diffstat (limited to 'clang/lib/Sema/Sema.h')
-rw-r--r--clang/lib/Sema/Sema.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 560f952bffa..28f81e614a3 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -29,6 +29,7 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/OwningPtr.h"
+#include <list>
#include <string>
#include <vector>
@@ -247,11 +248,18 @@ public:
/// have been declared.
bool GlobalNewDeleteDeclared;
- /// A flag that indicates when we are processing an unevaluated operand
- /// (C++0x [expr]). C99 has the same notion of declarations being
- /// "used" and C++03 has the notion of "potentially evaluated", but we
- /// adopt the C++0x terminology since it is most precise.
- bool InUnevaluatedOperand;
+ /// The current expression evaluation context.
+ ExpressionEvaluationContext ExprEvalContext;
+
+ typedef std::vector<std::pair<SourceLocation, Decl *> >
+ PotentiallyReferencedDecls;
+
+ /// A stack of declarations, each element of which is a set of declarations
+ /// that will be marked as referenced if the corresponding potentially
+ /// potentially evaluated expression is potentially evaluated. Each element
+ /// in the stack corresponds to a PotentiallyPotentiallyEvaluated expression
+ /// evaluation context.
+ std::list<PotentiallyReferencedDecls> PotentiallyReferencedDeclStack;
/// \brief Whether the code handled by Sema should be considered a
/// complete translation unit or not.
@@ -1334,12 +1342,13 @@ public:
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
Expr **Args, unsigned NumArgs);
- virtual bool setUnevaluatedOperand(bool UnevaluatedOperand) {
- bool Result = InUnevaluatedOperand;
- InUnevaluatedOperand = UnevaluatedOperand;
- return Result;
- }
-
+ virtual ExpressionEvaluationContext
+ PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
+
+ virtual void
+ PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
+ ExpressionEvaluationContext NewContext);
+
void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
// Primary Expressions.
OpenPOWER on IntegriCloud