[PATCH] D84656: [clang] Pass the NamedDecl* instead of the DeclarationName into many diagnostics.
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 27 06:56:24 PDT 2020
riccibruno created this revision.
riccibruno added reviewers: rsmith, aaron.ballman, erichkeane.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
Background:
-----------
There are two related argument types which can be sent into a diagnostic to display the name of an entity: `DeclarationName` (`ak_declarationname`) or `NamedDecl *` (`ak_nameddecl`) (there is also `ak_identifierinfo` for `IdentifierInfo *`, but we are not concerned with it here).
A `DeclarationName` in a diagnostic will just be streamed to the output, which will directly result in a call to `DeclarationName::print`.
A `NamedDecl *` in a diagnostic will also ultimately result in a call to `DeclarationName::print`, but with two customisation points along the way.
The first customisation point is `NamedDecl::getNameForDiagnostic` which is overloaded by `FunctionDecl`, `ClassTemplateSpecializationDecl` and `VarTemplateSpecializationDecl` to print the template arguments if any.
The second customisation point is `NamedDecl::printName`. By default it just streams the stored `DeclarationName` into the output but it can be customised to provide a user-friendly name for an entity. It is currently overloaded by `DecompositionDecl` and `MSGuidDecl`.
What this patch does:
---------------------
For many diagnostics a `DeclarationName` is used instead of the `NamedDecl *`. This bypasses the two customisation points mentioned above. This patches fix this for diagnostics in `Sema.cpp`, `SemaCast.cpp`, `SemaChecking.cpp`, `SemaDecl.cpp`, `SemaDeclAttr.cpp`, `SemaDecl.cpp`, `SemaOverload.cpp` and `SemaStmt.cpp`.
I have only modified diagnostics where I could construct a test-case which demonstrates that the change is appropriate (either with this patch or the next one).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84656
Files:
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
clang/test/Modules/module-private.cpp
clang/test/SemaCXX/array-bounds.cpp
clang/test/SemaCXX/attr-unused.cpp
clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
clang/test/SemaCXX/default2.cpp
clang/test/SemaCXX/incomplete-call.cpp
clang/test/SemaCXX/references.cpp
clang/test/SemaCXX/return-void.cpp
clang/test/SemaCXX/warn-func-not-needed.cpp
clang/test/SemaCXX/warn-large-by-value-copy.cpp
clang/test/SemaCXX/warn-member-not-needed.cpp
clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
clang/test/SemaCXX/warn-pure-virtual-kext.cpp
clang/test/SemaCXX/warn-unused-filescoped.cpp
clang/test/SemaCXX/warn-variable-not-needed.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84656.280888.patch
Type: text/x-patch
Size: 35269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200727/9d15184d/attachment-0001.bin>
More information about the cfe-commits
mailing list