summaryrefslogtreecommitdiffstats
path: root/clang/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
commitd5c1c9d0aee99246a68fd48131f97245efc0c104 (patch)
tree07685be314ee8e5694570224425ba79f6f331cdd /clang/lib/Parse/RAIIObjectsForParser.h
parent633c6f6f368634648318c4da6e1a123be3d46690 (diff)
downloadbcm5719-llvm-d5c1c9d0aee99246a68fd48131f97245efc0c104.tar.gz
bcm5719-llvm-d5c1c9d0aee99246a68fd48131f97245efc0c104.zip
refactor the 'ColonIsSacred' argument to ParseOptionalCXXScopeSpecifier
to be a bool in Parser that is twiddled by the ColonProtectionRAIIObject class. No functionality change. llvm-svn: 91014
Diffstat (limited to 'clang/lib/Parse/RAIIObjectsForParser.h')
-rw-r--r--clang/lib/Parse/RAIIObjectsForParser.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Parse/RAIIObjectsForParser.h b/clang/lib/Parse/RAIIObjectsForParser.h
index d642da58d50..d18d2f80263 100644
--- a/clang/lib/Parse/RAIIObjectsForParser.h
+++ b/clang/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
OpenPOWER on IntegriCloud