From 079b6f5ee5c3516b773a3ad71874c14e8ea7479c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 28 Dec 2009 01:20:29 +0000 Subject: [PATCH] Add an "ATTRIBUTE_UNUSED" macro (and use it). It's for variables which are mainly used in debugging and/or assert situations. It should make the compiler and the static analyzer stop nagging us about them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92181 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 6 ++++++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 8861a209540..1376e4664c2 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -29,6 +29,12 @@ #define ATTRIBUTE_USED #endif +#if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#define ATTRIBUTE_UNUSED __attribute__((__unused__)) +#else +#define ATTRIBUTE_UNUSED +#endif + #ifdef __GNUC__ // aka 'ATTRIBUTE_CONST' but following LLVM Conventions. #define ATTRIBUTE_READNONE __attribute__((__const__)) #else diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 232f035c660..ed4667ba185 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -15,6 +15,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetAsmParser.h" @@ -666,7 +667,7 @@ bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) { const AsmToken &Tok = getLexer().getTok(); if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) return Error(L, "unexpected token in .syntax directive"); - StringRef SymbolName = getLexer().getTok().getIdentifier(); + StringRef ATTRIBUTE_UNUSED SymbolName = getLexer().getTok().getIdentifier(); getLexer().Lex(); // Consume the identifier token. if (getLexer().isNot(AsmToken::EndOfStatement))