Fix to get the AST we generate for function templates closer to what clang generates and expects. We fix which FuntionDecl we are passing to CreateFunctionTemplateSpecializationInfo and we strip template parameters from the name when creating the FunctionDecl and FunctionTemplateDecl.
These two fixes together fix asserts and ambiguous lookup issues for several cases which are added to the already existing small function template test. This fixes issues with overloads, overloads and ADL, variadic function templates and templated operator overloads.
The recent fix D75545 came out of this patch and there will be at least one more patch to deal with and edge case with templated operator< when it is in a namespace. We do C++ name parsing in CPlusPlusNameParser and we don’t deal with cases like A::operator<<A::B> properly.
Currently the fix applies mostly to dsym cases and I will be working on a fix that will apply to all cases but it may be a separate PR.
Nit: llvm::Optional
However, usually just a plain StringRef is enough, since it can be empty().