Correct UnaryTransformTypeLoc to properly initialize.

The initializeLocal function of UnaryTransformTypeLoc missed
the UnderlyingTInfo member.  This caused a null-dereference
issue, as reported in PR23421. This patch correctly initializss 
the UnderlyingTInfo.

llvm-svn: 320765
This commit is contained in:
Erich Keane 2017-12-14 23:37:08 +00:00
parent 3c85a155c1
commit 47475f9ec7
3 changed files with 24 additions and 5 deletions

View File

@ -1961,11 +1961,7 @@ public:
setRParenLoc(Range.getEnd());
}
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
setKWLoc(Loc);
setRParenLoc(Loc);
setLParenLoc(Loc);
}
void initializeLocal(ASTContext &Context, SourceLocation Loc);
};
class DeducedTypeLoc

View File

@ -444,6 +444,15 @@ void TypeOfTypeLoc::initializeLocal(ASTContext &Context,
getUnderlyingType(), Loc);
}
void UnaryTransformTypeLoc::initializeLocal(ASTContext &Context,
SourceLocation Loc) {
setKWLoc(Loc);
setRParenLoc(Loc);
setLParenLoc(Loc);
this->setUnderlyingTInfo(
Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
}
void ElaboratedTypeLoc::initializeLocal(ASTContext &Context,
SourceLocation Loc) {
setElaboratedKeywordLoc(Loc);

View File

@ -62,3 +62,17 @@ enum E {};
void PR26014() { f<E>(0); } // should not yield an ambiguity error.
template<typename ...T> void f(__underlying_type(T) v); // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
namespace PR23421 {
template <class T>
using underlying_type_t = __underlying_type(T);
// Should not crash.
template <class T>
struct make_unsigned_impl { using type = underlying_type_t<T>; };
using AnotherType = make_unsigned_impl<E>::type;
// also should not crash.
template <typename T>
__underlying_type(T) ft();
auto x = &ft<E>;
}