================
Comment at: tools/clang/lib/Lex/MacroInfo.cpp:64
@@ +63,3 @@
+  for (const MacroInfo *MI = this; MI; MI = MI->PreviousDefinition) {
+    if (!SM.getFileEntryForID(SM.getFileID(MI->Location)) ||
+        SM.isBeforeInTranslationUnit(MI->Location, L))
----------------
Under what circumstances is this test necessary?

================
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() ||
----------------
Alexander Kornienko wrote:
> 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.
Yes, that's the right test.

================
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)
----------------
Alexander Kornienko wrote:
> 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?
I would recommend that you pass in a list of token values to look for, where a 
token value is a TokenKind and (for a tok_identifier) an IdentifierInfo*, 
rather than passing in a const char* and comparing it against the macro's 
spelling. That would be faster, and would also catch cases where an alternate 
spelling was used for the '[' or ']' tokens.


http://llvm-reviews.chandlerc.com/D50
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to