Move MS predefined type_info out of InitializePredefinedMacros

Instead of keeping it in amongst the macros, build the declaration at Sema init
the same way we do with other predeclared and builtin types.

In practice this means the declaration is marked implicit and therefore won't
show up as an unwanted user-declared type in tooling which has been a
frequently reported issue (though I haven't been able to cook up a test).

llvm-svn: 198497
This commit is contained in:
Alp Toker 2014-01-04 15:25:02 +00:00
parent ef6b007dc5
commit e1fab52688
2 changed files with 7 additions and 1 deletions

View File

@ -518,7 +518,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.CPlusPlus) {
// FIXME: Support Microsoft's __identifier extension in the lexer.
Builder.append("#define __identifier(x) x");
Builder.append("class type_info;");
}
}

View File

@ -178,6 +178,13 @@ void Sema::Initialize() {
PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope);
}
// Initialize Microsoft "predefined C++ types".
if (PP.getLangOpts().MicrosoftExt && PP.getLangOpts().CPlusPlus) {
if (IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
PushOnScopeChains(Context.buildImplicitRecord("type_info", TTK_Class),
TUScope);
}
// Initialize predefined OpenCL types.
if (PP.getLangOpts().OpenCL) {
addImplicitTypedef("image1d_t", Context.OCLImage1dTy);