[clang] 0e5813b - [clang][NFC] silences warnings

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 8 09:51:38 PDT 2022


On Fri, Aug 26, 2022 at 2:10 PM Christopher Di Bella via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
>
> Author: Abraham Corea Diaz
> Date: 2022-08-26T21:09:39Z
> New Revision: 0e5813b88e50576940070003e093d696390a6959
>
> URL: https://github.com/llvm/llvm-project/commit/0e5813b88e50576940070003e093d696390a6959
> DIFF: https://github.com/llvm/llvm-project/commit/0e5813b88e50576940070003e093d696390a6959.diff
>
> LOG: [clang][NFC] silences warnings
>
> * removes unused data member `OS` from `SARIFDiagnostic`
> * flags `Filename` variable as currently unused
>
> This is a follow-up to D131632.
>
> Added:
>
>
> Modified:
>     clang/include/clang/Frontend/SARIFDiagnostic.h
>     clang/lib/Frontend/SARIFDiagnostic.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/clang/include/clang/Frontend/SARIFDiagnostic.h b/clang/include/clang/Frontend/SARIFDiagnostic.h
> index bd0f1df9aa58..ec1d0b8e6a7c 100644
> --- a/clang/include/clang/Frontend/SARIFDiagnostic.h
> +++ b/clang/include/clang/Frontend/SARIFDiagnostic.h
> @@ -55,8 +55,6 @@ class SARIFDiagnostic : public DiagnosticRenderer {
>                                    StringRef ModuleName) override;
>
>  private:
> -  raw_ostream &OS;
> -
>    // Shared between SARIFDiagnosticPrinter and this renderer.
>    SarifDocumentWriter *Writer;
>
>
> diff  --git a/clang/lib/Frontend/SARIFDiagnostic.cpp b/clang/lib/Frontend/SARIFDiagnostic.cpp
> index 2bcbd5cf34f2..f0f32a179825 100644
> --- a/clang/lib/Frontend/SARIFDiagnostic.cpp
> +++ b/clang/lib/Frontend/SARIFDiagnostic.cpp
> @@ -33,7 +33,7 @@ namespace clang {
>  SARIFDiagnostic::SARIFDiagnostic(raw_ostream &OS, const LangOptions &LangOpts,
>                                   DiagnosticOptions *DiagOpts,
>                                   SarifDocumentWriter *Writer)
> -    : DiagnosticRenderer(LangOpts, DiagOpts), OS(OS), Writer(Writer) {}
> +    : DiagnosticRenderer(LangOpts, DiagOpts), Writer(Writer) {}
>
>  // FIXME(llvm-project/issues/57323): Refactor Diagnostic classes.
>  void SARIFDiagnostic::emitDiagnosticMessage(
> @@ -71,7 +71,8 @@ SarifResult SARIFDiagnostic::addLocationToResult(
>      FileID FID = Loc.getFileID();
>      if (FID.isValid()) {
>        if (const FileEntry *FE = Loc.getFileEntry()) {
> -        emitFilename(FE->getName(), Loc.getManager());
> +        [[gnu::unused]] llvm::StringRef Filename =

Does this not cause warnings on an MSVC build for an unknown
attribute? (there's a whole issue with unknown attributes and how to
diagnose them)

I think it's probably best in general to leave the variable out until it's used.

> +            emitFilename(FE->getName(), Loc.getManager());
>          // FIXME(llvm-project/issues/57366): File-only locations
>        }
>      }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list