r231251 - [Modules] Fix crash in Preprocessor::getLastMacroWithSpelling().

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Mar 4 08:03:07 PST 2015


Author: akirtzidis
Date: Wed Mar  4 10:03:07 2015
New Revision: 231251

URL: http://llvm.org/viewvc/llvm-project?rev=231251&view=rev
Log:
[Modules] Fix crash in Preprocessor::getLastMacroWithSpelling().

Macro names that got undefined inside a module may not have their MacroInfo set.

Added:
    cfe/trunk/test/Modules/crashes.m
Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp
    cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=231251&r1=231250&r2=231251&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Mar  4 10:03:07 2015
@@ -321,11 +321,11 @@ StringRef Preprocessor::getLastMacroWith
   StringRef BestSpelling;
   for (Preprocessor::macro_iterator I = macro_begin(), E = macro_end();
        I != E; ++I) {
-    if (!I->second->getMacroInfo()->isObjectLike())
-      continue;
     const MacroDirective::DefInfo
       Def = I->second->findDirectiveAtLoc(Loc, SourceMgr);
-    if (!Def)
+    if (!Def || !Def.getMacroInfo())
+      continue;
+    if (!Def.getMacroInfo()->isObjectLike())
       continue;
     if (!MacroDefinitionEquals(Def.getMacroInfo(), Tokens))
       continue;

Modified: cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h?rev=231251&r1=231250&r2=231251&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h (original)
+++ cfe/trunk/test/Modules/Inputs/Module.framework/Headers/Module.h Wed Mar  4 10:03:07 2015
@@ -31,4 +31,7 @@ typedef	struct __sFILE {
 
 extern FILE *myFile;
 
+#define SOME_MACRO_GETTING_UNDEFINED 1
+#undef SOME_MACRO_GETTING_UNDEFINED
+
 #endif // MODULE_H

Added: cfe/trunk/test/Modules/crashes.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crashes.m?rev=231251&view=auto
==============================================================================
--- cfe/trunk/test/Modules/crashes.m (added)
+++ cfe/trunk/test/Modules/crashes.m Wed Mar  4 10:03:07 2015
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules-cache-path=%t.mcp -fmodules -F %S/Inputs -fobjc-arc %s -verify
+
+ at import Module;
+
+__attribute__((objc_root_class))
+ at interface Test
+// rdar://19904648
+ at property (assign) id newFile; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}} \
+                               // expected-note {{explicitly declare getter}}
+ at end
+
+ at implementation Test
+ at end





More information about the cfe-commits mailing list