aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/RAIIObjectsForParser.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-10 00:32:41 +0000
committerChris Lattner <sabre@nondot.org>2009-12-10 00:32:41 +0000
commit08d92ecf6e5b1fd23177a08c2312b58d63d863db (patch)
tree705e478670c0fd24ee0becb72f71b3fd13971da0 /lib/Parse/RAIIObjectsForParser.h
parenteb4072ed06c884f1053047ad88846cbffd5ac62e (diff)
refactor the 'ColonIsSacred' argument to ParseOptionalCXXScopeSpecifier
to be a bool in Parser that is twiddled by the ColonProtectionRAIIObject class. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91014 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/RAIIObjectsForParser.h')
-rw-r--r--lib/Parse/RAIIObjectsForParser.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Parse/RAIIObjectsForParser.h b/lib/Parse/RAIIObjectsForParser.h
index d642da58d5..d18d2f8026 100644
--- a/lib/Parse/RAIIObjectsForParser.h
+++ b/lib/Parse/RAIIObjectsForParser.h
@@ -36,6 +36,25 @@ namespace clang {
Diags.DecrementAllExtensionsSilenced();
}
};
-}
+
+ // TODO: move GreaterThanIsOperatorScope here.
+
+ /// ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and
+ /// restores it when destroyed. This says that "foo:" should not be
+ /// considered a possible typo for "foo::" for error recovery purposes.
+ class ColonProtectionRAIIObject {
+ Parser &P;
+ bool OldVal;
+ public:
+ ColonProtectionRAIIObject(Parser &p) : P(p), OldVal(P.ColonIsSacred) {
+ P.ColonIsSacred = true;
+ }
+
+ ~ColonProtectionRAIIObject() {
+ P.ColonIsSacred = OldVal;
+ }
+ };
+
+} // end namespace clang
#endif