From: Anders Carlsson Date: Thu, 20 Jan 2011 03:47:08 +0000 (+0000) Subject: Lazily initialize the 'final' and 'override' contextual keywords as suggested by... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7eeb4ec11043d4860361348f2b19299d957d47a9;p=clang Lazily initialize the 'final' and 'override' contextual keywords as suggested by Doug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123876 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 4ac9eb9987..185f263d5e 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -113,8 +113,8 @@ class Parser : public CodeCompletionHandler { IdentifierInfo *Ident_pixel; /// C++0x contextual keywords. - IdentifierInfo *Ident_final; - IdentifierInfo *Ident_override; + mutable IdentifierInfo *Ident_final; + mutable IdentifierInfo *Ident_override; llvm::OwningPtr AlignHandler; llvm::OwningPtr GCCVisibilityHandler; diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 75a6f59eac..0dc367c9fd 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1275,6 +1275,12 @@ VirtSpecifiers::VirtSpecifier Parser::isCXX0XVirtSpecifier() const { if (Tok.is(tok::identifier)) { IdentifierInfo *II = Tok.getIdentifierInfo(); + // Initialize the contextual keywords. + if (!Ident_final) { + Ident_final = &PP.getIdentifierTable().get("final"); + Ident_override = &PP.getIdentifierTable().get("override"); + } + if (II == Ident_override) return VirtSpecifiers::VS_Override; diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 47c62377c2..3327f7b5a9 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -387,11 +387,8 @@ void Parser::Initialize() { ObjCTypeQuals[objc_byref] = &PP.getIdentifierTable().get("byref"); } - // Initialize C++0x contextual keywords. - if (getLang().CPlusPlus0x) { - Ident_final = &PP.getIdentifierTable().get("final"); - Ident_override = &PP.getIdentifierTable().get("override"); - } + Ident_final = 0; + Ident_override = 0; Ident_super = &PP.getIdentifierTable().get("super");