]> granicus.if.org Git - clang/commitdiff
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198497 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c7d25509e595e1caca2729a039355a38ab1db099..e475a9ed5ec036caa2c19097e32c88b4f705777f 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 9a00783da1e34c6e25a9e0bbef0b8a3fd3981d05..35fd86fd251f789f6641543c34a0fab500519452 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);