Skip to content

Commit 4ea0d23

Browse files
committed
Simplify warning flag value handling from r206826
Also give the field it a more appropriate name and improve the docs. llvm-svn: 212584
1 parent 013434e commit 4ea0d23

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

clang/include/clang/Basic/Diagnostic.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,12 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
335335
/// \brief Second string argument for the delayed diagnostic.
336336
std::string DelayedDiagArg2;
337337

338-
/// \brief Flag name value.
338+
/// \brief Optional flag value.
339339
///
340-
/// Some flags accept values. For instance, -Wframe-larger-than or -Rpass.
341-
/// When reporting a diagnostic with those flags, it is useful to also
342-
/// report the value that actually triggered the flag. The content of this
343-
/// string is a value to be emitted after the flag name.
344-
std::string FlagNameValue;
340+
/// Some flags accept values, for instance: -Wframe-larger-than=<value> and
341+
/// -Rpass=<value>. The content of this string is emitted after the flag name
342+
/// and '='.
343+
std::string FlagValue;
345344

346345
public:
347346
explicit DiagnosticsEngine(
@@ -703,11 +702,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
703702
/// \brief Clear out the current diagnostic.
704703
void Clear() { CurDiagID = ~0U; }
705704

706-
/// \brief Return the value associated to this diagnostic flag.
707-
StringRef getFlagNameValue() const { return StringRef(FlagNameValue); }
708-
709-
/// \brief Set the value associated to this diagnostic flag.
710-
void setFlagNameValue(StringRef V) { FlagNameValue = V; }
705+
/// \brief Return the value associated with this diagnostic flag.
706+
StringRef getFlagValue() const { return FlagValue; }
711707

712708
private:
713709
/// \brief Report the delayed diagnostic.
@@ -997,7 +993,7 @@ class DiagnosticBuilder {
997993
DiagObj->DiagFixItHints.push_back(Hint);
998994
}
999995

1000-
void addFlagValue(StringRef V) const { DiagObj->setFlagNameValue(V); }
996+
void addFlagValue(StringRef V) const { DiagObj->FlagValue = V; }
1001997
};
1002998

1003999
struct AddFlagValue {
@@ -1108,7 +1104,7 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
11081104
assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
11091105
CurDiagLoc = Loc;
11101106
CurDiagID = DiagID;
1111-
FlagNameValue.clear();
1107+
FlagValue.clear();
11121108
return DiagnosticBuilder(this);
11131109
}
11141110

clang/lib/Frontend/TextDiagnosticPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void printDiagnosticOptions(raw_ostream &OS,
8383
if (!Opt.empty()) {
8484
OS << (Started ? "," : " [")
8585
<< (Level == DiagnosticsEngine::Remark ? "-R" : "-W") << Opt;
86-
StringRef OptValue = Info.getDiags()->getFlagNameValue();
86+
StringRef OptValue = Info.getDiags()->getFlagValue();
8787
if (!OptValue.empty())
8888
OS << "=" << OptValue;
8989
Started = true;

0 commit comments

Comments
 (0)