mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 06:10:12 +00:00
[clang][nearly-NFC] Remove some superfluous uses of NamedDecl::getNameAsString
`OS << ND->getDeclName();` is equivalent to `OS << ND->getNameAsString();` without the extra temporary string. This is not quite a NFC since two uses of `getNameAsString` in a diagnostic are replaced, which results in the named entity being quoted with additional "'"s (ie: 'var' instead of var).
This commit is contained in:
parent
6f2fa9d312
commit
19701458d4
@ -99,7 +99,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
|
||||
|
||||
SourceLocation Loc = SM.getExpansionLoc(ND->getLocation());
|
||||
if (!Loc.isValid()) {
|
||||
llvm::errs() << "Declaration " << ND->getNameAsString() << "("
|
||||
llvm::errs() << "Declaration " << ND->getDeclName() << "("
|
||||
<< ND->getDeclKindName()
|
||||
<< ") has invalid declaration location.";
|
||||
return llvm::None;
|
||||
|
@ -116,7 +116,7 @@ void HelperDeclRGBuilder::run(
|
||||
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
|
||||
assert(DC);
|
||||
LLVM_DEBUG(llvm::dbgs() << "Find helper function usage: "
|
||||
<< FuncRef->getDecl()->getNameAsString() << " ("
|
||||
<< FuncRef->getDecl()->getDeclName() << " ("
|
||||
<< FuncRef->getDecl() << ")\n");
|
||||
RG->addEdge(
|
||||
getOutmostClassOrFunDecl(DC->getCanonicalDecl()),
|
||||
@ -126,7 +126,7 @@ void HelperDeclRGBuilder::run(
|
||||
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
|
||||
assert(DC);
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "Find helper class usage: " << UsedClass->getNameAsString()
|
||||
<< "Find helper class usage: " << UsedClass->getDeclName()
|
||||
<< " (" << UsedClass << ")\n");
|
||||
RG->addEdge(getOutmostClassOrFunDecl(DC->getCanonicalDecl()), UsedClass);
|
||||
}
|
||||
|
@ -675,8 +675,8 @@ void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
|
||||
Result.Nodes.getNodeAs<NamedDecl>("helper_decls")) {
|
||||
MovedDecls.push_back(ND);
|
||||
HelperDeclarations.push_back(ND);
|
||||
LLVM_DEBUG(llvm::dbgs() << "Add helper : " << ND->getNameAsString() << " ("
|
||||
<< ND << ")\n");
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "Add helper : " << ND->getDeclName() << " (" << ND << ")\n");
|
||||
} else if (const auto *UD = Result.Nodes.getNodeAs<NamedDecl>("using_decl")) {
|
||||
MovedDecls.push_back(UD);
|
||||
}
|
||||
@ -735,12 +735,12 @@ void ClangMoveTool::removeDeclsInOldFiles() {
|
||||
// We remove the helper declarations which are not used in the old.cc after
|
||||
// moving the given declarations.
|
||||
for (const auto *D : HelperDeclarations) {
|
||||
LLVM_DEBUG(llvm::dbgs() << "Check helper is used: "
|
||||
<< D->getNameAsString() << " (" << D << ")\n");
|
||||
LLVM_DEBUG(llvm::dbgs() << "Check helper is used: " << D->getDeclName()
|
||||
<< " (" << D << ")\n");
|
||||
if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(
|
||||
D->getCanonicalDecl()))) {
|
||||
LLVM_DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
|
||||
<< D->getNameAsString() << " (" << D << ")\n");
|
||||
<< D->getDeclName() << " (" << D << ")\n");
|
||||
RemovedDecls.push_back(D);
|
||||
}
|
||||
}
|
||||
@ -820,7 +820,7 @@ void ClangMoveTool::moveDeclsToNewFiles() {
|
||||
D->getCanonicalDecl())))
|
||||
continue;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString()
|
||||
LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getDeclName()
|
||||
<< " " << D << "\n");
|
||||
ActualNewCCDecls.push_back(D);
|
||||
}
|
||||
|
@ -1560,11 +1560,11 @@ class TemplateDiff {
|
||||
if (!Tree.HasChildren()) {
|
||||
// If we're dealing with a template specialization with zero
|
||||
// arguments, there are no children; special-case this.
|
||||
OS << FromTD->getNameAsString() << "<>";
|
||||
OS << FromTD->getDeclName() << "<>";
|
||||
return;
|
||||
}
|
||||
|
||||
OS << FromTD->getNameAsString() << '<';
|
||||
OS << FromTD->getDeclName() << '<';
|
||||
Tree.MoveToChild();
|
||||
unsigned NumElideArgs = 0;
|
||||
bool AllArgsElided = true;
|
||||
@ -1724,7 +1724,7 @@ class TemplateDiff {
|
||||
}
|
||||
|
||||
if (Same) {
|
||||
OS << "template " << FromTD->getNameAsString();
|
||||
OS << "template " << FromTD->getDeclName();
|
||||
} else if (!PrintTree) {
|
||||
OS << (FromDefault ? "(default) template " : "template ");
|
||||
Bold();
|
||||
|
@ -26,10 +26,10 @@ LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); }
|
||||
LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
|
||||
if (F) {
|
||||
if (auto *Cons = dyn_cast<CXXConstructorDecl>(F)) {
|
||||
const std::string &Name = Cons->getParent()->getNameAsString();
|
||||
DeclarationName Name = Cons->getParent()->getDeclName();
|
||||
OS << Name << "::" << Name << ":\n";
|
||||
} else {
|
||||
OS << F->getNameAsString() << ":\n";
|
||||
OS << F->getDeclName() << ":\n";
|
||||
}
|
||||
} else {
|
||||
OS << "<<expr>>\n";
|
||||
|
@ -661,7 +661,7 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
|
||||
void TextNodeDumper::dumpName(const NamedDecl *ND) {
|
||||
if (ND->getDeclName()) {
|
||||
ColorScope Color(OS, ShowColors, DeclNameColor);
|
||||
OS << ' ' << ND->getNameAsString();
|
||||
OS << ' ' << ND->getDeclName();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1600,9 +1600,8 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
|
||||
if (MD->size_overridden_methods() != 0) {
|
||||
auto dumpOverride = [=](const CXXMethodDecl *D) {
|
||||
SplitQualType T_split = D->getType().split();
|
||||
OS << D << " " << D->getParent()->getName()
|
||||
<< "::" << D->getNameAsString() << " '"
|
||||
<< QualType::getAsString(T_split, PrintPolicy) << "'";
|
||||
OS << D << " " << D->getParent()->getName() << "::" << D->getDeclName()
|
||||
<< " '" << QualType::getAsString(T_split, PrintPolicy) << "'";
|
||||
};
|
||||
|
||||
AddChild([=] {
|
||||
@ -2032,7 +2031,7 @@ void TextNodeDumper::VisitUsingDecl(const UsingDecl *D) {
|
||||
OS << ' ';
|
||||
if (D->getQualifier())
|
||||
D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
|
||||
OS << D->getNameAsString();
|
||||
OS << D->getDeclName();
|
||||
}
|
||||
|
||||
void TextNodeDumper::VisitUnresolvedUsingTypenameDecl(
|
||||
@ -2040,7 +2039,7 @@ void TextNodeDumper::VisitUnresolvedUsingTypenameDecl(
|
||||
OS << ' ';
|
||||
if (D->getQualifier())
|
||||
D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
|
||||
OS << D->getNameAsString();
|
||||
OS << D->getDeclName();
|
||||
}
|
||||
|
||||
void TextNodeDumper::VisitUnresolvedUsingValueDecl(
|
||||
@ -2048,7 +2047,7 @@ void TextNodeDumper::VisitUnresolvedUsingValueDecl(
|
||||
OS << ' ';
|
||||
if (D->getQualifier())
|
||||
D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
|
||||
OS << D->getNameAsString();
|
||||
OS << D->getDeclName();
|
||||
dumpType(D->getType());
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public:
|
||||
= Ctx.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error,
|
||||
"%0 was deserialized");
|
||||
Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->getLocation()), DiagID)
|
||||
<< ND->getNameAsString();
|
||||
<< ND;
|
||||
}
|
||||
|
||||
DelegatingDeserializationListener::DeclRead(ID, D);
|
||||
|
@ -52,7 +52,7 @@ void FileIndexRecord::print(llvm::raw_ostream &OS) const {
|
||||
<< ':' << PLoc.getColumn();
|
||||
|
||||
if (auto ND = dyn_cast<NamedDecl>(D)) {
|
||||
OS << ' ' << ND->getNameAsString();
|
||||
OS << ' ' << ND->getDeclName();
|
||||
}
|
||||
|
||||
OS << '\n';
|
||||
|
@ -1849,8 +1849,8 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
||||
<< *PossibleMatch);
|
||||
if (Verbose && POK == POK_VarAccess) {
|
||||
PartialDiagnosticAt VNote(D->getLocation(),
|
||||
S.PDiag(diag::note_guarded_by_declared_here)
|
||||
<< D->getNameAsString());
|
||||
S.PDiag(diag::note_guarded_by_declared_here)
|
||||
<< D->getDeclName());
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note, VNote));
|
||||
} else
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note));
|
||||
|
@ -11027,7 +11027,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
|
||||
BitfieldEnumDecl->getNumPositiveBits() > 0 &&
|
||||
BitfieldEnumDecl->getNumNegativeBits() == 0) {
|
||||
S.Diag(InitLoc, diag::warn_no_underlying_type_specified_for_enum_bitfield)
|
||||
<< BitfieldEnumDecl->getNameAsString();
|
||||
<< BitfieldEnumDecl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,10 +119,10 @@ static const NoteTag *getNoteTag(CheckerContext &C,
|
||||
Out << "Assuming ";
|
||||
|
||||
if (const auto *DRE = dyn_cast<DeclRefExpr>(Object)) {
|
||||
Out << '\'' << DRE->getDecl()->getNameAsString() << '\'';
|
||||
Out << '\'' << DRE->getDecl()->getDeclName() << '\'';
|
||||
} else if (const auto *ME = dyn_cast<MemberExpr>(Object)) {
|
||||
Out << (IsKnownCast ? "Field '" : "field '")
|
||||
<< ME->getMemberDecl()->getNameAsString() << '\'';
|
||||
<< ME->getMemberDecl()->getDeclName() << '\'';
|
||||
} else {
|
||||
Out << (IsKnownCast ? "The object" : "the object");
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void FuchsiaHandleChecker::checkPostCall(const CallEvent &Call,
|
||||
if (auto IsInteresting = PathBR->getInterestingnessKind(RetSym)) {
|
||||
std::string SBuf;
|
||||
llvm::raw_string_ostream OS(SBuf);
|
||||
OS << "Function '" << FuncDecl->getNameAsString()
|
||||
OS << "Function '" << FuncDecl->getDeclName()
|
||||
<< "' returns an open handle";
|
||||
return OS.str();
|
||||
} else
|
||||
|
@ -3301,14 +3301,16 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
|
||||
OS << "reallocated by call to '";
|
||||
const Stmt *S = RSCurr->getStmt();
|
||||
if (const auto *MemCallE = dyn_cast<CXXMemberCallExpr>(S)) {
|
||||
OS << MemCallE->getMethodDecl()->getNameAsString();
|
||||
OS << MemCallE->getMethodDecl()->getDeclName();
|
||||
} else if (const auto *OpCallE = dyn_cast<CXXOperatorCallExpr>(S)) {
|
||||
OS << OpCallE->getDirectCallee()->getNameAsString();
|
||||
OS << OpCallE->getDirectCallee()->getDeclName();
|
||||
} else if (const auto *CallE = dyn_cast<CallExpr>(S)) {
|
||||
auto &CEMgr = BRC.getStateManager().getCallEventManager();
|
||||
CallEventRef<> Call = CEMgr.getSimpleCall(CallE, state, CurrentLC);
|
||||
const auto *D = dyn_cast_or_null<NamedDecl>(Call->getDecl());
|
||||
OS << (D ? D->getNameAsString() : "unknown");
|
||||
if (const auto *D = dyn_cast_or_null<NamedDecl>(Call->getDecl()))
|
||||
OS << D->getDeclName();
|
||||
else
|
||||
OS << "unknown";
|
||||
}
|
||||
OS << "'";
|
||||
StackHint = std::make_unique<StackHintGeneratorForSymbol>(
|
||||
|
@ -580,7 +580,7 @@ void MoveChecker::explainObject(llvm::raw_ostream &OS, const MemRegion *MR,
|
||||
if (const auto DR =
|
||||
dyn_cast_or_null<DeclRegion>(unwrapRValueReferenceIndirection(MR))) {
|
||||
const auto *RegionDecl = cast<NamedDecl>(DR->getDecl());
|
||||
OS << " '" << RegionDecl->getNameAsString() << "'";
|
||||
OS << " '" << RegionDecl->getDeclName() << "'";
|
||||
}
|
||||
|
||||
ObjectKind OK = classifyObject(MR, RD);
|
||||
|
@ -439,7 +439,7 @@ annotateStartParameter(const ExplodedNode *N, SymbolRef Sym,
|
||||
|
||||
std::string s;
|
||||
llvm::raw_string_ostream os(s);
|
||||
os << "Parameter '" << PVD->getNameAsString() << "' starts at +";
|
||||
os << "Parameter '" << PVD->getDeclName() << "' starts at +";
|
||||
if (CurrT->getCount() == 1) {
|
||||
os << "1, as it is marked as consuming";
|
||||
} else {
|
||||
|
@ -125,8 +125,8 @@ void VirtualCallChecker::checkPreCall(const CallEvent &Call,
|
||||
OS << "Call to ";
|
||||
if (IsPure)
|
||||
OS << "pure ";
|
||||
OS << "virtual method '" << MD->getParent()->getNameAsString()
|
||||
<< "::" << MD->getNameAsString() << "' during ";
|
||||
OS << "virtual method '" << MD->getParent()->getDeclName()
|
||||
<< "::" << MD->getDeclName() << "' during ";
|
||||
if (*ObState == ObjectState::CtorCalled)
|
||||
OS << "construction ";
|
||||
else
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
if (S) {
|
||||
S->printJson(Out, Helper, PP, /*AddQuotes=*/true);
|
||||
} else {
|
||||
Out << '\"' << I->getAnyMember()->getNameAsString() << '\"';
|
||||
Out << '\"' << I->getAnyMember()->getDeclName() << '\"';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ static void dump(const SelectedASTNode &Node, llvm::raw_ostream &OS,
|
||||
if (const Decl *D = Node.Node.get<Decl>()) {
|
||||
OS << D->getDeclKindName() << "Decl";
|
||||
if (const auto *ND = dyn_cast<NamedDecl>(D))
|
||||
OS << " \"" << ND->getNameAsString() << '"';
|
||||
OS << " \"" << ND->getDeclName() << '"';
|
||||
} else if (const Stmt *S = Node.Node.get<Stmt>()) {
|
||||
OS << S->getStmtClassName();
|
||||
}
|
||||
|
@ -10,4 +10,4 @@
|
||||
// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 2>&1 \
|
||||
// RUN: | FileCheck %s
|
||||
|
||||
// CHECK: error: NestedVar1 was deserialized
|
||||
// CHECK: error: 'NestedVar1' was deserialized
|
||||
|
@ -6,8 +6,8 @@ void test0() {
|
||||
enum F { F1, F2 };
|
||||
struct { E e1 : 1; E e2; F f1 : 1; F f2; } s;
|
||||
|
||||
s.e1 = E1; // expected-warning {{enums in the Microsoft ABI are signed integers by default; consider giving the enum E an unsigned underlying type to make this code portable}}
|
||||
s.f1 = F1; // expected-warning {{enums in the Microsoft ABI are signed integers by default; consider giving the enum F an unsigned underlying type to make this code portable}}
|
||||
s.e1 = E1; // expected-warning {{enums in the Microsoft ABI are signed integers by default; consider giving the enum 'E' an unsigned underlying type to make this code portable}}
|
||||
s.f1 = F1; // expected-warning {{enums in the Microsoft ABI are signed integers by default; consider giving the enum 'F' an unsigned underlying type to make this code portable}}
|
||||
|
||||
s.e2 = E2;
|
||||
s.f2 = F2;
|
||||
|
Loading…
Reference in New Issue
Block a user