[cfe-commits] r163408 - /cfe/trunk/include/clang/Lex/Lexer.h

Chandler Carruth chandlerc at google.com
Fri Sep 7 13:15:36 PDT 2012


On Fri, Sep 7, 2012 at 3:43 PM, Abramo Bagnara
<abramo.bagnara at bugseng.com>wrote:

> Author: abramo
> Date: Fri Sep  7 14:43:13 2012
> New Revision: 163408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=163408&view=rev
> Log:
> Moved back getCharAndSizeNoWarn to public area.
>

If this is going to become a widely used public interface of the Lexer,
could you add some unittests to cover it so we have some reasonable way of
regression testing it and ensuring it isn't broken?

Most important to my eyes would be testing the no-warn property.


>
> Modified:
>     cfe/trunk/include/clang/Lex/Lexer.h
>
> Modified: cfe/trunk/include/clang/Lex/Lexer.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=163408&r1=163407&r2=163408&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Lex/Lexer.h (original)
> +++ cfe/trunk/include/clang/Lex/Lexer.h Fri Sep  7 14:43:13 2012
> @@ -409,6 +409,21 @@
>    /// \brief Returns true if the given character could appear in an
> identifier.
>    static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts);
>
> +  /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not
> ever
> +  /// emit a warning.
> +  static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size,
> +                                          const LangOptions &LangOpts) {
> +    // If this is not a trigraph and not a UCN or escaped newline, return
> +    // quickly.
> +    if (isObviouslySimpleCharacter(Ptr[0])) {
> +      Size = 1;
> +      return *Ptr;
> +    }
> +
> +    Size = 0;
> +    return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts);
> +  }
> +
>
>  //===--------------------------------------------------------------------===//
>    // Internal implementation interfaces.
>  private:
> @@ -514,21 +529,6 @@
>    /// method.
>    char getCharAndSizeSlow(const char *Ptr, unsigned &Size, Token *Tok =
> 0);
>
> -  /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not
> ever
> -  /// emit a warning.
> -  static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size,
> -                                          const LangOptions &LangOpts) {
> -    // If this is not a trigraph and not a UCN or escaped newline, return
> -    // quickly.
> -    if (isObviouslySimpleCharacter(Ptr[0])) {
> -      Size = 1;
> -      return *Ptr;
> -    }
> -
> -    Size = 0;
> -    return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts);
> -  }
> -
>    /// getEscapedNewLineSize - Return the size of the specified escaped
> newline,
>    /// or 0 if it is not an escaped newline. P[-1] is known to be a "\" on
> entry
>    /// to this function.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120907/4b314b83/attachment.html>


More information about the cfe-commits mailing list