On Sat, Sep 29, 2012 at 1:40 PM, Dmitri Gribenko <[email protected]>wrote:

> Author: gribozavr
> Date: Sat Sep 29 06:40:46 2012
> New Revision: 164892
>
> URL: http://llvm.org/viewvc/llvm-project?rev=164892&view=rev
> Log:
> Move the 'find macro by spelling' infrastructure to the Preprocessor class
> and
> use it to suggest appropriate macro for __attribute__((deprecated)) in
> -Wdocumentation-deprecated-sync.
> ...
> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
> ...

+  /// \brief Return the name of the macro defined before \p Loc that has
> +  /// spelling \p Tokens.  If there are multiple macros with same
> spelling,
> +  /// return the last one defined.
> +  StringRef getLastMacroWithSpelling(SourceLocation Loc,
> +                                     ArrayRef<TokenValue> Tokens) const;
>

Isn't it more convenient to have a default spelling as a parameter of this
method so that callers don't have to check if the result is empty?


> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

...

-          std::string AnnotationSpelling = GetSuitableSpelling(
> -              PP, L, Tokens, "[[clang::fallthrough]]");
> +          StringRef AnnotationSpelling = "[[clang::fallthrough]]";
> +          StringRef MacroName = PP.getLastMacroWithSpelling(L, Tokens);
> +          if (!MacroName.empty())
> +            AnnotationSpelling = MacroName;
>
StringRef AnnotationSpelling = PP.getLastMacroWithSpelling(L, Tokens,
    "[[clang::fallthrough]]");
(if you add the DefaultSpelling argument) seems better to me.


> +          SmallString<64> TextToInsert(AnnotationSpelling);
> +          TextToInsert += "; ";
>

Over-optimization? ;)


>            S.Diag(L, diag::note_insert_fallthrough_fixit) <<
>                AnnotationSpelling <<
> -              FixItHint::CreateInsertion(L, AnnotationSpelling + "; ");
> +              FixItHint::CreateInsertion(L, TextToInsert);
>          }
>        }
>        S.Diag(L, diag::note_insert_break_fixit) <<
>
>
-- 
Regards,
Alex
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to