[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 10:09:19 PDT 2019


aaronpuchert removed a reviewer: bkramer.
aaronpuchert added a comment.

I discovered an issue with variables, because there can be multiple definitions with the same `TypeLoc`:

  extern int a;
  int a, b;

We emit the warning for `b`, but we can't just put static in front of the declaration, as that would affect `a` as well. I haven't found a way to determine whether a `VarDecl` shares its type with another declaration, especially since global declarations don't even belong to a `DeclStmt`. We just get

  TranslationUnitDecl 0x1d0b598 <<invalid sloc>> <invalid sloc>
  |-...
  |-VarDecl 0x1d47b60 <<stdin>:1:1, col:12> col:12 a 'int' extern
  |-VarDecl 0x1d47c18 prev 0x1d47b60 <line:2:1, col:5> col:5 a 'int'
  `-VarDecl 0x1d47c90 <col:1, col:8> col:8 b 'int'

So I think I have to drop the fix-it hint there, but I can still emit a note.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59402/new/

https://reviews.llvm.org/D59402





More information about the cfe-commits mailing list