Author: leonardchan
Date: Sun May 12 14:50:01 2019
New Revision: 360544

URL: http://llvm.org/viewvc/llvm-project?rev=360544&view=rev
Log:
Fix for P41852 where builtin attributes were being caught by 
FindLocsWithCommonFileID().

Added:
    cfe/trunk/test/Driver/mingw-macro-qualified-type.c
Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=360544&r1=360543&r2=360544&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun May 12 14:50:01 2019
@@ -224,8 +224,9 @@ void Parser::ParseGNUAttributes(ParsedAt
 
     // If this was declared in a macro, attach the macro IdentifierInfo to the
     // parsed attribute.
-    if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
-      auto &SM = PP.getSourceManager();
+    auto &SM = PP.getSourceManager();
+    if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) &&
+        FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) {
       CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc);
       StringRef FoundName =
           Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts());

Added: cfe/trunk/test/Driver/mingw-macro-qualified-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-macro-qualified-type.c?rev=360544&view=auto
==============================================================================
--- cfe/trunk/test/Driver/mingw-macro-qualified-type.c (added)
+++ cfe/trunk/test/Driver/mingw-macro-qualified-type.c Sun May 12 14:50:01 2019
@@ -0,0 +1,12 @@
+// Ensure that builtin attributes do not get treated as user defined macros to
+// be weapped in macro qualified types. This addresses P41852.
+//
+// RUN: %clang -c %s -target i686-w64-mingw32
+
+typedef int WINBOOL;
+typedef unsigned int UINT_PTR, *PUINT_PTR;
+typedef unsigned long long ULONG64, *PULONG64;
+#define WINAPI __stdcall
+#define CALLBACK __stdcall
+
+typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, 
ULONG64 data, ULONG64 context);


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to