1 //===-- Variable.cpp ------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Symbol/Variable.h"
10 
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ValueObject.h"
13 #include "lldb/Core/ValueObjectVariable.h"
14 #include "lldb/Symbol/Block.h"
15 #include "lldb/Symbol/CompileUnit.h"
16 #include "lldb/Symbol/CompilerDecl.h"
17 #include "lldb/Symbol/CompilerDeclContext.h"
18 #include "lldb/Symbol/Function.h"
19 #include "lldb/Symbol/SymbolContext.h"
20 #include "lldb/Symbol/SymbolFile.h"
21 #include "lldb/Symbol/Type.h"
22 #include "lldb/Symbol/TypeSystem.h"
23 #include "lldb/Symbol/VariableList.h"
24 #include "lldb/Target/ABI.h"
25 #include "lldb/Target/Process.h"
26 #include "lldb/Target/RegisterContext.h"
27 #include "lldb/Target/StackFrame.h"
28 #include "lldb/Target/Target.h"
29 #include "lldb/Target/Thread.h"
30 #include "lldb/Utility/RegularExpression.h"
31 #include "lldb/Utility/Stream.h"
32 
33 #include "llvm/ADT/Twine.h"
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 
38 Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
39                    const lldb::SymbolFileTypeSP &symfile_type_sp,
40                    ValueType scope, SymbolContextScope *context,
41                    const RangeList &scope_range, Declaration *decl_ptr,
42                    const DWARFExpression &location, bool external,
43                    bool artificial, bool location_is_constant_data,
44                    bool static_member)
45     : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
46       m_symfile_type_sp(symfile_type_sp), m_scope(scope),
47       m_owner_scope(context), m_scope_range(scope_range),
48       m_declaration(decl_ptr), m_location(location), m_external(external),
49       m_artificial(artificial), m_loc_is_const_data(location_is_constant_data),
50       m_static_member(static_member) {}
51 
52 Variable::~Variable() = default;
53 
54 lldb::LanguageType Variable::GetLanguage() const {
55   lldb::LanguageType lang = m_mangled.GuessLanguage();
56   if (lang != lldb::eLanguageTypeUnknown)
57     return lang;
58 
59   if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
60     if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
61       return lang;
62   } else if (auto *comp_unit =
63                  m_owner_scope->CalculateSymbolContextCompileUnit()) {
64     if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
65       return lang;
66   }
67 
68   return lldb::eLanguageTypeUnknown;
69 }
70 
71 ConstString Variable::GetName() const {
72   ConstString name = m_mangled.GetName();
73   if (name)
74     return name;
75   return m_name;
76 }
77 
78 ConstString Variable::GetUnqualifiedName() const { return m_name; }
79 
80 bool Variable::NameMatches(ConstString name) const {
81   if (m_name == name)
82     return true;
83   SymbolContext variable_sc;
84   m_owner_scope->CalculateSymbolContext(&variable_sc);
85 
86   return m_mangled.NameMatches(name);
87 }
88 bool Variable::NameMatches(const RegularExpression &regex) const {
89   if (regex.Execute(m_name.AsCString()))
90     return true;
91   if (m_mangled)
92     return m_mangled.NameMatches(regex);
93   return false;
94 }
95 
96 Type *Variable::GetType() {
97   if (m_symfile_type_sp)
98     return m_symfile_type_sp->GetType();
99   return nullptr;
100 }
101 
102 void Variable::Dump(Stream *s, bool show_context) const {
103   s->Printf("%p: ", static_cast<const void *>(this));
104   s->Indent();
105   *s << "Variable" << (const UserID &)*this;
106 
107   if (m_name)
108     *s << ", name = \"" << m_name << "\"";
109 
110   if (m_symfile_type_sp) {
111     Type *type = m_symfile_type_sp->GetType();
112     if (type) {
113       s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
114       type->DumpTypeName(s);
115       s->PutChar(')');
116     }
117   }
118 
119   if (m_scope != eValueTypeInvalid) {
120     s->PutCString(", scope = ");
121     switch (m_scope) {
122     case eValueTypeVariableGlobal:
123       s->PutCString(m_external ? "global" : "static");
124       break;
125     case eValueTypeVariableArgument:
126       s->PutCString("parameter");
127       break;
128     case eValueTypeVariableLocal:
129       s->PutCString("local");
130       break;
131     case eValueTypeVariableThreadLocal:
132       s->PutCString("thread local");
133       break;
134     default:
135       s->AsRawOstream() << "??? (" << m_scope << ')';
136     }
137   }
138 
139   if (show_context && m_owner_scope != nullptr) {
140     s->PutCString(", context = ( ");
141     m_owner_scope->DumpSymbolContext(s);
142     s->PutCString(" )");
143   }
144 
145   bool show_fullpaths = false;
146   m_declaration.Dump(s, show_fullpaths);
147 
148   if (m_location.IsValid()) {
149     s->PutCString(", location = ");
150     ABISP abi;
151     if (m_owner_scope) {
152       ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
153       if (module_sp)
154         abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
155     }
156     m_location.GetDescription(s, lldb::eDescriptionLevelBrief, abi.get());
157   }
158 
159   if (m_external)
160     s->PutCString(", external");
161 
162   if (m_artificial)
163     s->PutCString(", artificial");
164 
165   s->EOL();
166 }
167 
168 bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
169                                bool show_module) {
170   bool dumped_declaration_info = false;
171   if (m_owner_scope) {
172     SymbolContext sc;
173     m_owner_scope->CalculateSymbolContext(&sc);
174     sc.block = nullptr;
175     sc.line_entry.Clear();
176     bool show_inlined_frames = false;
177     const bool show_function_arguments = true;
178     const bool show_function_name = true;
179 
180     dumped_declaration_info = sc.DumpStopContext(
181         s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
182         show_function_arguments, show_function_name);
183 
184     if (sc.function)
185       s->PutChar(':');
186   }
187   if (m_declaration.DumpStopContext(s, false))
188     dumped_declaration_info = true;
189   return dumped_declaration_info;
190 }
191 
192 size_t Variable::MemorySize() const { return sizeof(Variable); }
193 
194 CompilerDeclContext Variable::GetDeclContext() {
195   Type *type = GetType();
196   if (type)
197     return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
198   return CompilerDeclContext();
199 }
200 
201 CompilerDecl Variable::GetDecl() {
202   Type *type = GetType();
203   return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
204 }
205 
206 void Variable::CalculateSymbolContext(SymbolContext *sc) {
207   if (m_owner_scope) {
208     m_owner_scope->CalculateSymbolContext(sc);
209     sc->variable = this;
210   } else
211     sc->Clear(false);
212 }
213 
214 bool Variable::LocationIsValidForFrame(StackFrame *frame) {
215   // Is the variable is described by a single location?
216   if (!m_location.IsLocationList()) {
217     // Yes it is, the location is valid.
218     return true;
219   }
220 
221   if (frame) {
222     Function *function =
223         frame->GetSymbolContext(eSymbolContextFunction).function;
224     if (function) {
225       TargetSP target_sp(frame->CalculateTarget());
226 
227       addr_t loclist_base_load_addr =
228           function->GetAddressRange().GetBaseAddress().GetLoadAddress(
229               target_sp.get());
230       if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
231         return false;
232       // It is a location list. We just need to tell if the location list
233       // contains the current address when converted to a load address
234       return m_location.LocationListContainsAddress(
235           loclist_base_load_addr,
236           frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
237     }
238   }
239   return false;
240 }
241 
242 bool Variable::LocationIsValidForAddress(const Address &address) {
243   // Be sure to resolve the address to section offset prior to calling this
244   // function.
245   if (address.IsSectionOffset()) {
246     SymbolContext sc;
247     CalculateSymbolContext(&sc);
248     if (sc.module_sp == address.GetModule()) {
249       // Is the variable is described by a single location?
250       if (!m_location.IsLocationList()) {
251         // Yes it is, the location is valid.
252         return true;
253       }
254 
255       if (sc.function) {
256         addr_t loclist_base_file_addr =
257             sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
258         if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
259           return false;
260         // It is a location list. We just need to tell if the location list
261         // contains the current address when converted to a load address
262         return m_location.LocationListContainsAddress(loclist_base_file_addr,
263                                                       address.GetFileAddress());
264       }
265     }
266   }
267   return false;
268 }
269 
270 bool Variable::IsInScope(StackFrame *frame) {
271   switch (m_scope) {
272   case eValueTypeRegister:
273   case eValueTypeRegisterSet:
274     return frame != nullptr;
275 
276   case eValueTypeConstResult:
277   case eValueTypeVariableGlobal:
278   case eValueTypeVariableStatic:
279   case eValueTypeVariableThreadLocal:
280     return true;
281 
282   case eValueTypeVariableArgument:
283   case eValueTypeVariableLocal:
284     if (frame) {
285       // We don't have a location list, we just need to see if the block that
286       // this variable was defined in is currently
287       Block *deepest_frame_block =
288           frame->GetSymbolContext(eSymbolContextBlock).block;
289       if (deepest_frame_block) {
290         SymbolContext variable_sc;
291         CalculateSymbolContext(&variable_sc);
292 
293         // Check for static or global variable defined at the compile unit
294         // level that wasn't defined in a block
295         if (variable_sc.block == nullptr)
296           return true;
297 
298         // Check if the variable is valid in the current block
299         if (variable_sc.block != deepest_frame_block &&
300             !variable_sc.block->Contains(deepest_frame_block))
301           return false;
302 
303         // If no scope range is specified then it means that the scope is the
304         // same as the scope of the enclosing lexical block.
305         if (m_scope_range.IsEmpty())
306           return true;
307 
308         addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
309         return m_scope_range.FindEntryThatContains(file_address) != nullptr;
310       }
311     }
312     break;
313 
314   default:
315     break;
316   }
317   return false;
318 }
319 
320 Status Variable::GetValuesForVariableExpressionPath(
321     llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
322     GetVariableCallback callback, void *baton, VariableList &variable_list,
323     ValueObjectList &valobj_list) {
324   Status error;
325   if (!callback || variable_expr_path.empty()) {
326     error.SetErrorString("unknown error");
327     return error;
328   }
329 
330   switch (variable_expr_path.front()) {
331   case '*':
332     error = Variable::GetValuesForVariableExpressionPath(
333         variable_expr_path.drop_front(), scope, callback, baton, variable_list,
334         valobj_list);
335     if (error.Fail()) {
336       error.SetErrorString("unknown error");
337       return error;
338     }
339     for (uint32_t i = 0; i < valobj_list.GetSize();) {
340       Status tmp_error;
341       ValueObjectSP valobj_sp(
342           valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
343       if (tmp_error.Fail()) {
344         variable_list.RemoveVariableAtIndex(i);
345         valobj_list.RemoveValueObjectAtIndex(i);
346       } else {
347         valobj_list.SetValueObjectAtIndex(i, valobj_sp);
348         ++i;
349       }
350     }
351     return error;
352   case '&': {
353     error = Variable::GetValuesForVariableExpressionPath(
354         variable_expr_path.drop_front(), scope, callback, baton, variable_list,
355         valobj_list);
356     if (error.Success()) {
357       for (uint32_t i = 0; i < valobj_list.GetSize();) {
358         Status tmp_error;
359         ValueObjectSP valobj_sp(
360             valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
361         if (tmp_error.Fail()) {
362           variable_list.RemoveVariableAtIndex(i);
363           valobj_list.RemoveValueObjectAtIndex(i);
364         } else {
365           valobj_list.SetValueObjectAtIndex(i, valobj_sp);
366           ++i;
367         }
368       }
369     } else {
370       error.SetErrorString("unknown error");
371     }
372     return error;
373   } break;
374 
375   default: {
376     static RegularExpression g_regex(
377         llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
378     llvm::SmallVector<llvm::StringRef, 2> matches;
379     variable_list.Clear();
380     if (!g_regex.Execute(variable_expr_path, &matches)) {
381       error.SetErrorStringWithFormat(
382           "unable to extract a variable name from '%s'",
383           variable_expr_path.str().c_str());
384       return error;
385     }
386     std::string variable_name = matches[1].str();
387     if (!callback(baton, variable_name.c_str(), variable_list)) {
388       error.SetErrorString("unknown error");
389       return error;
390     }
391     uint32_t i = 0;
392     while (i < variable_list.GetSize()) {
393       VariableSP var_sp(variable_list.GetVariableAtIndex(i));
394       ValueObjectSP valobj_sp;
395       if (!var_sp) {
396         variable_list.RemoveVariableAtIndex(i);
397         continue;
398       }
399       ValueObjectSP variable_valobj_sp(
400           ValueObjectVariable::Create(scope, var_sp));
401       if (!variable_valobj_sp) {
402         variable_list.RemoveVariableAtIndex(i);
403         continue;
404       }
405 
406       llvm::StringRef variable_sub_expr_path =
407           variable_expr_path.drop_front(variable_name.size());
408       if (!variable_sub_expr_path.empty()) {
409         valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
410             variable_sub_expr_path);
411         if (!valobj_sp) {
412           error.SetErrorStringWithFormat(
413               "invalid expression path '%s' for variable '%s'",
414               variable_sub_expr_path.str().c_str(),
415               var_sp->GetName().GetCString());
416           variable_list.RemoveVariableAtIndex(i);
417           continue;
418         }
419       } else {
420         // Just the name of a variable with no extras
421         valobj_sp = variable_valobj_sp;
422       }
423 
424       valobj_list.Append(valobj_sp);
425       ++i;
426     }
427 
428     if (variable_list.GetSize() > 0) {
429       error.Clear();
430       return error;
431     }
432   } break;
433   }
434   error.SetErrorString("unknown error");
435   return error;
436 }
437 
438 bool Variable::DumpLocations(Stream *s, const Address &address) {
439   SymbolContext sc;
440   CalculateSymbolContext(&sc);
441   ABISP abi;
442   if (m_owner_scope) {
443     ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
444     if (module_sp)
445       abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
446   }
447 
448   const addr_t file_addr = address.GetFileAddress();
449   if (sc.function) {
450     addr_t loclist_base_file_addr =
451         sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
452     if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
453       return false;
454     return m_location.DumpLocations(s, eDescriptionLevelBrief,
455                                     loclist_base_file_addr, file_addr,
456                                     abi.get());
457   }
458   return false;
459 }
460 
461 static void PrivateAutoComplete(
462     StackFrame *frame, llvm::StringRef partial_path,
463     const llvm::Twine
464         &prefix_path, // Anything that has been resolved already will be in here
465     const CompilerType &compiler_type, CompletionRequest &request);
466 
467 static void PrivateAutoCompleteMembers(
468     StackFrame *frame, const std::string &partial_member_name,
469     llvm::StringRef partial_path,
470     const llvm::Twine
471         &prefix_path, // Anything that has been resolved already will be in here
472     const CompilerType &compiler_type, CompletionRequest &request) {
473 
474   // We are in a type parsing child members
475   const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
476 
477   if (num_bases > 0) {
478     for (uint32_t i = 0; i < num_bases; ++i) {
479       CompilerType base_class_type =
480           compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
481 
482       PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
483                                  prefix_path,
484                                  base_class_type.GetCanonicalType(), request);
485     }
486   }
487 
488   const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
489 
490   if (num_vbases > 0) {
491     for (uint32_t i = 0; i < num_vbases; ++i) {
492       CompilerType vbase_class_type =
493           compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
494 
495       PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
496                                  prefix_path,
497                                  vbase_class_type.GetCanonicalType(), request);
498     }
499   }
500 
501   // We are in a type parsing child members
502   const uint32_t num_fields = compiler_type.GetNumFields();
503 
504   if (num_fields > 0) {
505     for (uint32_t i = 0; i < num_fields; ++i) {
506       std::string member_name;
507 
508       CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
509           i, member_name, nullptr, nullptr, nullptr);
510 
511       if (partial_member_name.empty() ||
512           llvm::StringRef(member_name).startswith(partial_member_name)) {
513         if (member_name == partial_member_name) {
514           PrivateAutoComplete(
515               frame, partial_path,
516               prefix_path + member_name, // Anything that has been resolved
517                                          // already will be in here
518               member_compiler_type.GetCanonicalType(), request);
519         } else {
520           request.AddCompletion((prefix_path + member_name).str());
521         }
522       }
523     }
524   }
525 }
526 
527 static void PrivateAutoComplete(
528     StackFrame *frame, llvm::StringRef partial_path,
529     const llvm::Twine
530         &prefix_path, // Anything that has been resolved already will be in here
531     const CompilerType &compiler_type, CompletionRequest &request) {
532   //    printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
533   //    '%s'\n", prefix_path.c_str(), partial_path.c_str());
534   std::string remaining_partial_path;
535 
536   const lldb::TypeClass type_class = compiler_type.GetTypeClass();
537   if (partial_path.empty()) {
538     if (compiler_type.IsValid()) {
539       switch (type_class) {
540       default:
541       case eTypeClassArray:
542       case eTypeClassBlockPointer:
543       case eTypeClassBuiltin:
544       case eTypeClassComplexFloat:
545       case eTypeClassComplexInteger:
546       case eTypeClassEnumeration:
547       case eTypeClassFunction:
548       case eTypeClassMemberPointer:
549       case eTypeClassReference:
550       case eTypeClassTypedef:
551       case eTypeClassVector: {
552         request.AddCompletion(prefix_path.str());
553       } break;
554 
555       case eTypeClassClass:
556       case eTypeClassStruct:
557       case eTypeClassUnion:
558         if (prefix_path.str().back() != '.')
559           request.AddCompletion((prefix_path + ".").str());
560         break;
561 
562       case eTypeClassObjCObject:
563       case eTypeClassObjCInterface:
564         break;
565       case eTypeClassObjCObjectPointer:
566       case eTypeClassPointer: {
567         bool omit_empty_base_classes = true;
568         if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0)
569           request.AddCompletion((prefix_path + "->").str());
570         else {
571           request.AddCompletion(prefix_path.str());
572         }
573       } break;
574       }
575     } else {
576       if (frame) {
577         const bool get_file_globals = true;
578 
579         VariableList *variable_list = frame->GetVariableList(get_file_globals);
580 
581         if (variable_list) {
582           for (const VariableSP &var_sp : *variable_list)
583             request.AddCompletion(var_sp->GetName().AsCString());
584         }
585       }
586     }
587   } else {
588     const char ch = partial_path[0];
589     switch (ch) {
590     case '*':
591       if (prefix_path.str().empty()) {
592         PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
593                             request);
594       }
595       break;
596 
597     case '&':
598       if (prefix_path.isTriviallyEmpty()) {
599         PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
600                             compiler_type, request);
601       }
602       break;
603 
604     case '-':
605       if (partial_path.size() > 1 && partial_path[1] == '>' &&
606           !prefix_path.str().empty()) {
607         switch (type_class) {
608         case lldb::eTypeClassPointer: {
609           CompilerType pointee_type(compiler_type.GetPointeeType());
610           if (partial_path.size() > 2 && partial_path[2]) {
611             // If there is more after the "->", then search deeper
612             PrivateAutoComplete(frame, partial_path.substr(2),
613                                 prefix_path + "->",
614                                 pointee_type.GetCanonicalType(), request);
615           } else {
616             // Nothing after the "->", so list all members
617             PrivateAutoCompleteMembers(
618                 frame, std::string(), std::string(), prefix_path + "->",
619                 pointee_type.GetCanonicalType(), request);
620           }
621         } break;
622         default:
623           break;
624         }
625       }
626       break;
627 
628     case '.':
629       if (compiler_type.IsValid()) {
630         switch (type_class) {
631         case lldb::eTypeClassUnion:
632         case lldb::eTypeClassStruct:
633         case lldb::eTypeClassClass:
634           if (partial_path.size() > 1 && partial_path[1]) {
635             // If there is more after the ".", then search deeper
636             PrivateAutoComplete(frame, partial_path.substr(1),
637                                 prefix_path + ".", compiler_type, request);
638 
639           } else {
640             // Nothing after the ".", so list all members
641             PrivateAutoCompleteMembers(frame, std::string(), partial_path,
642                                        prefix_path + ".", compiler_type,
643                                        request);
644           }
645           break;
646         default:
647           break;
648         }
649       }
650       break;
651     default:
652       if (isalpha(ch) || ch == '_' || ch == '$') {
653         const size_t partial_path_len = partial_path.size();
654         size_t pos = 1;
655         while (pos < partial_path_len) {
656           const char curr_ch = partial_path[pos];
657           if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
658             ++pos;
659             continue;
660           }
661           break;
662         }
663 
664         std::string token(std::string(partial_path), 0, pos);
665         remaining_partial_path = std::string(partial_path.substr(pos));
666 
667         if (compiler_type.IsValid()) {
668           PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
669                                      prefix_path, compiler_type, request);
670         } else if (frame) {
671           // We haven't found our variable yet
672           const bool get_file_globals = true;
673 
674           VariableList *variable_list =
675               frame->GetVariableList(get_file_globals);
676 
677           if (!variable_list)
678             break;
679 
680           for (VariableSP var_sp : *variable_list) {
681 
682             if (!var_sp)
683               continue;
684 
685             llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
686             if (variable_name.startswith(token)) {
687               if (variable_name == token) {
688                 Type *variable_type = var_sp->GetType();
689                 if (variable_type) {
690                   CompilerType variable_compiler_type(
691                       variable_type->GetForwardCompilerType());
692                   PrivateAutoComplete(
693                       frame, remaining_partial_path,
694                       prefix_path + token, // Anything that has been resolved
695                                            // already will be in here
696                       variable_compiler_type.GetCanonicalType(), request);
697                 } else {
698                   request.AddCompletion((prefix_path + variable_name).str());
699                 }
700               } else if (remaining_partial_path.empty()) {
701                 request.AddCompletion((prefix_path + variable_name).str());
702               }
703             }
704           }
705         }
706       }
707       break;
708     }
709   }
710 }
711 
712 void Variable::AutoComplete(const ExecutionContext &exe_ctx,
713                             CompletionRequest &request) {
714   CompilerType compiler_type;
715 
716   PrivateAutoComplete(exe_ctx.GetFramePtr(), request.GetCursorArgumentPrefix(),
717                       "", compiler_type, request);
718 }
719