[cfe-commits] r73157 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Jun 9 21:01:39 PDT 2009
Author: efriedma
Date: Tue Jun 9 23:01:38 2009
New Revision: 73157
URL: http://llvm.org/viewvc/llvm-project?rev=73157&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=73157&r1=73156&r2=73157&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 9 23:01:38 2009
@@ -3208,7 +3208,7 @@
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 @@
// 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));
}
}
More information about the cfe-commits
mailing list