]> granicus.if.org Git - clang/commitdiff
[tablegen] Check that an optional IdentifierArgument of an attribute is
authorAkira Hatanaka <ahatanaka@apple.com>
Sat, 10 Sep 2016 03:29:43 +0000 (03:29 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Sat, 10 Sep 2016 03:29:43 +0000 (03:29 +0000)
provided before trying to print it.

This fixes a segfault that occurs when function printPretty generated by
tablegen tries to print an optional argument of attribute
objc_bridge_related.

rdar://problem/28155469

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281132 91177308-0d34-0410-b5e6-96231b3b80d8

test/Misc/ast-print-objectivec.m
utils/TableGen/ClangAttrEmitter.cpp

index 6293b43f55e423b9b2858996dcf5301cc0b79e4d..e419237bbbac375f2947e9876145c44b8c5fabb8 100644 (file)
@@ -39,3 +39,9 @@
 // CHECK: }
 
 // CHECK: @end
+
+@class C1;
+struct __attribute__((objc_bridge_related(C1,,))) S1;
+
+// CHECK: @class C1;
+// CHECK: struct __attribute__((objc_bridge_related(C1, , ))) S1;
index 7f5769cbd0de56de65c0a52f8990754c461d06c9..4cdc5602a7508d5d5deae8898b7a51ed9291b0ab 100644 (file)
@@ -299,7 +299,13 @@ namespace {
         OS << "\" << get" << getUpperName()
            << "()->getNameInfo().getAsString() << \"";
       } else if (type == "IdentifierInfo *") {
-        OS << "\" << get" << getUpperName() << "()->getName() << \"";
+        OS << "\";\n";
+        if (isOptional())
+          OS << "    if (get" << getUpperName() << "()) ";
+        else
+          OS << "    ";
+        OS << "OS << get" << getUpperName() << "()->getName();\n";
+        OS << "    OS << \"";
       } else if (type == "TypeSourceInfo *") {
         OS << "\" << get" << getUpperName() << "().getAsString() << \"";
       } else {