[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:05:34 PDT 2017


rsmith added inline comments.


================
Comment at: test/SemaCXX/source_location.cpp:10-35
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:
----------------
This seems suboptimal. It would seem better for the compiler to generate a global containing the relevant data and to represent a `source_location` as a pointer to such a value. We should also try to minimize the number of relocations necessary to build a `source_location` object, since such constructions are likely to be extremely common in some codebases. We should also keep in mind that we're likely to want to add fields to `source_location` in future, so designing it in a way that avoids an ABI break for such cases would be preferable.

How long has GCC supported this?


https://reviews.llvm.org/D37035





More information about the cfe-commits mailing list