Move MS predefined type_info out of InitializePredefinedMacros
authorAlp Toker <alp@nuanti.com>
Sat, 4 Jan 2014 15:25:02 +0000 (15:25 +0000)
committerAlp Toker <alp@nuanti.com>
Sat, 4 Jan 2014 15:25:02 +0000 (15:25 +0000)
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

clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Sema/Sema.cpp

index c7d2550..e475a9e 100644 (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;");
     }
   }
 
index 9a00783..35fd86f 100644 (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);