Fix handling of references and typedefs
Merge pull request #4810 from wmtan/FixesForFunctionInvocation

Fix handling of references and typedefs