[cfe-commits] r150612 - in /cfe/trunk: docs/UsersManual.html include/clang/Basic/DiagnosticIDs.h include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/DiagnosticOptions.h lib/Basic/DiagnosticIDs.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/TextDiagnosticPrinter.cpp test/Frontend/diagnostic-name.c tools/diagtool/ListWarnings.cpp
David Blaikie
dblaikie at gmail.com
Wed Feb 15 11:45:34 PST 2012
Author: dblaikie
Date: Wed Feb 15 13:45:34 2012
New Revision: 150612
URL: http://llvm.org/viewvc/llvm-project?rev=150612&view=rev
Log:
Remove the unuseful -fdiagnostics-show-name
This option was added in r129614 and doesn't have any use case that I'm aware
of. It's possible that external tools are using these names - and if that's
the case we can certainly reassess the functionality, but for now it lets us
shave out a few unneeded bits from clang.
Move the "StaticDiagNameIndex" table into the only remaining consumer, diagtool.
This removes the actual diagnostic name strings from clang entirely.
Reviewed by Chris Lattner & Ted Kremenek.
Removed:
cfe/trunk/test/Frontend/diagnostic-name.c
Modified:
cfe/trunk/docs/UsersManual.html
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
cfe/trunk/tools/diagtool/ListWarnings.cpp
Modified: cfe/trunk/docs/UsersManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.html?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/docs/UsersManual.html (original)
+++ cfe/trunk/docs/UsersManual.html Wed Feb 15 13:45:34 2012
@@ -535,8 +535,6 @@
<li>A categorization of the diagnostic as a note, warning, error, or fatal
error.</li>
<li>A text string that describes what the problem is.</li>
-<li>An option that indicates whether to print the diagnostic name [<a
- href="#opt_fdiagnostics-show-name">-fdiagnostics-show-name</a>].</li>
<li>An option that indicates how to control the diagnostic (for diagnostics that
support it) [<a
href="#opt_fdiagnostics-show-option">-fdiagnostics-show-option</a>].</li>
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Wed Feb 15 13:45:34 2012
@@ -223,31 +223,6 @@
/// are not SFINAE errors.
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
- /// getName - Given a diagnostic ID, return its name
- static StringRef getName(unsigned DiagID);
-
- /// getIdFromName - Given a diagnostic name, return its ID, or 0
- static unsigned getIdFromName(StringRef Name);
-
- /// Iterator class used for traversing all statically declared
- /// diagnostics.
- class diag_iterator {
- const void *impl;
-
- friend class DiagnosticIDs;
- diag_iterator(const void *im) : impl(im) {}
- public:
- diag_iterator &operator++();
- bool operator==(const diag_iterator &x) const { return impl == x.impl; }
- bool operator!=(const diag_iterator &x) const { return impl != x.impl; }
-
- llvm::StringRef getDiagName() const;
- unsigned getDiagID() const;
- };
-
- static diag_iterator diags_begin();
- static diag_iterator diags_end();
-
/// \brief Get the set of all diagnostic IDs in the group with the given name.
///
/// \param Diags [out] - On return, the diagnostics in the group.
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Feb 15 13:45:34 2012
@@ -290,8 +290,6 @@
HelpText<"Print source range spans in numeric form">;
def fdiagnostics_parseable_fixits : Flag<"-fdiagnostics-parseable-fixits">,
HelpText<"Print fix-its in machine parseable form">;
-def fdiagnostics_show_name : Flag<"-fdiagnostics-show-name">,
- HelpText<"Print diagnostic name">;
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">,
HelpText<"Print option name with mappable diagnostics">;
def fdiagnostics_format : Separate<"-fdiagnostics-format">,
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 15 13:45:34 2012
@@ -301,7 +301,6 @@
def fdiagnostics_print_source_range_info : Flag<"-fdiagnostics-print-source-range-info">, Group<f_clang_Group>;
def fdiagnostics_parseable_fixits : Flag<"-fdiagnostics-parseable-fixits">, Group<f_clang_Group>;
def fdiagnostics_show_option : Flag<"-fdiagnostics-show-option">, Group<f_Group>;
-def fdiagnostics_show_name : Flag<"-fdiagnostics-show-name">, Group<f_Group>;
def fdiagnostics_show_note_include_stack : Flag<"-fdiagnostics-show-note-include-stack">, Group<f_Group>;
def fdiagnostics_format_EQ : Joined<"-fdiagnostics-format=">, Group<f_clang_Group>;
def fdiagnostics_show_category_EQ : Joined<"-fdiagnostics-show-category=">, Group<f_clang_Group>;
@@ -402,7 +401,6 @@
def fno_cxx_exceptions: Flag<"-fno-cxx-exceptions">, Group<f_Group>;
def fno_cxx_modules : Flag <"-fno-cxx-modules">, Group<f_Group>, Flags<[NoForward]>;
def fno_diagnostics_fixit_info : Flag<"-fno-diagnostics-fixit-info">, Group<f_Group>;
-def fno_diagnostics_show_name : Flag<"-fno-diagnostics-show-name">, Group<f_Group>;
def fno_diagnostics_show_option : Flag<"-fno-diagnostics-show-option">, Group<f_Group>;
def fno_diagnostics_show_note_include_stack : Flag<"-fno-diagnostics-show-note-include-stack">, Group<f_Group>;
def fno_dollars_in_identifiers : Flag<"-fno-dollars-in-identifiers">, Group<f_Group>;
Modified: cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DiagnosticOptions.h?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/DiagnosticOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DiagnosticOptions.h Wed Feb 15 13:45:34 2012
@@ -31,7 +31,6 @@
unsigned ShowFixits : 1; /// Show fixit information.
unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form.
unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its.
- unsigned ShowNames : 1; /// Show the diagnostic name
unsigned ShowOptionNames : 1; /// Show the option name for mappable
/// diagnostics.
unsigned ShowNoteIncludeStack : 1; /// Show include stacks for notes.
@@ -91,7 +90,6 @@
ShowColumn = 1;
ShowFixits = 1;
ShowLocation = 1;
- ShowNames = 0;
ShowOptionNames = 0;
ShowCategories = 0;
Format = Clang;
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Wed Feb 15 13:45:34 2012
@@ -52,19 +52,14 @@
unsigned WarnShowInSystemHeader : 1;
unsigned Category : 5;
- uint8_t NameLen;
uint8_t OptionGroupLen;
uint16_t DescriptionLen;
- const char *NameStr;
const char *OptionGroupStr;
const char *DescriptionStr;
- StringRef getName() const {
- return StringRef(NameStr, NameLen);
- }
StringRef getOptionGroup() const {
return StringRef(OptionGroupStr, OptionGroupLen);
}
@@ -78,24 +73,6 @@
}
};
-struct StaticDiagNameIndexRec {
- const char *NameStr;
- unsigned short DiagID;
- uint8_t NameLen;
-
- StringRef getName() const {
- return StringRef(NameStr, NameLen);
- }
-
- bool operator<(const StaticDiagNameIndexRec &RHS) const {
- return getName() < RHS.getName();
- }
-
- bool operator==(const StaticDiagNameIndexRec &RHS) const {
- return getName() == RHS.getName();
- }
-};
-
template <size_t SizeOfStr, typename FieldType>
class StringSizerHelper {
char FIELD_TOO_SMALL[SizeOfStr <= FieldType(~0U) ? 1 : -1];
@@ -113,9 +90,9 @@
CATEGORY) \
{ diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, ACCESS, \
NOWERROR, SHOWINSYSHEADER, CATEGORY, \
- STR_SIZE(#ENUM, uint8_t), STR_SIZE(GROUP, uint8_t), \
+ STR_SIZE(GROUP, uint8_t), \
STR_SIZE(DESC, uint16_t), \
- #ENUM, GROUP, DESC },
+ GROUP, DESC },
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
#include "clang/Basic/DiagnosticFrontendKinds.inc"
@@ -126,23 +103,12 @@
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#undef DIAG
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
static const unsigned StaticDiagInfoSize =
sizeof(StaticDiagInfo)/sizeof(StaticDiagInfo[0])-1;
-/// To be sorted before first use (since it's splitted among multiple files)
-static const StaticDiagNameIndexRec StaticDiagNameIndex[] = {
-#define DIAG_NAME_INDEX(ENUM) { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
-#include "clang/Basic/DiagnosticIndexName.inc"
-#undef DIAG_NAME_INDEX
- { 0, 0, 0 }
-};
-
-static const unsigned StaticDiagNameIndexSize =
- sizeof(StaticDiagNameIndex)/sizeof(StaticDiagNameIndex[0])-1;
-
/// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
/// or null if the ID is invalid.
static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
@@ -164,7 +130,7 @@
// Search the diagnostic table with a binary search.
StaticDiagInfoRec Find = { static_cast<unsigned short>(DiagID),
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
const StaticDiagInfoRec *Found =
std::lower_bound(StaticDiagInfo, StaticDiagInfo + StaticDiagInfoSize, Find);
@@ -286,34 +252,6 @@
return SFINAE_Report;
}
-/// getName - Given a diagnostic ID, return its name
-StringRef DiagnosticIDs::getName(unsigned DiagID) {
- if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
- return Info->getName();
- return StringRef();
-}
-
-/// getIdFromName - Given a diagnostic name, return its ID, or 0
-unsigned DiagnosticIDs::getIdFromName(StringRef Name) {
- const StaticDiagNameIndexRec *StaticDiagNameIndexEnd =
- StaticDiagNameIndex + StaticDiagNameIndexSize;
-
- if (Name.empty()) { return diag::DIAG_UPPER_LIMIT; }
-
- assert(Name.size() == static_cast<uint8_t>(Name.size()) &&
- "Name is too long");
- StaticDiagNameIndexRec Find = { Name.data(), 0,
- static_cast<uint8_t>(Name.size()) };
-
- const StaticDiagNameIndexRec *Found =
- std::lower_bound( StaticDiagNameIndex, StaticDiagNameIndexEnd, Find);
- if (Found == StaticDiagNameIndexEnd ||
- Found->getName() != Name)
- return diag::DIAG_UPPER_LIMIT;
-
- return Found->DiagID;
-}
-
/// getBuiltinDiagClass - Return the class field of the diagnostic.
///
static unsigned getBuiltinDiagClass(unsigned DiagID) {
@@ -323,35 +261,6 @@
}
//===----------------------------------------------------------------------===//
-// diag_iterator
-//===----------------------------------------------------------------------===//
-
-llvm::StringRef DiagnosticIDs::diag_iterator::getDiagName() const {
- return static_cast<const StaticDiagNameIndexRec*>(impl)->getName();
-}
-
-unsigned DiagnosticIDs::diag_iterator::getDiagID() const {
- return static_cast<const StaticDiagNameIndexRec*>(impl)->DiagID;
-}
-
-DiagnosticIDs::diag_iterator &DiagnosticIDs::diag_iterator::operator++() {
- const StaticDiagNameIndexRec* ptr =
- static_cast<const StaticDiagNameIndexRec*>(impl);;
- ++ptr;
- impl = ptr;
- return *this;
-}
-
-DiagnosticIDs::diag_iterator DiagnosticIDs::diags_begin() {
- return DiagnosticIDs::diag_iterator(StaticDiagNameIndex);
-}
-
-DiagnosticIDs::diag_iterator DiagnosticIDs::diags_end() {
- return DiagnosticIDs::diag_iterator(StaticDiagNameIndex +
- StaticDiagNameIndexSize);
-}
-
-//===----------------------------------------------------------------------===//
// Custom Diagnostic information
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 15 13:45:34 2012
@@ -2350,11 +2350,6 @@
options::OPT_fno_diagnostics_fixit_info))
CmdArgs.push_back("-fno-diagnostics-fixit-info");
- // Enable -fdiagnostics-show-name by default.
- if (Args.hasFlag(options::OPT_fdiagnostics_show_name,
- options::OPT_fno_diagnostics_show_name, false))
- CmdArgs.push_back("-fdiagnostics-show-name");
-
// Enable -fdiagnostics-show-option by default.
if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
options::OPT_fno_diagnostics_show_option))
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Feb 15 13:45:34 2012
@@ -322,8 +322,6 @@
Res.push_back("-fcolor-diagnostics");
if (Opts.VerifyDiagnostics)
Res.push_back("-verify");
- if (Opts.ShowNames)
- Res.push_back("-fdiagnostics-show-name");
if (Opts.ShowOptionNames)
Res.push_back("-fdiagnostics-show-option");
if (Opts.ShowCategories == 1)
@@ -1217,7 +1215,6 @@
/*Default=*/true);
Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
- Opts.ShowNames = Args.hasArg(OPT_fdiagnostics_show_name);
Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
// Default behavior is to not to show note include stacks.
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Wed Feb 15 13:45:34 2012
@@ -46,16 +46,6 @@
TextDiag.reset(0);
}
-/// \brief Print the diagnostic name to a raw_ostream.
-///
-/// This prints the diagnostic name to a raw_ostream if it has one. It formats
-/// the name according to the expected diagnostic message formatting:
-/// " [diagnostic_name_here]"
-static void printDiagnosticName(raw_ostream &OS, const Diagnostic &Info) {
- if (!DiagnosticIDs::isBuiltinNote(Info.getID()))
- OS << " [" << DiagnosticIDs::getName(Info.getID()) << "]";
-}
-
/// \brief Print any diagnostic option information to a raw_ostream.
///
/// This implements all of the logic for adding diagnostic options to a message
@@ -136,8 +126,6 @@
Info.FormatDiagnostic(OutStr);
llvm::raw_svector_ostream DiagMessageStream(OutStr);
- if (DiagOpts->ShowNames)
- printDiagnosticName(DiagMessageStream, Info);
printDiagnosticOptions(DiagMessageStream, Level, Info, *DiagOpts);
// Keeps track of the the starting position of the location
Removed: cfe/trunk/test/Frontend/diagnostic-name.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/diagnostic-name.c?rev=150611&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/diagnostic-name.c (original)
+++ cfe/trunk/test/Frontend/diagnostic-name.c (removed)
@@ -1,5 +0,0 @@
-// RUN: %clang -fsyntax-only -Wunused-parameter -fdiagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 1
-// RUN: %clang -fsyntax-only -Wunused-parameter -fno-diagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 0
-int main(int argc, char *argv[]) {
- return argc;
-}
Modified: cfe/trunk/tools/diagtool/ListWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/ListWarnings.cpp?rev=150612&r1=150611&r2=150612&view=diff
==============================================================================
--- cfe/trunk/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/trunk/tools/diagtool/ListWarnings.cpp Wed Feb 15 13:45:34 2012
@@ -16,6 +16,14 @@
#include "clang/Basic/Diagnostic.h"
#include "llvm/Support/Format.h"
#include "llvm/ADT/StringMap.h"
+#include "clang/AST/ASTDiagnostic.h"
+#include "clang/Analysis/AnalysisDiagnostic.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Lex/LexDiagnostic.h"
+#include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "clang/Serialization/SerializationDiagnostic.h"
DEF_DIAGTOOL("list-warnings",
"List warnings and their corresponding flags",
@@ -23,6 +31,39 @@
using namespace clang;
+namespace {
+template <size_t SizeOfStr, typename FieldType>
+class StringSizerHelper {
+ char FIELD_TOO_SMALL[SizeOfStr <= FieldType(~0U) ? 1 : -1];
+public:
+ enum { Size = SizeOfStr };
+};
+
+} // namespace anonymous
+
+#define STR_SIZE(str, fieldTy) StringSizerHelper<sizeof(str)-1, fieldTy>::Size
+
+namespace {
+struct StaticDiagNameIndexRec {
+ const char *NameStr;
+ unsigned short DiagID;
+ uint8_t NameLen;
+
+ StringRef getName() const {
+ return StringRef(NameStr, NameLen);
+ }
+};
+}
+
+static const StaticDiagNameIndexRec StaticDiagNameIndex[] = {
+#define DIAG_NAME_INDEX(ENUM) { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
+#include "clang/Basic/DiagnosticIndexName.inc"
+#undef DIAG_NAME_INDEX
+ { 0, 0, 0 }
+};
+
+static const unsigned StaticDiagNameIndexSize =
+ sizeof(StaticDiagNameIndex)/sizeof(StaticDiagNameIndex[0])-1;
namespace {
struct Entry {
@@ -47,16 +88,13 @@
}
int ListWarnings::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
- llvm::IntrusiveRefCntPtr<DiagnosticIDs> Diags(new DiagnosticIDs);
- DiagnosticsEngine D(Diags);
-
std::vector<Entry> Flagged, Unflagged;
llvm::StringMap<std::vector<unsigned> > flagHistogram;
- for (DiagnosticIDs::diag_iterator di = DiagnosticIDs::diags_begin(),
- de = DiagnosticIDs::diags_end(); di != de; ++di) {
+ for (const StaticDiagNameIndexRec *di = StaticDiagNameIndex, *de = StaticDiagNameIndex + StaticDiagNameIndexSize;
+ di != de; ++di) {
- unsigned diagID = di.getDiagID();
+ unsigned diagID = di->DiagID;
if (DiagnosticIDs::isBuiltinNote(diagID))
continue;
@@ -64,7 +102,7 @@
if (!DiagnosticIDs::isBuiltinWarningOrExtension(diagID))
continue;
- Entry entry(di.getDiagName(),
+ Entry entry(di->getName(),
DiagnosticIDs::getWarningOptionForDiag(diagID));
if (entry.Flag.empty())
More information about the cfe-commits
mailing list