[cfe-commits] [PATCH] Compatibility macro detection for the -Wimplicit-fallthrough diagnostic.

Alexander Kornienko reviews at llvm-reviews.chandlerc.com
Wed Sep 26 08:28:47 PDT 2012



================
Comment at: tools/clang/lib/Lex/MacroInfo.cpp:65
@@ +64,3 @@
+    if (!SM.getFileEntryForID(SM.getFileID(MI->Location)) ||
+        SM.isBeforeInTranslationUnit(MI->Location, L))
+      return (MI->UndefLocation.isInvalid() ||
----------------
Can anyone confirm, that this is the right method to find out if the macro was defined before a specific source location?
I've tried SM.isBeforeInSLocAddrSpace(), but it seemed to be wrong.

================
Comment at: tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:687
@@ +686,3 @@
+       it != MI->tokens_end(); ++it) {
+    StringRef S = PP.getSpelling(*it, Buf);
+    if (StringRef(P, S.size()) != S)
----------------
If this seems to be not efficient, does anyone have an idea of how to conveniently create a Token array for a known character sequence (run Lexer? fill by hand? both ways seem to be too verbose).
And after that, how to compare two token sequences? Manually compare getKind() and for certain kinds getIdentifierInfo(), getLiteralData(), getAnnotationValue() and some flags?


http://llvm-reviews.chandlerc.com/D50



More information about the cfe-commits mailing list