================ @@ -0,0 +1,61 @@ +//===--- ParseReflect.cpp - C++26 Reflection Parsing ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements parsing for reflection facilities. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/LocInfoType.h" +#include "clang/Basic/DiagnosticParse.h" +#include "clang/Parse/Parser.h" +#include "clang/Sema/EnterExpressionEvaluationContext.h" +using namespace clang; + +ExprResult Parser::ParseCXXReflectExpression(SourceLocation OpLoc) { + // TODO(reflection) : support parsing for more reflect-expressions. + EnterExpressionEvaluationContext Unevaluated( + Actions, Sema::ExpressionEvaluationContext::Unevaluated); + + SourceLocation OperandLoc = Tok.getLocation(); + + { + TentativeParsingAction TPA(*this); + // global namespace :: + if (Tok.is(tok::coloncolon)) { + ConsumeToken(); + TPA.Commit(); ---------------- katzdm wrote:
I think this is wrong; it will parse `^^::std::vector` as `^^::` and then fail with an unrelated diagnostic when it reaches `std::vector`. I implemented this [here](https://github.com/bloomberg/clang-p2996/blob/p2996/clang/lib/Parse/ParseReflect.cpp#L29-L76); note that I start by first trying to parse a `CXXScopeSpec` (i.e., _nested-name-specifier_), then determine whether it's `^^::` based on 1. the tokens that follow and 2. the "kind" of the `CXXScopeSpec`. https://github.com/llvm/llvm-project/pull/164692 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
