From d63bbadbef6d8b1b9dbc9a5e024c275b0a9897e9 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 28 Jun 2009 07:36:13 +0000 Subject: Add stack protector support to clang. This generates the 'ssp' and 'sspreq' function attributes. There are predefined macros that are defined when stack protectors are used: __SSP__=1 with -fstack-protector and __SSP_ALL__=2 with -fstack-protector-all. llvm-svn: 74405 --- clang/lib/Driver/ArgList.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'clang/lib/Driver/ArgList.cpp') diff --git a/clang/lib/Driver/ArgList.cpp b/clang/lib/Driver/ArgList.cpp index 593694cfbbf..54dd4bb7753 100644 --- a/clang/lib/Driver/ArgList.cpp +++ b/clang/lib/Driver/ArgList.cpp @@ -49,6 +49,35 @@ Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, bool Claim) const { return Res; } +Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, options::ID Id2, + bool Claim) const { + Arg *Res = 0; + Arg *A0 = getLastArg(Id0, false); + Arg *A1 = getLastArg(Id1, false); + Arg *A2 = getLastArg(Id2, false); + + int A0Idx = A0 ? A0->getIndex() : -1; + int A1Idx = A1 ? A1->getIndex() : -1; + int A2Idx = A2 ? A2->getIndex() : -1; + + if (A0Idx > A1Idx) { + if (A0Idx > A2Idx) + Res = A0; + else if (A2Idx != -1) + Res = A2; + } else { + if (A1Idx > A2Idx) + Res = A1; + else if (A2Idx != -1) + Res = A2; + } + + if (Claim && Res) + Res->claim(); + + return Res; +} + bool ArgList::hasFlag(options::ID Pos, options::ID Neg, bool Default) const { if (Arg *A = getLastArg(Pos, Neg)) return A->getOption().matches(Pos); -- cgit v1.2.3