Progress towards making isUsed() reflect whether a declaration is odr-used; don't set isUsed for local variables which are referenced in unevaluated contexts.  Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate.

I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check.  Someone who actually understands the semantics here should fix that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148158 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp
index 46e251b..b0ba7b4 100644
--- a/lib/Serialization/ASTWriterDecl.cpp
+++ b/lib/Serialization/ASTWriterDecl.cpp
@@ -729,6 +729,7 @@
       !D->hasExtInfo() &&
       !D->isImplicit() &&
       !D->isUsed(false) &&
+      !D->isReferenced() &&
       D->getAccess() == AS_none &&
       !D->isModulePrivate() &&
       D->getStorageClass() == 0 &&