[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 17:36:04 PDT 2017


rsmith added a comment.

I don't like the model of conditionally rebuilding the default initializer / default argument if it contains one of these builtins; it seems more heavy-handed than necessary. I'm also not convinced that we need to store the computed value in the AST.

As an alternative, `CodeGen` and the expression evaluator can track a current call context (the innermost call expression or list initialization that is not within a default argument / default member initializer) consisting of the enclosing `FunctionDecl` and `SourceLocation`, and when the value of one of these builtins is needed, pass that context to the AST node to ask what value it has in that context. This will require a bit more work for the static analyzer, but should be fairly simple elsewhere and will avoid the extra AST nodes for the desugared form.



================
Comment at: docs/LanguageExtensions.rst:2118
+point is the location of the caller. When the builtins appear as part of a
+NSDMI the invocation point is the location of the constructor or
+aggregate initialization used to create the object. Otherwise the invocation
----------------
What is an NSDMI? I think you mean "default member initializer".


https://reviews.llvm.org/D37035





More information about the cfe-commits mailing list