[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

Rafael Stahl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 22 08:06:35 PDT 2017


r.stahl added a comment.

In a similar case, static inline functions are an issue.

inc.h

  void foo();
  static inline void wow()
  {
      int a = *(int*)0;
  }

main.c

  #include "inc.h"
  void moo()
  {
      foo();
      wow();
  }

other.c

  #include "inc.h"
  void foo()
  {
      wow();
  }

The inline function is inlined into each calling AST as different AST objects. This causes the PathDiagnostics to be distinct, while pointing to the exact same source location.

When the compareCrossTUSourceLocs function tries to compare the FullSourceLocs, it cannot find a difference and FlushDiagnostics will assert on an erroneous compare function.

For my purposes I replaced the return statement of the compareCrossTUSourceLocs function with:

  return XL.getFileID() < YL.getFileID();

A more correct fix would create only one unique diagnostic for both cases.


https://reviews.llvm.org/D30691





More information about the cfe-commits mailing list