[cfe-commits] [PATCH] Implementation quantity limits to prevent crashes

Aaron Ballman aaron at aaronballman.com
Sat Oct 8 15:04:08 PDT 2011


On Fri, Oct 7, 2011 at 9:33 AM, Douglas Gregor <dgregor at apple.com> wrote:
> A few comments below.
>
> +  class DelimiterTracker {
> +  private:
> +    friend class Parser;
> +
> +    unsigned P, B, S, L, LLL, T;
>
> Some more-descriptive variable names would be useful here :)

Heh, sorry about that.  They've been improved.  ;-)

> +    BalancedDelimiterTracker(Parser& p, tok::TokenKind k);
> +    ~BalancedDelimiterTracker();
> +
> +    bool consumeOpen(SourceLocation *open) const;
> +    bool expectAndConsume(SourceLocation *open,
> +                           unsigned DiagID,
> +                           const char *Msg = "",
> +                           tok::TokenKind SkipToTok = tok::unknown) const;
> +    bool consumeClose(const SourceLocation& open, SourceLocation *close) const;
> +  };
>
> I'd prefer that we keep the open/close source locations within BalancedDelimiterTracker, which would simplify the interface a bit, since *every* user of BalancedDelimiterTracker needs to track this information anyway.

I've implemented this change as well -- it was a good point, and it
does make things cleaner.  I had to update the signature for
ParseInnerNamespace though, since that was the one use case that
needed the opening brace to be passed in manually.

I've attached the updated patch -- hopefully for the last time,
because keeping this patch up to date is a bit painful due to how
frequently the parser changes.  :-)

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ParserLimits3.diff
Type: application/octet-stream
Size: 96416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111008/ef6ee81f/attachment.obj>


More information about the cfe-commits mailing list