]> granicus.if.org Git - clang/commit
[analyzer][UninitializedObjectChecker] Explicit namespace resolution for inherited...
authorKristof Umann <dkszelethus@gmail.com>
Tue, 21 Aug 2018 12:16:59 +0000 (12:16 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Tue, 21 Aug 2018 12:16:59 +0000 (12:16 +0000)
commite46b1b616d44944edf7c1f98423d22539fc6bca8
tree93f66de9a858e8f4ad5bd09c30405fd9bef9c47f
parent1e3b0376117f894b38377fd12855eadb4937e66c
[analyzer][UninitializedObjectChecker] Explicit namespace resolution for inherited data members

For the following example:

  struct Base {
    int x;
  };

  // In a different translation unit

  struct Derived : public Base {
    Derived() {}
  };

For a call to Derived::Derived(), we'll receive a note that
this->x is uninitialized. Since x is not a direct field of Derived,
it could be a little confusing. This patch aims to fix this, as well
as the case when the derived object has a field that has the name as
an inherited uninitialized data member:

  struct Base {
    int x; // note: uninitialized field 'this->Base::x'
  };

  struct Derived : public Base {
    int x = 5;
    Derived() {}
  };

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340272 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
test/Analysis/cxx-uninitialized-object-inheritance.cpp