[modules] Fix Decl's Used invariant.
authorVassil Vassilev <v.g.vassilev@gmail.com>
Wed, 27 Apr 2016 10:46:06 +0000 (10:46 +0000)
committerVassil Vassilev <v.g.vassilev@gmail.com>
Wed, 27 Apr 2016 10:46:06 +0000 (10:46 +0000)
commita4d7d783d04f15b65c749daa33baa3d94b1e5904
tree39acf11e06deec8f291c0cb6fe09d20fde5b4bed
parent7c85a8cb46702e221f5d3eecc3c8e946b325eeb6
[modules] Fix Decl's Used invariant.

The Decl::isUsed has a value for every decl. In non-module builds it is very
difficult (but possible) to break this invariant but when we walk up the redecl
chain we find the neccessary information.

When deserializing the decls from a module it is much more difficult to update
correctly this invariant. The patch centralizes the information whether a decl
is used in the canonical decl marking the entire entity as being used.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27401

Patch by Cristina Cristescu and me.

Thanks to Richard Smith who helped to debug and understand the issue!

Reviewed by Richard Smith.

llvm-svn: 267691
clang/include/clang/AST/DeclBase.h
clang/include/clang/Serialization/ASTWriter.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/Inputs/PR27401/a.h [new file with mode: 0644]
clang/test/Modules/Inputs/PR27401/b.h [new file with mode: 0644]
clang/test/Modules/Inputs/PR27401/module.modulemap [new file with mode: 0644]
clang/test/Modules/pr27401.cpp [new file with mode: 0644]