-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC] Run code formatter on Diagnostic.h/cpp ProfileList.cpp SpecialCaseList.cpp #140316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC] Run code formatter on Diagnostic.h/cpp ProfileList.cpp SpecialCaseList.cpp #140316
Conversation
Created using spr 1.3.6
@llvm/pr-subscribers-llvm-support Author: Qinkun Bao (qinkunbao) ChangesPatch is 24.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/140316.diff 4 Files Affected:
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 0ba4edcc5d54c..49ef22d4e4eb6 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -92,18 +92,15 @@ class FixItHint {
/// modification is known.
FixItHint() = default;
- bool isNull() const {
- return !RemoveRange.isValid();
- }
+ bool isNull() const { return !RemoveRange.isValid(); }
/// Create a code modification hint that inserts the given
/// code string at a specific location.
- static FixItHint CreateInsertion(SourceLocation InsertionLoc,
- StringRef Code,
+ static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code,
bool BeforePreviousInsertions = false) {
FixItHint Hint;
Hint.RemoveRange =
- CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
+ CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
Hint.CodeToInsert = std::string(Code);
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
return Hint;
@@ -111,12 +108,13 @@ class FixItHint {
/// Create a code modification hint that inserts the given
/// code from \p FromRange at a specific location.
- static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc,
- CharSourceRange FromRange,
- bool BeforePreviousInsertions = false) {
+ static FixItHint
+ CreateInsertionFromRange(SourceLocation InsertionLoc,
+ CharSourceRange FromRange,
+ bool BeforePreviousInsertions = false) {
FixItHint Hint;
Hint.RemoveRange =
- CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
+ CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
Hint.InsertFromRange = FromRange;
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
return Hint;
@@ -143,8 +141,7 @@ class FixItHint {
return Hint;
}
- static FixItHint CreateReplacement(SourceRange RemoveRange,
- StringRef Code) {
+ static FixItHint CreateReplacement(SourceRange RemoveRange, StringRef Code) {
return CreateReplacement(CharSourceRange::getTokenRange(RemoveRange), Code);
}
};
@@ -553,13 +550,11 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// avoid redundancy across arguments.
///
/// This is a hack to avoid a layering violation between libbasic and libsema.
- using ArgToStringFnTy = void (*)(
- ArgumentKind Kind, intptr_t Val,
- StringRef Modifier, StringRef Argument,
- ArrayRef<ArgumentValue> PrevArgs,
- SmallVectorImpl<char> &Output,
- void *Cookie,
- ArrayRef<intptr_t> QualTypeVals);
+ using ArgToStringFnTy = void (*)(ArgumentKind Kind, intptr_t Val,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<ArgumentValue> PrevArgs,
+ SmallVectorImpl<char> &Output, void *Cookie,
+ ArrayRef<intptr_t> QualTypeVals);
void *ArgToStringCookie = nullptr;
ArgToStringFnTy ArgToStringFn;
@@ -656,9 +651,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// Retrieve the maximum number of template instantiation
/// notes to emit along with a given diagnostic.
- unsigned getTemplateBacktraceLimit() const {
- return TemplateBacktraceLimit;
- }
+ unsigned getTemplateBacktraceLimit() const { return TemplateBacktraceLimit; }
/// Specify the maximum number of constexpr evaluation
/// notes to emit along with a given diagnostic.
@@ -744,9 +737,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// fails.
///
/// By default, we show all candidates.
- void setShowOverloads(OverloadsShown Val) {
- ShowOverloads = Val;
- }
+ void setShowOverloads(OverloadsShown Val) { ShowOverloads = Val; }
OverloadsShown getShowOverloads() const { return ShowOverloads; }
/// When a call or operator fails, print out up to this many candidate
@@ -885,9 +876,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
unsigned getNumErrors() const { return NumErrors; }
unsigned getNumWarnings() const { return NumWarnings; }
- void setNumWarnings(unsigned NumWarnings) {
- this->NumWarnings = NumWarnings;
- }
+ void setNumWarnings(unsigned NumWarnings) { this->NumWarnings = NumWarnings; }
/// Return an ID for a diagnostic with the specified format string and
/// level.
@@ -907,9 +896,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// Converts a diagnostic argument (as an intptr_t) into the string
/// that represents it.
- void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
- StringRef Modifier, StringRef Argument,
- ArrayRef<ArgumentValue> PrevArgs,
+ void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier,
+ StringRef Argument, ArrayRef<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
ArrayRef<intptr_t> QualTypeVals) const {
ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
@@ -1074,8 +1062,9 @@ class DiagnosticErrorTrap {
unsigned NumUnrecoverableErrors;
public:
- explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag)
- : Diag(Diag) { reset(); }
+ explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag) : Diag(Diag) {
+ reset();
+ }
/// Determine whether any errors have occurred since this
/// object instance was created.
@@ -1278,7 +1267,8 @@ class DiagnosticBuilder : public StreamingDiagnostic {
bool Emit() {
// If this diagnostic is inactive, then its soul was stolen by the copy ctor
// (or by a subclass, as in SemaDiagnosticBuilder).
- if (!isActive()) return false;
+ if (!isActive())
+ return false;
// Process the diagnostic.
bool Result = DiagObj->EmitDiagnostic(*this, IsForceEmit);
@@ -1553,7 +1543,9 @@ class Diagnostic {
unsigned getID() const { return DiagID; }
const SourceLocation &getLocation() const { return DiagLoc; }
bool hasSourceManager() const { return DiagObj->hasSourceManager(); }
- SourceManager &getSourceManager() const { return DiagObj->getSourceManager();}
+ SourceManager &getSourceManager() const {
+ return DiagObj->getSourceManager();
+ }
unsigned getNumArgs() const { return DiagStorage.NumDiagArgs; }
@@ -1709,8 +1701,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StoredDiagnostic &);
/// formats and prints fully processed diagnostics.
class DiagnosticConsumer {
protected:
- unsigned NumWarnings = 0; ///< Number of warnings reported
- unsigned NumErrors = 0; ///< Number of errors reported
+ unsigned NumWarnings = 0; ///< Number of warnings reported
+ unsigned NumErrors = 0; ///< Number of errors reported
public:
DiagnosticConsumer() = default;
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 586273ab88bd3..fcf86cc4c234c 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -67,12 +67,12 @@ const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
return DB;
}
-static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
- StringRef Modifier, StringRef Argument,
- ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
- SmallVectorImpl<char> &Output,
- void *Cookie,
- ArrayRef<intptr_t> QualTypeVals) {
+static void
+DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
+ SmallVectorImpl<char> &Output, void *Cookie,
+ ArrayRef<intptr_t> QualTypeVals) {
StringRef Str = "<can't format argument>";
Output.append(Str.begin(), Str.end());
}
@@ -94,9 +94,7 @@ DiagnosticsEngine::~DiagnosticsEngine() {
setClient(nullptr);
}
-void DiagnosticsEngine::dump() const {
- DiagStatesByLoc.dump(*SourceMgr);
-}
+void DiagnosticsEngine::dump() const { DiagStatesByLoc.dump(*SourceMgr); }
void DiagnosticsEngine::dump(StringRef DiagName) const {
DiagStatesByLoc.dump(*SourceMgr, DiagName);
@@ -259,7 +257,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
bool PrintedOuterHeading = false;
auto PrintOuterHeading = [&] {
- if (PrintedOuterHeading) return;
+ if (PrintedOuterHeading)
+ return;
PrintedOuterHeading = true;
llvm::errs() << "File " << &File << " <FileID " << ID.getHashValue()
@@ -272,8 +271,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
llvm::errs() << " parent " << File.Parent << " <FileID "
<< Decomp.first.getHashValue() << "> ";
SrcMgr.getLocForStartOfFile(Decomp.first)
- .getLocWithOffset(Decomp.second)
- .print(llvm::errs(), SrcMgr);
+ .getLocWithOffset(Decomp.second)
+ .print(llvm::errs(), SrcMgr);
}
if (File.HasLocalTransitions)
llvm::errs() << " has_local_transitions";
@@ -286,14 +285,15 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
for (DiagStatePoint &Transition : File.StateTransitions) {
bool PrintedInnerHeading = false;
auto PrintInnerHeading = [&] {
- if (PrintedInnerHeading) return;
+ if (PrintedInnerHeading)
+ return;
PrintedInnerHeading = true;
PrintOuterHeading();
llvm::errs() << " ";
SrcMgr.getLocForStartOfFile(ID)
- .getLocWithOffset(Transition.Offset)
- .print(llvm::errs(), SrcMgr);
+ .getLocWithOffset(Transition.Offset)
+ .print(llvm::errs(), SrcMgr);
llvm::errs() << ": state " << Transition.State << ":\n";
};
@@ -316,11 +316,21 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
llvm::errs() << ": ";
switch (Mapping.second.getSeverity()) {
- case diag::Severity::Ignored: llvm::errs() << "ignored"; break;
- case diag::Severity::Remark: llvm::errs() << "remark"; break;
- case diag::Severity::Warning: llvm::errs() << "warning"; break;
- case diag::Severity::Error: llvm::errs() << "error"; break;
- case diag::Severity::Fatal: llvm::errs() << "fatal"; break;
+ case diag::Severity::Ignored:
+ llvm::errs() << "ignored";
+ break;
+ case diag::Severity::Remark:
+ llvm::errs() << "remark";
+ break;
+ case diag::Severity::Warning:
+ llvm::errs() << "warning";
+ break;
+ case diag::Severity::Error:
+ llvm::errs() << "error";
+ break;
+ case diag::Severity::Fatal:
+ llvm::errs() << "fatal";
+ break;
}
if (!Mapping.second.isUser())
@@ -666,8 +676,8 @@ bool DiagnosticsEngine::EmitDiagnostic(const DiagnosticBuilder &DB,
Diagnostic Info(this, DB);
// Figure out the diagnostic level of this message.
- DiagnosticIDs::Level DiagLevel
- = Diags->getDiagnosticLevel(Info.getID(), Info.getLocation(), *this);
+ DiagnosticIDs::Level DiagLevel =
+ Diags->getDiagnosticLevel(Info.getID(), Info.getLocation(), *this);
Emitted = (DiagLevel != DiagnosticIDs::Ignored);
if (Emitted) {
@@ -719,7 +729,7 @@ Diagnostic::Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
DiagnosticConsumer::~DiagnosticConsumer() = default;
void DiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) {
+ const Diagnostic &Info) {
if (!IncludeInDiagnosticCounts())
return;
@@ -733,7 +743,7 @@ void DiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
template <std::size_t StrLen>
static bool ModifierIs(const char *Modifier, unsigned ModifierLen,
const char (&Str)[StrLen]) {
- return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
+ return StrLen - 1 == ModifierLen && memcmp(Modifier, Str, StrLen - 1) == 0;
}
/// ScanForward - Scans forward, looking for the given character, skipping
@@ -741,20 +751,25 @@ static bool ModifierIs(const char *Modifier, unsigned ModifierLen,
static const char *ScanFormat(const char *I, const char *E, char Target) {
unsigned Depth = 0;
- for ( ; I != E; ++I) {
- if (Depth == 0 && *I == Target) return I;
- if (Depth != 0 && *I == '}') Depth--;
+ for (; I != E; ++I) {
+ if (Depth == 0 && *I == Target)
+ return I;
+ if (Depth != 0 && *I == '}')
+ Depth--;
if (*I == '%') {
I++;
- if (I == E) break;
+ if (I == E)
+ break;
// Escaped characters get implicitly skipped here.
// Format specifier.
if (!isDigit(*I) && !isPunctuation(*I)) {
- for (I++; I != E && !isDigit(*I) && *I != '{'; I++) ;
- if (I == E) break;
+ for (I++; I != E && !isDigit(*I) && *I != '{'; I++)
+ ;
+ if (I == E)
+ break;
if (*I == '{')
Depth++;
}
@@ -771,14 +786,15 @@ static const char *ScanFormat(const char *I, const char *E, char Target) {
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo,
const char *Argument, unsigned ArgumentLen,
SmallVectorImpl<char> &OutStr) {
- const char *ArgumentEnd = Argument+ArgumentLen;
+ const char *ArgumentEnd = Argument + ArgumentLen;
// Skip over 'ValNo' |'s.
while (ValNo) {
const char *NextVal = ScanFormat(Argument, ArgumentEnd, '|');
- assert(NextVal != ArgumentEnd && "Value for integer select modifier was"
+ assert(NextVal != ArgumentEnd &&
+ "Value for integer select modifier was"
" larger than the number of options in the diagnostic string!");
- Argument = NextVal+1; // Skip this string.
+ Argument = NextVal + 1; // Skip this string.
--ValNo;
}
@@ -977,15 +993,13 @@ static const char *getTokenDescForDiagnostic(tok::TokenKind Kind) {
/// FormatDiagnostic - Format this diagnostic into a string, substituting the
/// formal arguments into the %0 slots. The result is appended onto the Str
/// array.
-void Diagnostic::
-FormatDiagnostic(SmallVectorImpl<char> &OutStr) const {
+void Diagnostic::FormatDiagnostic(SmallVectorImpl<char> &OutStr) const {
if (StoredDiagMessage.has_value()) {
OutStr.append(StoredDiagMessage->begin(), StoredDiagMessage->end());
return;
}
- StringRef Diag =
- getDiags()->getDiagnosticIDs()->getDescription(getID());
+ StringRef Diag = getDiags()->getDiagnosticIDs()->getDescription(getID());
FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
}
@@ -1035,9 +1049,8 @@ void clang::EscapeStringForDiagnostic(StringRef Str,
}
}
-void Diagnostic::
-FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
- SmallVectorImpl<char> &OutStr) const {
+void Diagnostic::FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
+ SmallVectorImpl<char> &OutStr) const {
// When the diagnostic string is only "%0", the entire string is being given
// by an outside source. Remove unprintable characters from this string
// and skip all the other string processing.
@@ -1071,7 +1084,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
DiagStr = StrEnd;
continue;
} else if (isPunctuation(DiagStr[1])) {
- OutStr.push_back(DiagStr[1]); // %% -> %.
+ OutStr.push_back(DiagStr[1]); // %% -> %.
DiagStr += 2;
continue;
}
@@ -1090,10 +1103,9 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
// Check to see if we have a modifier. If so eat it.
if (!isDigit(DiagStr[0])) {
Modifier = DiagStr;
- while (DiagStr[0] == '-' ||
- (DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
+ while (DiagStr[0] == '-' || (DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
++DiagStr;
- ModifierLen = DiagStr-Modifier;
+ ModifierLen = DiagStr - Modifier;
// If we have an argument, get it next.
if (DiagStr[0] == '{') {
@@ -1102,8 +1114,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
DiagStr = ScanFormat(DiagStr, DiagEnd, '}');
assert(DiagStr != DiagEnd && "Mismatched {}'s in diagnostic string!");
- ArgumentLen = DiagStr-Argument;
- ++DiagStr; // Skip }.
+ ArgumentLen = DiagStr - Argument;
+ ++DiagStr; // Skip }.
}
}
@@ -1117,7 +1129,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
if (ModifierIs(Modifier, ModifierLen, "diff")) {
assert(*DiagStr == ',' && isDigit(*(DiagStr + 1)) &&
"Invalid format for diff modifier");
- ++DiagStr; // Comma.
+ ++DiagStr; // Comma.
ArgNo2 = *DiagStr++ - '0';
DiagnosticsEngine::ArgumentKind Kind2 = getArgKind(ArgNo2);
if (Kind == DiagnosticsEngine::ak_qualtype &&
@@ -1135,8 +1147,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
"Found too many '|'s in a %diff modifier!");
const char *FirstDollar = ScanFormat(Argument, Pipe, '$');
const char *SecondDollar = ScanFormat(FirstDollar + 1, Pipe, '$');
- const char ArgStr1[] = { '%', static_cast<char>('0' + ArgNo) };
- const char ArgStr2[] = { '%', static_cast<char>('0' + ArgNo2) };
+ const char ArgStr1[] = {'%', static_cast<char>('0' + ArgNo)};
+ const char ArgStr2[] = {'%', static_cast<char>('0' + ArgNo2)};
FormatDiagnostic(Argument, FirstDollar, OutStr);
FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
@@ -1260,8 +1272,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- OutStr, QualTypeVals);
+ FormattedArgs, OutStr, QualTypeVals);
break;
case DiagnosticsEngine::ak_qualtype_pair: {
// Create a struct with all the info needed for printing.
@@ -1284,8 +1295,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, val,
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- Tree, QualTypeVals);
+ FormattedArgs, Tree, QualTypeVals);
// If there is no tree information, fall back to regular printing.
if (!Tree.empty()) {
FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
@@ -1307,11 +1317,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, val,
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- OutStr, QualTypeVals);
+ FormattedArgs, OutStr, QualTypeVals);
if (!TDT.TemplateDiffUsed)
- FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype,
- TDT.FromType));
+ FormattedArgs.push_back(
+ std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType));
// Append middle text
FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
@@ -1321,11 +1330,10 @@...
[truncated]
|
@llvm/pr-subscribers-clang Author: Qinkun Bao (qinkunbao) ChangesPatch is 24.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/140316.diff 4 Files Affected:
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 0ba4edcc5d54c..49ef22d4e4eb6 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -92,18 +92,15 @@ class FixItHint {
/// modification is known.
FixItHint() = default;
- bool isNull() const {
- return !RemoveRange.isValid();
- }
+ bool isNull() const { return !RemoveRange.isValid(); }
/// Create a code modification hint that inserts the given
/// code string at a specific location.
- static FixItHint CreateInsertion(SourceLocation InsertionLoc,
- StringRef Code,
+ static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code,
bool BeforePreviousInsertions = false) {
FixItHint Hint;
Hint.RemoveRange =
- CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
+ CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
Hint.CodeToInsert = std::string(Code);
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
return Hint;
@@ -111,12 +108,13 @@ class FixItHint {
/// Create a code modification hint that inserts the given
/// code from \p FromRange at a specific location.
- static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc,
- CharSourceRange FromRange,
- bool BeforePreviousInsertions = false) {
+ static FixItHint
+ CreateInsertionFromRange(SourceLocation InsertionLoc,
+ CharSourceRange FromRange,
+ bool BeforePreviousInsertions = false) {
FixItHint Hint;
Hint.RemoveRange =
- CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
+ CharSourceRange::getCharRange(InsertionLoc, InsertionLoc);
Hint.InsertFromRange = FromRange;
Hint.BeforePreviousInsertions = BeforePreviousInsertions;
return Hint;
@@ -143,8 +141,7 @@ class FixItHint {
return Hint;
}
- static FixItHint CreateReplacement(SourceRange RemoveRange,
- StringRef Code) {
+ static FixItHint CreateReplacement(SourceRange RemoveRange, StringRef Code) {
return CreateReplacement(CharSourceRange::getTokenRange(RemoveRange), Code);
}
};
@@ -553,13 +550,11 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// avoid redundancy across arguments.
///
/// This is a hack to avoid a layering violation between libbasic and libsema.
- using ArgToStringFnTy = void (*)(
- ArgumentKind Kind, intptr_t Val,
- StringRef Modifier, StringRef Argument,
- ArrayRef<ArgumentValue> PrevArgs,
- SmallVectorImpl<char> &Output,
- void *Cookie,
- ArrayRef<intptr_t> QualTypeVals);
+ using ArgToStringFnTy = void (*)(ArgumentKind Kind, intptr_t Val,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<ArgumentValue> PrevArgs,
+ SmallVectorImpl<char> &Output, void *Cookie,
+ ArrayRef<intptr_t> QualTypeVals);
void *ArgToStringCookie = nullptr;
ArgToStringFnTy ArgToStringFn;
@@ -656,9 +651,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// Retrieve the maximum number of template instantiation
/// notes to emit along with a given diagnostic.
- unsigned getTemplateBacktraceLimit() const {
- return TemplateBacktraceLimit;
- }
+ unsigned getTemplateBacktraceLimit() const { return TemplateBacktraceLimit; }
/// Specify the maximum number of constexpr evaluation
/// notes to emit along with a given diagnostic.
@@ -744,9 +737,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// fails.
///
/// By default, we show all candidates.
- void setShowOverloads(OverloadsShown Val) {
- ShowOverloads = Val;
- }
+ void setShowOverloads(OverloadsShown Val) { ShowOverloads = Val; }
OverloadsShown getShowOverloads() const { return ShowOverloads; }
/// When a call or operator fails, print out up to this many candidate
@@ -885,9 +876,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
unsigned getNumErrors() const { return NumErrors; }
unsigned getNumWarnings() const { return NumWarnings; }
- void setNumWarnings(unsigned NumWarnings) {
- this->NumWarnings = NumWarnings;
- }
+ void setNumWarnings(unsigned NumWarnings) { this->NumWarnings = NumWarnings; }
/// Return an ID for a diagnostic with the specified format string and
/// level.
@@ -907,9 +896,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
/// Converts a diagnostic argument (as an intptr_t) into the string
/// that represents it.
- void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
- StringRef Modifier, StringRef Argument,
- ArrayRef<ArgumentValue> PrevArgs,
+ void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier,
+ StringRef Argument, ArrayRef<ArgumentValue> PrevArgs,
SmallVectorImpl<char> &Output,
ArrayRef<intptr_t> QualTypeVals) const {
ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
@@ -1074,8 +1062,9 @@ class DiagnosticErrorTrap {
unsigned NumUnrecoverableErrors;
public:
- explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag)
- : Diag(Diag) { reset(); }
+ explicit DiagnosticErrorTrap(DiagnosticsEngine &Diag) : Diag(Diag) {
+ reset();
+ }
/// Determine whether any errors have occurred since this
/// object instance was created.
@@ -1278,7 +1267,8 @@ class DiagnosticBuilder : public StreamingDiagnostic {
bool Emit() {
// If this diagnostic is inactive, then its soul was stolen by the copy ctor
// (or by a subclass, as in SemaDiagnosticBuilder).
- if (!isActive()) return false;
+ if (!isActive())
+ return false;
// Process the diagnostic.
bool Result = DiagObj->EmitDiagnostic(*this, IsForceEmit);
@@ -1553,7 +1543,9 @@ class Diagnostic {
unsigned getID() const { return DiagID; }
const SourceLocation &getLocation() const { return DiagLoc; }
bool hasSourceManager() const { return DiagObj->hasSourceManager(); }
- SourceManager &getSourceManager() const { return DiagObj->getSourceManager();}
+ SourceManager &getSourceManager() const {
+ return DiagObj->getSourceManager();
+ }
unsigned getNumArgs() const { return DiagStorage.NumDiagArgs; }
@@ -1709,8 +1701,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StoredDiagnostic &);
/// formats and prints fully processed diagnostics.
class DiagnosticConsumer {
protected:
- unsigned NumWarnings = 0; ///< Number of warnings reported
- unsigned NumErrors = 0; ///< Number of errors reported
+ unsigned NumWarnings = 0; ///< Number of warnings reported
+ unsigned NumErrors = 0; ///< Number of errors reported
public:
DiagnosticConsumer() = default;
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 586273ab88bd3..fcf86cc4c234c 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -67,12 +67,12 @@ const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
return DB;
}
-static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
- StringRef Modifier, StringRef Argument,
- ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
- SmallVectorImpl<char> &Output,
- void *Cookie,
- ArrayRef<intptr_t> QualTypeVals) {
+static void
+DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
+ StringRef Modifier, StringRef Argument,
+ ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
+ SmallVectorImpl<char> &Output, void *Cookie,
+ ArrayRef<intptr_t> QualTypeVals) {
StringRef Str = "<can't format argument>";
Output.append(Str.begin(), Str.end());
}
@@ -94,9 +94,7 @@ DiagnosticsEngine::~DiagnosticsEngine() {
setClient(nullptr);
}
-void DiagnosticsEngine::dump() const {
- DiagStatesByLoc.dump(*SourceMgr);
-}
+void DiagnosticsEngine::dump() const { DiagStatesByLoc.dump(*SourceMgr); }
void DiagnosticsEngine::dump(StringRef DiagName) const {
DiagStatesByLoc.dump(*SourceMgr, DiagName);
@@ -259,7 +257,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
bool PrintedOuterHeading = false;
auto PrintOuterHeading = [&] {
- if (PrintedOuterHeading) return;
+ if (PrintedOuterHeading)
+ return;
PrintedOuterHeading = true;
llvm::errs() << "File " << &File << " <FileID " << ID.getHashValue()
@@ -272,8 +271,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
llvm::errs() << " parent " << File.Parent << " <FileID "
<< Decomp.first.getHashValue() << "> ";
SrcMgr.getLocForStartOfFile(Decomp.first)
- .getLocWithOffset(Decomp.second)
- .print(llvm::errs(), SrcMgr);
+ .getLocWithOffset(Decomp.second)
+ .print(llvm::errs(), SrcMgr);
}
if (File.HasLocalTransitions)
llvm::errs() << " has_local_transitions";
@@ -286,14 +285,15 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
for (DiagStatePoint &Transition : File.StateTransitions) {
bool PrintedInnerHeading = false;
auto PrintInnerHeading = [&] {
- if (PrintedInnerHeading) return;
+ if (PrintedInnerHeading)
+ return;
PrintedInnerHeading = true;
PrintOuterHeading();
llvm::errs() << " ";
SrcMgr.getLocForStartOfFile(ID)
- .getLocWithOffset(Transition.Offset)
- .print(llvm::errs(), SrcMgr);
+ .getLocWithOffset(Transition.Offset)
+ .print(llvm::errs(), SrcMgr);
llvm::errs() << ": state " << Transition.State << ":\n";
};
@@ -316,11 +316,21 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
llvm::errs() << ": ";
switch (Mapping.second.getSeverity()) {
- case diag::Severity::Ignored: llvm::errs() << "ignored"; break;
- case diag::Severity::Remark: llvm::errs() << "remark"; break;
- case diag::Severity::Warning: llvm::errs() << "warning"; break;
- case diag::Severity::Error: llvm::errs() << "error"; break;
- case diag::Severity::Fatal: llvm::errs() << "fatal"; break;
+ case diag::Severity::Ignored:
+ llvm::errs() << "ignored";
+ break;
+ case diag::Severity::Remark:
+ llvm::errs() << "remark";
+ break;
+ case diag::Severity::Warning:
+ llvm::errs() << "warning";
+ break;
+ case diag::Severity::Error:
+ llvm::errs() << "error";
+ break;
+ case diag::Severity::Fatal:
+ llvm::errs() << "fatal";
+ break;
}
if (!Mapping.second.isUser())
@@ -666,8 +676,8 @@ bool DiagnosticsEngine::EmitDiagnostic(const DiagnosticBuilder &DB,
Diagnostic Info(this, DB);
// Figure out the diagnostic level of this message.
- DiagnosticIDs::Level DiagLevel
- = Diags->getDiagnosticLevel(Info.getID(), Info.getLocation(), *this);
+ DiagnosticIDs::Level DiagLevel =
+ Diags->getDiagnosticLevel(Info.getID(), Info.getLocation(), *this);
Emitted = (DiagLevel != DiagnosticIDs::Ignored);
if (Emitted) {
@@ -719,7 +729,7 @@ Diagnostic::Diagnostic(const DiagnosticsEngine *DO, SourceLocation DiagLoc,
DiagnosticConsumer::~DiagnosticConsumer() = default;
void DiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) {
+ const Diagnostic &Info) {
if (!IncludeInDiagnosticCounts())
return;
@@ -733,7 +743,7 @@ void DiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
template <std::size_t StrLen>
static bool ModifierIs(const char *Modifier, unsigned ModifierLen,
const char (&Str)[StrLen]) {
- return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
+ return StrLen - 1 == ModifierLen && memcmp(Modifier, Str, StrLen - 1) == 0;
}
/// ScanForward - Scans forward, looking for the given character, skipping
@@ -741,20 +751,25 @@ static bool ModifierIs(const char *Modifier, unsigned ModifierLen,
static const char *ScanFormat(const char *I, const char *E, char Target) {
unsigned Depth = 0;
- for ( ; I != E; ++I) {
- if (Depth == 0 && *I == Target) return I;
- if (Depth != 0 && *I == '}') Depth--;
+ for (; I != E; ++I) {
+ if (Depth == 0 && *I == Target)
+ return I;
+ if (Depth != 0 && *I == '}')
+ Depth--;
if (*I == '%') {
I++;
- if (I == E) break;
+ if (I == E)
+ break;
// Escaped characters get implicitly skipped here.
// Format specifier.
if (!isDigit(*I) && !isPunctuation(*I)) {
- for (I++; I != E && !isDigit(*I) && *I != '{'; I++) ;
- if (I == E) break;
+ for (I++; I != E && !isDigit(*I) && *I != '{'; I++)
+ ;
+ if (I == E)
+ break;
if (*I == '{')
Depth++;
}
@@ -771,14 +786,15 @@ static const char *ScanFormat(const char *I, const char *E, char Target) {
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo,
const char *Argument, unsigned ArgumentLen,
SmallVectorImpl<char> &OutStr) {
- const char *ArgumentEnd = Argument+ArgumentLen;
+ const char *ArgumentEnd = Argument + ArgumentLen;
// Skip over 'ValNo' |'s.
while (ValNo) {
const char *NextVal = ScanFormat(Argument, ArgumentEnd, '|');
- assert(NextVal != ArgumentEnd && "Value for integer select modifier was"
+ assert(NextVal != ArgumentEnd &&
+ "Value for integer select modifier was"
" larger than the number of options in the diagnostic string!");
- Argument = NextVal+1; // Skip this string.
+ Argument = NextVal + 1; // Skip this string.
--ValNo;
}
@@ -977,15 +993,13 @@ static const char *getTokenDescForDiagnostic(tok::TokenKind Kind) {
/// FormatDiagnostic - Format this diagnostic into a string, substituting the
/// formal arguments into the %0 slots. The result is appended onto the Str
/// array.
-void Diagnostic::
-FormatDiagnostic(SmallVectorImpl<char> &OutStr) const {
+void Diagnostic::FormatDiagnostic(SmallVectorImpl<char> &OutStr) const {
if (StoredDiagMessage.has_value()) {
OutStr.append(StoredDiagMessage->begin(), StoredDiagMessage->end());
return;
}
- StringRef Diag =
- getDiags()->getDiagnosticIDs()->getDescription(getID());
+ StringRef Diag = getDiags()->getDiagnosticIDs()->getDescription(getID());
FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
}
@@ -1035,9 +1049,8 @@ void clang::EscapeStringForDiagnostic(StringRef Str,
}
}
-void Diagnostic::
-FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
- SmallVectorImpl<char> &OutStr) const {
+void Diagnostic::FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
+ SmallVectorImpl<char> &OutStr) const {
// When the diagnostic string is only "%0", the entire string is being given
// by an outside source. Remove unprintable characters from this string
// and skip all the other string processing.
@@ -1071,7 +1084,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
DiagStr = StrEnd;
continue;
} else if (isPunctuation(DiagStr[1])) {
- OutStr.push_back(DiagStr[1]); // %% -> %.
+ OutStr.push_back(DiagStr[1]); // %% -> %.
DiagStr += 2;
continue;
}
@@ -1090,10 +1103,9 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
// Check to see if we have a modifier. If so eat it.
if (!isDigit(DiagStr[0])) {
Modifier = DiagStr;
- while (DiagStr[0] == '-' ||
- (DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
+ while (DiagStr[0] == '-' || (DiagStr[0] >= 'a' && DiagStr[0] <= 'z'))
++DiagStr;
- ModifierLen = DiagStr-Modifier;
+ ModifierLen = DiagStr - Modifier;
// If we have an argument, get it next.
if (DiagStr[0] == '{') {
@@ -1102,8 +1114,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
DiagStr = ScanFormat(DiagStr, DiagEnd, '}');
assert(DiagStr != DiagEnd && "Mismatched {}'s in diagnostic string!");
- ArgumentLen = DiagStr-Argument;
- ++DiagStr; // Skip }.
+ ArgumentLen = DiagStr - Argument;
+ ++DiagStr; // Skip }.
}
}
@@ -1117,7 +1129,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
if (ModifierIs(Modifier, ModifierLen, "diff")) {
assert(*DiagStr == ',' && isDigit(*(DiagStr + 1)) &&
"Invalid format for diff modifier");
- ++DiagStr; // Comma.
+ ++DiagStr; // Comma.
ArgNo2 = *DiagStr++ - '0';
DiagnosticsEngine::ArgumentKind Kind2 = getArgKind(ArgNo2);
if (Kind == DiagnosticsEngine::ak_qualtype &&
@@ -1135,8 +1147,8 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
"Found too many '|'s in a %diff modifier!");
const char *FirstDollar = ScanFormat(Argument, Pipe, '$');
const char *SecondDollar = ScanFormat(FirstDollar + 1, Pipe, '$');
- const char ArgStr1[] = { '%', static_cast<char>('0' + ArgNo) };
- const char ArgStr2[] = { '%', static_cast<char>('0' + ArgNo2) };
+ const char ArgStr1[] = {'%', static_cast<char>('0' + ArgNo)};
+ const char ArgStr2[] = {'%', static_cast<char>('0' + ArgNo2)};
FormatDiagnostic(Argument, FirstDollar, OutStr);
FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
@@ -1260,8 +1272,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- OutStr, QualTypeVals);
+ FormattedArgs, OutStr, QualTypeVals);
break;
case DiagnosticsEngine::ak_qualtype_pair: {
// Create a struct with all the info needed for printing.
@@ -1284,8 +1295,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, val,
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- Tree, QualTypeVals);
+ FormattedArgs, Tree, QualTypeVals);
// If there is no tree information, fall back to regular printing.
if (!Tree.empty()) {
FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
@@ -1307,11 +1317,10 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
getDiags()->ConvertArgToString(Kind, val,
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),
- FormattedArgs,
- OutStr, QualTypeVals);
+ FormattedArgs, OutStr, QualTypeVals);
if (!TDT.TemplateDiffUsed)
- FormattedArgs.push_back(std::make_pair(DiagnosticsEngine::ak_qualtype,
- TDT.FromType));
+ FormattedArgs.push_back(
+ std::make_pair(DiagnosticsEngine::ak_qualtype, TDT.FromType));
// Append middle text
FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
@@ -1321,11 +1330,10 @@...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have issues with reformatting the entire files, and https://www.llvm.org/docs/Contributing.html says nothing about that.
But I guess convention is to reformat only parts you are going to change - less noise in blame output, and less conflict resolution for others who have pending PRs here.
On a positive side, if landed, less friction for future editors.
Thank you for the comments. Yeah, I am changing these files. I feel like reformatting these files makes the future PRs more clean. The most changes are from [Diagnostic.h] and [Diagnostic.cpp]. According to the history, there files are not changed frequently (four times this year). So I guess it won't cause much troubles for others who have pending PRs. |
…pp SpecialCaseList.cpp Reviewers: vitalybuka Reviewed By: vitalybuka Pull Request: llvm/llvm-project#140316
…aseList.cpp Reviewers: vitalybuka Reviewed By: vitalybuka Pull Request: llvm#140316
No description provided.