[cfe-commits] r77253 - in /cfe/trunk: lib/AST/DeclPrinter.cpp lib/Sema/SemaDecl.cpp test/Sema/return.c
Mike Stump
mrs at apple.com
Mon Jul 27 14:33:40 PDT 2009
Author: mrs
Date: Mon Jul 27 16:33:40 2009
New Revision: 77253
URL: http://llvm.org/viewvc/llvm-project?rev=77253&view=rev
Log:
Add builtin knowledge about longjmp being noreturn. Add printing for
the noreturn attribute.
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/return.c
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=77253&r1=77252&r2=77253&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Jul 27 16:33:40 2009
@@ -335,6 +335,8 @@
}
Proto += ")";
+ if (D->hasAttr<NoReturnAttr>())
+ Proto += " __attribute((noreturn))";
if (CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D)) {
if (CDecl->getNumBaseOrMemberInitializers() > 0) {
Proto += " : ";
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=77253&r1=77252&r2=77253&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 27 16:33:40 2009
@@ -3705,7 +3705,9 @@
if (!FD->getAttr<FormatAttr>())
FD->addAttr(::new (Context) FormatAttr("printf", 2,
Name->isStr("vasprintf") ? 0 : 3));
- }
+ } else if (Name->isStr("longjmp") &&
+ !FD->hasAttr<NoReturnAttr>())
+ FD->addAttr(::new (Context) NoReturnAttr());
}
TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T) {
Modified: cfe/trunk/test/Sema/return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/return.c?rev=77253&r1=77252&r2=77253&view=diff
==============================================================================
--- cfe/trunk/test/Sema/return.c (original)
+++ cfe/trunk/test/Sema/return.c Mon Jul 27 16:33:40 2009
@@ -196,3 +196,9 @@
int test29() {
exit(1);
}
+
+#include <setjmp.h>
+jmp_buf test30_j;
+int test30() {
+ longjmp(test30_j, 1);
+}
More information about the cfe-commits
mailing list