[cfe-commits] r170616 - in /cfe/trunk: lib/Lex/TokenLexer.cpp test/Preprocessor/macro_arg_slocentry_merge.c test/Preprocessor/macro_arg_slocentry_merge.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Dec 19 15:55:44 PST 2012


Author: akirtzidis
Date: Wed Dec 19 17:55:44 2012
New Revision: 170616

URL: http://llvm.org/viewvc/llvm-project?rev=170616&view=rev
Log:
[preprocessor] When "merging" macro argument tokens into one SLocEntry chunk,
make sure they came from the same kind of FileIDs.

Thanks to Abramo Bagnara for providing the test case.

Added:
    cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.c
    cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.h
Modified:
    cfe/trunk/lib/Lex/TokenLexer.cpp

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=170616&r1=170615&r2=170616&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Wed Dec 19 17:55:44 2012
@@ -749,14 +749,18 @@
 
   Token *NextTok = begin_tokens + 1;
   for (; NextTok < end_tokens; ++NextTok) {
+    SourceLocation NextLoc = NextTok->getLocation();
+    if (CurLoc.isFileID() != NextLoc.isFileID())
+      break; // Token from different kind of FileID.
+
     int RelOffs;
-    if (!SM.isInSameSLocAddrSpace(CurLoc, NextTok->getLocation(), &RelOffs))
+    if (!SM.isInSameSLocAddrSpace(CurLoc, NextLoc, &RelOffs))
       break; // Token from different local/loaded location.
     // Check that token is not before the previous token or more than 50
     // "characters" away.
     if (RelOffs < 0 || RelOffs > 50)
       break;
-    CurLoc = NextTok->getLocation();
+    CurLoc = NextLoc;
   }
 
   // For the consecutive tokens, find the length of the SLocEntry to contain

Added: cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.c?rev=170616&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.c (added)
+++ cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.c Wed Dec 19 17:55:44 2012
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+#include "macro_arg_slocentry_merge.h"
+
+// CHECK: macro_arg_slocentry_merge.h:7:19: error: unknown type name 'win'
+// CHECK: macro_arg_slocentry_merge.h:5:16: note: expanded from macro 'WINDOW'
+// CHECK: macro_arg_slocentry_merge.h:6:18: note: expanded from macro 'P_'

Added: cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.h?rev=170616&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.h (added)
+++ cfe/trunk/test/Preprocessor/macro_arg_slocentry_merge.h Wed Dec 19 17:55:44 2012
@@ -0,0 +1,7 @@
+
+
+
+
+#define WINDOW win
+#define P_(args) args
+extern void f P_((WINDOW win));





More information about the cfe-commits mailing list