summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/RAIIObjectsForParser.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-15 14:51:05 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-15 14:51:05 +0000
commite9bba4f1a44162eb6c02f96ebbd088333e5a45d5 (patch)
tree732440ed8868387a2d9e657a0892a5067c0cc928 /clang/lib/Parse/RAIIObjectsForParser.h
parentda25de8096fb71c45e3d93de779f9008b7071a50 (diff)
downloadbcm5719-llvm-e9bba4f1a44162eb6c02f96ebbd088333e5a45d5.tar.gz
bcm5719-llvm-e9bba4f1a44162eb6c02f96ebbd088333e5a45d5.zip
Implement bracket insertion for Objective-C instance message sends as
part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
Diffstat (limited to 'clang/lib/Parse/RAIIObjectsForParser.h')
-rw-r--r--clang/lib/Parse/RAIIObjectsForParser.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Parse/RAIIObjectsForParser.h b/clang/lib/Parse/RAIIObjectsForParser.h
index addc7950839..583f18428d6 100644
--- a/clang/lib/Parse/RAIIObjectsForParser.h
+++ b/clang/lib/Parse/RAIIObjectsForParser.h
@@ -80,6 +80,22 @@ namespace clang {
}
};
+ class InMessageExpressionRAIIObject {
+ bool &InMessageExpression;
+ bool OldValue;
+
+ public:
+ InMessageExpressionRAIIObject(Parser &P, bool Value)
+ : InMessageExpression(P.InMessageExpression),
+ OldValue(P.InMessageExpression) {
+ InMessageExpression = Value;
+ }
+
+ ~InMessageExpressionRAIIObject() {
+ InMessageExpression = OldValue;
+ }
+ };
+
/// \brief RAII object that makes sure paren/bracket/brace count is correct
/// after declaration/statement parsing, even when there's a parsing error.
class ParenBraceBracketBalancer {
OpenPOWER on IntegriCloud