aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTCommon.cpp
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2022-03-28 18:27:18 -0400
committerJames Y Knight <jyknight@google.com>2022-03-28 18:29:02 -0400
commitd61487490022aaacc34249475fac3e208c7d767e (patch)
tree62f7d36763159fa951657e68f8df02ef6e916baa /clang/lib/Serialization/ASTCommon.cpp
parente2485f3c5942877c5e345cac188df7d696e9a6bd (diff)
downloadllvm-d61487490022aaacc34249475fac3e208c7d767e.zip
llvm-d61487490022aaacc34249475fac3e208c7d767e.tar.gz
llvm-d61487490022aaacc34249475fac3e208c7d767e.tar.bz2
[Clang] Implement __builtin_source_location.
This builtin returns the address of a global instance of the `std::source_location::__impl` type, which must be defined (with an appropriate shape) before calling the builtin. It will be used to implement std::source_location in libc++ in a future change. The builtin is compatible with GCC's implementation, and libstdc++'s usage. An intentional divergence is that GCC declares the builtin's return type to be `const void*` (for ease-of-implementation reasons), while Clang uses the actual type, `const std::source_location::__impl*`. In order to support this new functionality, I've also added a new 'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after MSGuidDecl, and is used to represent a generic concept of an lvalue constant with global scope, deduplicated by its value. It's possible that MSGuidDecl itself, or some of the other similar sorts of things in Clang might be able to be refactored onto this more-generic concept, but there's enough special-case weirdness in MSGuidDecl that I gave up attempting to share code there, at least for now. Finally, for compatibility with libstdc++'s <source_location> header, I've added a second exception to the "cannot cast from void* to T* in constant evaluation" rule. This seems a bit distasteful, but feels like the best available option. Reviewers: aaron.ballman, erichkeane Differential Revision: https://reviews.llvm.org/D120159
Diffstat (limited to 'clang/lib/Serialization/ASTCommon.cpp')
-rw-r--r--clang/lib/Serialization/ASTCommon.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index c60f87a..673c566 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -391,6 +391,7 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::Field:
case Decl::MSProperty:
case Decl::MSGuid:
+ case Decl::UnnamedGlobalConstant:
case Decl::TemplateParamObject:
case Decl::ObjCIvar:
case Decl::ObjCAtDefsField: