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

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 14 06:11:32 PDT 2017


klimek added a comment.

Ok, now I get it - can you please add tests? This is usually tested by adding a c-index-test based test.



================
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};
----------------
Can you use Lexer::getSourceText instead?


================
Comment at: lib/Sema/SemaCodeComplete.cpp:2453
     std::string PlaceholderStr = FormatFunctionParameter(Policy, Param);
+    if (Param->hasDefaultArg() && PlaceholderStr.find("=") == std::string::npos) {
+        std::string DefaultValue =
----------------
Why the check for = in the PlaceholderStr?


https://reviews.llvm.org/D33644





More information about the cfe-commits mailing list