[clang] [llvm][tblgen] Add `SourcePath` for `emitSourceFileHeader` (PR #65744)

Shao-Ce SUN via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 02:20:35 PDT 2023


sunshaoce wrote:

> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
> 
> You can test this locally with the following command:
> ```shell
> git-clang-format --diff b8b4ee6b450766796b162b4811a6b3f723d07268 d07486764071679c8cbcd5e7c4905eb41b4770b3 -- clang/utils/TableGen/ClangASTNodesEmitter.cpp clang/utils/TableGen/ClangASTPropertiesEmitter.cpp clang/utils/TableGen/ClangAttrEmitter.cpp clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp clang/utils/TableGen/ClangSyntaxEmitter.cpp clang/utils/TableGen/ClangTypeNodesEmitter.cpp lldb/utils/TableGen/LLDBOptionDefEmitter.cpp lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp llvm/include/llvm/TableGen/TableGenBackend.h llvm/lib/TableGen/TableGenBackend.cpp llvm/utils/TableGen/AsmMatcherEmitter.cpp llvm/utils/TableGen/AsmWriterEmitter.cpp llvm/utils/TableGen/VTEmitter.cpp mlir/tools/mlir-tblgen/DialectGen.cpp mlir/tools/mlir-tblgen/EnumsGen.cpp mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp mlir/tools/mlir-tblgen/RewriterGen.cpp mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
> ```
> 
> View the diff from clang-format here.
> ```diff
> diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
> index 6ba82a22df1e..dddc9b9896ef 100644
> --- a/clang/utils/TableGen/ClangAttrEmitter.cpp
> +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
> @@ -3170,27 +3170,27 @@ namespace clang {
>  
>  // Emits the enumeration list for attributes.
>  void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
> -  emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
> -                       Records);
> +    emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
> +                         Records);
>  
> -  AttrClassHierarchy Hierarchy(Records);
> +    AttrClassHierarchy Hierarchy(Records);
>  
> -  // Add defaulting macro definitions.
> -  Hierarchy.emitDefaultDefines(OS);
> -  emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr);
> +    // Add defaulting macro definitions.
> +    Hierarchy.emitDefaultDefines(OS);
> +    emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr);
>  
> -  std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
> -  std::vector<Record *> PragmaAttrs;
> -  for (auto *Attr : Attrs) {
> -    if (!Attr->getValueAsBit("ASTNode"))
> -      continue;
> +    std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
> +    std::vector<Record *> PragmaAttrs;
> +    for (auto *Attr : Attrs) {
> +      if (!Attr->getValueAsBit("ASTNode"))
> +        continue;
>  
> -    // Add the attribute to the ad-hoc groups.
> -    if (AttrHasPragmaSpelling(Attr))
> -      PragmaAttrs.push_back(Attr);
> +      // Add the attribute to the ad-hoc groups.
> +      if (AttrHasPragmaSpelling(Attr))
> +        PragmaAttrs.push_back(Attr);
>  
> -    // Place it in the hierarchy.
> -    Hierarchy.classifyAttr(Attr);
> +      // Place it in the hierarchy.
> +      Hierarchy.classifyAttr(Attr);
>    }
>  
>    // Emit the main attribute list.
> ```

Is this suggestion correct?

https://github.com/llvm/llvm-project/pull/65744


More information about the cfe-commits mailing list