[PATCH] D33644: Add default values for function parameter chunks

Ivan Donchevskii via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 14 07:39:05 PDT 2017


yvvan added inline comments.


================
Comment at: lib/Sema/SemaCodeComplete.cpp:2411-2417
+  const SourceLocation StartLoc = SrcRange.getBegin();
+  const SourceLocation EndLoc = SrcRange.getEnd();
+  if (StartLoc != SM.getExpansionLoc(StartLoc) || EndLoc != SM.getExpansionLoc(EndLoc))
+      return "";
+  const size_t PtrDiff = EndLoc.getRawEncoding() - StartLoc.getRawEncoding()
+          + Lexer::MeasureTokenLength(EndLoc, SM, LangOpts);
+  return std::string{SM.getCharacterData(StartLoc), PtrDiff};
----------------
klimek wrote:
> Can you use Lexer::getSourceText instead?
If that does the same i will use it in the next diff update


================
Comment at: lib/Sema/SemaCodeComplete.cpp:2453
     std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+    if (Param->hasDefaultArg() && PlaceholderStr.find("=") == std::string::npos) {
+        std::string DefaultValue =
----------------
klimek wrote:
> Why the check for = in the PlaceholderStr?
Not to add default value twice. If there's already "=" in placeholder string that means we've already added it in FormatFunctionParameter call


https://reviews.llvm.org/D33644





More information about the cfe-commits mailing list