Add -fdelayed-template-parsing option. Using this option all templated function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup.
Using this flag is necessary for compatibility with Microsoft template code.
This also provides some parsing speed improvement.
llvm-svn: 130022
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 156e017..d37099f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1413,7 +1413,7 @@
bool FunctionDecl::hasBody(const FunctionDecl *&Definition) const {
for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
- if (I->Body) {
+ if (I->Body || I->IsLateTemplateParsed) {
Definition = *I;
return true;
}
@@ -1427,6 +1427,9 @@
if (I->Body) {
Definition = *I;
return I->Body.get(getASTContext().getExternalSource());
+ } else if (I->IsLateTemplateParsed) {
+ Definition = *I;
+ return 0;
}
}