================
@@ -2305,6 +2308,36 @@ APValue SourceLocExpr::EvaluateInContext(const 
ASTContext &Ctx,
   };
 
   switch (getIdentKind()) {
+  case SourceLocIdentKind::VariableName: {
+    // __builtin_VARIABLE_NAME() is a Clang-specific extension that expands to
+    // the name of the variable being defined in a CXXDefaultArgExpr.
+
+    // FIXME: The AST doesn't have upward edges, so we can't easily traverse up
+    // from the CXXDefaultArgExpr to find it.  Unfortunately, this means we 
need
+    // to do a linear scan of (up to) the entire FunctionDecl.
+    struct FindVarDecl : public RecursiveASTVisitor<FindVarDecl> {
+      const Expr *ToFind;
+      const VarDecl *Found = nullptr;
+      bool TraverseVarDecl(VarDecl *D) {
+        if (const auto *CE = dyn_cast_or_null<CXXConstructExpr>(D->getInit())) 
{
----------------
jroelofs wrote:

Need to strip casts, conversions, parens, etc.

https://github.com/llvm/llvm-project/pull/86756
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to