summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-03-04 16:03:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-03-04 16:03:07 +0000
commit5c585253e5f66affee0ce1d3db18ea2cfdfcdd82 (patch)
tree21bd2bb236386eb8d64bc5e446312e2c5b412132 /clang
parentf14889ee3474354e81bf58fe1c4f87739f1f22b5 (diff)
downloadbcm5719-llvm-5c585253e5f66affee0ce1d3db18ea2cfdfcdd82.tar.gz
bcm5719-llvm-5c585253e5f66affee0ce1d3db18ea2cfdfcdd82.zip
[Modules] Fix crash in Preprocessor::getLastMacroWithSpelling().
Macro names that got undefined inside a module may not have their MacroInfo set. llvm-svn: 231251
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp6
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/Module.h3
-rw-r--r--clang/test/Modules/crashes.m14
3 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index b2a6d933a0f..51a038ac728 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -321,11 +321,11 @@ StringRef Preprocessor::getLastMacroWithSpelling(
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;
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
index 9a1c2b9bd87..55ce7a3e30f 100644
--- a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
@@ -31,4 +31,7 @@ typedef struct __sFILE {
extern FILE *myFile;
+#define SOME_MACRO_GETTING_UNDEFINED 1
+#undef SOME_MACRO_GETTING_UNDEFINED
+
#endif // MODULE_H
diff --git a/clang/test/Modules/crashes.m b/clang/test/Modules/crashes.m
new file mode 100644
index 00000000000..cfdd1b2a541
--- /dev/null
+++ b/clang/test/Modules/crashes.m
@@ -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
+
+@import Module;
+
+__attribute__((objc_root_class))
+@interface Test
+// rdar://19904648
+@property (assign) id newFile; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}} \
+ // expected-note {{explicitly declare getter}}
+@end
+
+@implementation Test
+@end
OpenPOWER on IntegriCloud