aaron.ballman added a comment.
Richard, with the following test case, my patch currently fails an assertion in
`ASTContext::adjustExceptionSpec()` that I want to solve before committing:
template<typename T> void f7() {
struct S { void g() noexcept(undefined_val); }; // expected-error{{use of
undeclared identifier 'undefined_val'}}
}
template void f7<int>();
What is the correct way to rebuild the type source information? Would it be
correct to call CreateTypeSourceInfo(Updated) to get a new TypeSourceInfo
object of the proper size, then initializeFullCopy() the new type location
object from the old one, and call setExceptionSpecRange() to update the source
range information on the new type loc object? (The range would have to be
passed to adjustExceptionSpec().) Or is there a better way to perform this
rebuilding?
================
Comment at: lib/AST/Decl.cpp:2938-2948
@@ -2937,1 +2937,13 @@
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+ const TypeSourceInfo *TSI = getTypeSourceInfo();
+ if (!TSI)
+ return SourceRange();
+ FunctionTypeLoc FTL =
+ TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
+ if (!FTL)
+ return SourceRange();
+
+ return FTL.getExceptionSpecRange();
+}
+
----------------
rsmith wrote:
> Can you factor out a function to get the `FunctionTypeLoc` from a
> `FunctionDecl`, when there is one (preferably as a separate change)? This is
> duplicated in a few places now (you can find some more by searching for
> `getAs<FunctionProtoTypeLoc>` in Sema), and looks slightly wrong here (we
> should skip calling convention attributes as well as parens).
Yup, I can do that.
http://reviews.llvm.org/D20428
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits