diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-10 04:01:38 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-10 04:01:38 +0000 |
commit | f4799847628b511b96bfde868925966b57604fa3 (patch) | |
tree | 368e0588cf6e2789cc89d9feec3647db18e8b6ed /clang/lib/Sema/SemaDecl.cpp | |
parent | 9a8f2f7d583f0b25059376644286a23aabc99563 (diff) | |
download | bcm5719-llvm-f4799847628b511b96bfde868925966b57604fa3.tar.gz bcm5719-llvm-f4799847628b511b96bfde868925966b57604fa3.zip |
PR4350: Make sure we don't create invalid printf attributes. This isn't
visible anywhere normally because the printf format checks for
this case, and we don't print out attribute values anywhere. Original
patch by Roberto Bagnara.
llvm-svn: 73157
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c67af295c18..3a4aeb79a1a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3208,7 +3208,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) { if (!FD->getAttr<FormatAttr>()) FD->addAttr(::new (Context) FormatAttr("printf", FormatIdx + 1, - FormatIdx + 2)); + HasVAListArg ? 0 : FormatIdx + 2)); } // Mark const if we don't care about errno and that is the only @@ -3239,10 +3239,12 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { // FIXME: We known better than our headers. const_cast<FormatAttr *>(Format)->setType("printf"); } else - FD->addAttr(::new (Context) FormatAttr("printf", 1, 2)); + FD->addAttr(::new (Context) FormatAttr("printf", 1, + Name->isStr("NSLogv") ? 0 : 2)); } else if (Name->isStr("asprintf") || Name->isStr("vasprintf")) { if (!FD->getAttr<FormatAttr>()) - FD->addAttr(::new (Context) FormatAttr("printf", 2, 3)); + FD->addAttr(::new (Context) FormatAttr("printf", 2, + Name->isStr("vasprintf") ? 0 : 3)); } } |