[PATCH] D22955: [MSVC] Improved late parsing of template functions.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 28 21:47:26 PDT 2016


ABataev created this revision.
ABataev added reviewers: rnk, rsmith, majnemer.
ABataev added subscribers: cfe-commits, andreybokhanko.

MSVC actively uses unqualified lookup in dependent bases, lookup at the instantiation point (non-dependent names may be resolved on things declared later) etc. and all this stuff is the main cause of incompatibility between clang and MSVC.
Clang tries to emulate MSVC behavior but it may fail in many cases. Patch tries to improve compatibility between clang and MSVC. Each time a new instantiation of the function is required, a new copy of the original templated function is created and the body of original function is parsed in the context of this new copy. If unqualified lookup is detected, patch tries to find the required name in the instantiated context. Also, if the original template function is instantiated, but not used, its body is not parsed and not instantiated (it emulates MSVC behavior).
Patch significantly improves compatibility with ATL/WTL headers, but does not solve troubles with unqualified lookup in dependent bases in default initializers of members, types of member functions/data members and default values of function arguments. This must be fixed later.

https://reviews.llvm.org/D22955

Files:
  include/clang/Sema/Sema.h
  lib/AST/DeclBase.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/SemaCXX/ms-property.cpp
  test/SemaTemplate/lookup-dependent-bases.cpp
  test/SemaTemplate/ms-lookup-template-base-classes.cpp
  test/SemaTemplate/typename-specifier.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22955.66077.patch
Type: text/x-patch
Size: 39819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160729/7dc54579/attachment-0001.bin>


More information about the cfe-commits mailing list