<br><br><div class="gmail_quote">On Sat, Sep 29, 2012 at 1:40 PM, Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: gribozavr<br>
Date: Sat Sep 29 06:40:46 2012<br>
New Revision: 164892<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=164892&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=164892&view=rev</a><br>
Log:<br>
Move the 'find macro by spelling' infrastructure to the Preprocessor class and<br>
use it to suggest appropriate macro for __attribute__((deprecated)) in<br>
-Wdocumentation-deprecated-sync.<br>...<br>Modified: cfe/trunk/include/clang/Lex/Preprocessor.h<br>...</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+  /// \brief Return the name of the macro defined before \p Loc that has<br>

+  /// spelling \p Tokens.  If there are multiple macros with same spelling,<br>
+  /// return the last one defined.<br>
+  StringRef getLastMacroWithSpelling(SourceLocation Loc,<br>
+                                     ArrayRef<TokenValue> Tokens) const;<br></blockquote><div><br></div><div>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?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
...</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-          std::string AnnotationSpelling = GetSuitableSpelling(<br>
-              PP, L, Tokens, "[[clang::fallthrough]]");<br>
+          StringRef AnnotationSpelling = "[[clang::fallthrough]]";<br>
+          StringRef MacroName = PP.getLastMacroWithSpelling(L, Tokens);<br>
+          if (!MacroName.empty())<br>
+            AnnotationSpelling = MacroName;<br></blockquote><div><font face="courier new, monospace">StringRef AnnotationSpelling = PP.getLastMacroWithSpelling(L, Tokens,</font></div><div><font face="courier new, monospace">    "[[clang::fallthrough]]");</font></div>
<div>(if you add the DefaultSpelling argument) seems better to me.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+          SmallString<64> TextToInsert(AnnotationSpelling);<br>

+          TextToInsert += "; ";<br></blockquote><div><br></div><div>Over-optimization? ;)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

           S.Diag(L, diag::note_insert_fallthrough_fixit) <<<br>
               AnnotationSpelling <<<br>
-              FixItHint::CreateInsertion(L, AnnotationSpelling + "; ");<br>
+              FixItHint::CreateInsertion(L, TextToInsert);<br>
         }<br>
       }<br>
       S.Diag(L, diag::note_insert_break_fixit) <<<br>
<br></blockquote></div><div><br></div>-- <br>
<div>Regards,</div><div>Alex</div>