[all-commits] [llvm/llvm-project] f5acd1: [clang-format][NFC] Be more careful about the layo...

Bruno Ricci via All-commits all-commits at lists.llvm.org
Tue Jul 28 02:36:46 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f5acd11d2c0ea228452aa5ed3abbc2c502009d56
      https://github.com/llvm/llvm-project/commit/f5acd11d2c0ea228452aa5ed3abbc2c502009d56
  Author: Bruno Ricci <riccibrun at gmail.com>
  Date:   2020-07-28 (Tue, 28 Jul 2020)

  Changed paths:
    M clang/lib/Format/ContinuationIndenter.cpp
    M clang/lib/Format/Format.cpp
    M clang/lib/Format/FormatToken.cpp
    M clang/lib/Format/FormatToken.h
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/lib/Format/UnwrappedLineFormatter.cpp
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/lib/Format/WhitespaceManager.cpp

  Log Message:
  -----------
  [clang-format][NFC] Be more careful about the layout of FormatToken.

The underlying ABI forces FormatToken to have a lot of padding.

Currently (on x86-64 linux) `sizeof(FormatToken) == 288`. After this patch
`sizeof(FormatToken) == 232`.

No functional changes.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D84306


  Commit: eb10b065f2a870b425dcc2040b9955e0eee464b4
      https://github.com/llvm/llvm-project/commit/eb10b065f2a870b425dcc2040b9955e0eee464b4
  Author: Bruno Ricci <riccibrun at gmail.com>
  Date:   2020-07-28 (Tue, 28 Jul 2020)

  Changed paths:
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaCast.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/lib/Sema/SemaStmt.cpp
    M clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
    M clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
    M clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
    M clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
    M clang/test/Modules/module-private.cpp
    M clang/test/SemaCXX/array-bounds.cpp
    M clang/test/SemaCXX/attr-unused.cpp
    M clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
    M clang/test/SemaCXX/default2.cpp
    M clang/test/SemaCXX/incomplete-call.cpp
    M clang/test/SemaCXX/references.cpp
    M clang/test/SemaCXX/return-void.cpp
    M clang/test/SemaCXX/warn-func-not-needed.cpp
    M clang/test/SemaCXX/warn-large-by-value-copy.cpp
    M clang/test/SemaCXX/warn-member-not-needed.cpp
    M clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
    M clang/test/SemaCXX/warn-pure-virtual-kext.cpp
    M clang/test/SemaCXX/warn-unused-filescoped.cpp
    M clang/test/SemaCXX/warn-variable-not-needed.cpp

  Log Message:
  -----------
  [clang] Pass the NamedDecl* instead of the DeclarationName into many diagnostics.

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).

Reviewed By: erichkeane, aaron.ballman

Differential Revision: https://reviews.llvm.org/D84656


Compare: https://github.com/llvm/llvm-project/compare/e2f5444c9ce2...eb10b065f2a8


More information about the All-commits mailing list