From a789ca9b967abe47b84df83bcf4afb150856a8d9 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sat, 8 Oct 2011 11:31:46 +0000 Subject: [PATCH] Whitespace git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141486 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 2 +- lib/Frontend/CompilerInstance.cpp | 174 +++++----- lib/Parse/ParseStmt.cpp | 120 +++---- lib/Sema/SemaTemplateInstantiateDecl.cpp | 406 +++++++++++------------ 4 files changed, 351 insertions(+), 351 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 07481c1ee3..1914fff0dd 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -536,7 +536,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { if (char *env = ::getenv("IOS_SIMULATOR_DEPLOYMENT_TARGET")) iOSSimTarget = env; - // If no '-miphoneos-version-min' specified on the command line and + // If no '-miphoneos-version-min' specified on the command line and // IPHONEOS_DEPLOYMENT_TARGET is not defined, see if we can set the default // based on isysroot. if (iOSTarget.empty()) { diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 408ebbee43..c413a42f44 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -79,7 +79,7 @@ void CompilerInstance::setFileManager(FileManager *Value) { FileMgr = Value; } -void CompilerInstance::setSourceManager(SourceManager *Value) { +void CompilerInstance::setSourceManager(SourceManager *Value) { SourceMgr = Value; } @@ -162,7 +162,7 @@ void CompilerInstance::createDiagnostics(int Argc, const char* const *Argv, &getCodeGenOpts()); } -llvm::IntrusiveRefCntPtr +llvm::IntrusiveRefCntPtr CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts, int Argc, const char* const *Argv, DiagnosticConsumer *Client, @@ -184,13 +184,13 @@ CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts, Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), Opts)); // Chain in -verify checker, if requested. - if (Opts.VerifyDiagnostics) + if (Opts.VerifyDiagnostics) Diags->setClient(new VerifyDiagnosticConsumer(*Diags)); // Chain in -diagnostic-log-file dumper, if requested. if (!Opts.DiagnosticLogFile.empty()) SetUpDiagnosticLog(Opts, CodeGenOpts, *Diags); - + if (!Opts.DumpBuildInformation.empty()) SetUpBuildDumpLog(Opts, Argc, Argv, *Diags); @@ -216,18 +216,18 @@ void CompilerInstance::createSourceManager(FileManager &FileMgr) { void CompilerInstance::createPreprocessor() { const PreprocessorOptions &PPOpts = getPreprocessorOpts(); - + // Create a PTH manager if we are using some form of a token cache. PTHManager *PTHMgr = 0; if (!PPOpts.TokenCache.empty()) PTHMgr = PTHManager::Create(PPOpts.TokenCache, getDiagnostics()); - + // Create the Preprocessor. HeaderSearch *HeaderInfo = new HeaderSearch(getFileManager()); PP = new Preprocessor(getDiagnostics(), getLangOpts(), &getTarget(), getSourceManager(), *HeaderInfo, *this, PTHMgr, /*OwnsHeaderSearch=*/true); - + // Note that this is different then passing PTHMgr to Preprocessor's ctor. // That argument is used as the IdentifierInfoLookup argument to // IdentifierTable's ctor. @@ -235,30 +235,30 @@ void CompilerInstance::createPreprocessor() { PTHMgr->setPreprocessor(&*PP); PP->setPTHManager(PTHMgr); } - + if (PPOpts.DetailedRecord) PP->createPreprocessingRecord( PPOpts.DetailedRecordIncludesNestedMacroExpansions); - + InitializePreprocessor(*PP, PPOpts, getHeaderSearchOpts(), getFrontendOpts()); - + // Set up the module path, including the hash for the // module-creation options. llvm::SmallString<256> SpecificModuleCache( getHeaderSearchOpts().ModuleCachePath); if (!getHeaderSearchOpts().DisableModuleHash) - llvm::sys::path::append(SpecificModuleCache, + llvm::sys::path::append(SpecificModuleCache, getInvocation().getModuleHash()); PP->getHeaderSearchInfo().configureModules(SpecificModuleCache, getPreprocessorOpts().ModuleBuildPath.empty() - ? std::string() + ? std::string() : getPreprocessorOpts().ModuleBuildPath.back()); - + // Handle generating dependencies, if requested. const DependencyOutputOptions &DepOpts = getDependencyOutputOpts(); if (!DepOpts.OutputFile.empty()) AttachDependencyFileGen(*PP, DepOpts); - + // Handle generating header include information, if requested. if (DepOpts.ShowHeaderIncludes) AttachHeaderIncludeGen(*PP); @@ -290,7 +290,7 @@ void CompilerInstance::createPCHExternalASTSource(StringRef Path, llvm::OwningPtr Source; bool Preamble = getPreprocessorOpts().PrecompiledPreambleBytes.first != 0; Source.reset(createPCHExternalASTSource(Path, getHeaderSearchOpts().Sysroot, - DisablePCHValidation, + DisablePCHValidation, DisableStatCache, getPreprocessor(), getASTContext(), DeserializationListener, @@ -315,8 +315,8 @@ CompilerInstance::createPCHExternalASTSource(StringRef Path, Reader->setDeserializationListener( static_cast(DeserializationListener)); - switch (Reader->ReadAST(Path, - Preamble ? serialization::MK_Preamble + switch (Reader->ReadAST(Path, + Preamble ? serialization::MK_Preamble : serialization::MK_PCH)) { case ASTReader::Success: // Set the predefines buffer as suggested by the PCH reader. Typically, the @@ -338,7 +338,7 @@ CompilerInstance::createPCHExternalASTSource(StringRef Path, // Code Completion -static bool EnableCodeCompletion(Preprocessor &PP, +static bool EnableCodeCompletion(Preprocessor &PP, const std::string &Filename, unsigned Line, unsigned Column) { @@ -398,7 +398,7 @@ CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP, return 0; // Set up the creation routine for code-completion. - return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns, + return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns, ShowGlobals, OS); } @@ -440,7 +440,7 @@ void CompilerInstance::clearOutputFiles(bool EraseFiles) { } } else if (!it->Filename.empty() && EraseFiles) llvm::sys::Path(it->Filename).eraseFromDisk(); - + } OutputFiles.clear(); } @@ -619,7 +619,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { if (getFrontendOpts().ShowStats) llvm::EnableStatistics(); - + for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) { const std::string &InFile = getFrontendOpts().Inputs[i].second; @@ -638,7 +638,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { // Get the total number of warnings/errors from the client. unsigned NumWarnings = getDiagnostics().getClient()->getNumWarnings(); unsigned NumErrors = getDiagnostics().getClient()->getNumErrors(); - + if (NumWarnings) OS << NumWarnings << " warning" << (NumWarnings == 1 ? "" : "s"); if (NumWarnings && NumErrors) @@ -687,7 +687,7 @@ namespace { /// \brief Class that manages the creation of a lock file to aid /// implicit coordination between different processes. /// - /// The implicit coordination works by creating a ".lock" file alongside + /// The implicit coordination works by creating a ".lock" file alongside /// the file that we're coordinating for, using the atomicity of the file /// system to ensure that only a single process can create that ".lock" file. /// When the lock file is removed, the owning process has finished the @@ -710,28 +710,28 @@ namespace { private: llvm::SmallString<128> LockFileName; llvm::SmallString<128> UniqueLockFileName; - + llvm::Optional > Owner; llvm::Optional Error; - + LockFileManager(const LockFileManager &); LockFileManager &operator=(const LockFileManager &); - - static llvm::Optional > + + static llvm::Optional > readLockFile(StringRef LockFileName); - + static bool processStillExecuting(StringRef Hostname, int PID); - + public: - + LockFileManager(StringRef FileName); ~LockFileManager(); /// \brief Determine the state of the lock file. LockFileState getState() const; - + operator LockFileState() const { return getState(); } - + /// \brief For a shared lock, wait until the owner releases the lock. void waitForUnlock(); }; @@ -742,14 +742,14 @@ namespace { /// \param LockFileName The name of the lock file to read. /// /// \returns The process ID of the process that owns this lock file -llvm::Optional > +llvm::Optional > LockFileManager::readLockFile(StringRef LockFileName) { // Check whether the lock file exists. If not, clearly there's nothing // to read, so we just return. bool Exists = false; if (llvm::sys::fs::exists(LockFileName, Exists) || !Exists) return llvm::Optional >(); - + // Read the owning host and PID out of the lock file. If it appears that the // owning process is dead, the lock file is invalid. int PID = 0; @@ -770,42 +770,42 @@ bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) { char MyHostname[256]; MyHostname[255] = 0; MyHostname[0] = 0; - gethostname(MyHostname, 255); + gethostname(MyHostname, 255); // Check whether the process is dead. If so, we're done. if (MyHostname == Hostname && getsid(PID) == -1 && errno == ESRCH) return false; #endif - + return true; } -LockFileManager::LockFileManager(StringRef FileName) +LockFileManager::LockFileManager(StringRef FileName) { LockFileName = FileName; LockFileName += ".lock"; - + // If the lock file already exists, don't bother to try to create our own // lock file; it won't work anyway. Just figure out who owns this lock file. if ((Owner = readLockFile(LockFileName))) return; - + // Create a lock file that is unique to this instance. UniqueLockFileName = LockFileName; UniqueLockFileName += "-%%%%%%%%"; int UniqueLockFileID; - if (llvm::error_code EC - = llvm::sys::fs::unique_file(UniqueLockFileName.str(), + if (llvm::error_code EC + = llvm::sys::fs::unique_file(UniqueLockFileName.str(), UniqueLockFileID, - UniqueLockFileName, + UniqueLockFileName, /*makeAbsolute=*/false)) { Error = EC; return; } - + // Write our process ID to our unique lock file. { llvm::raw_fd_ostream Out(UniqueLockFileID, /*shouldClose=*/true); - + #if LLVM_ON_UNIX // FIXME: move getpid() call into LLVM char hostname[256]; @@ -817,7 +817,7 @@ LockFileManager::LockFileManager(StringRef FileName) Out << "localhost 1"; #endif Out.close(); - + if (Out.has_error()) { // We failed to write out PID, so make up an excuse, remove the // unique lock file, and fail. @@ -827,16 +827,16 @@ LockFileManager::LockFileManager(StringRef FileName) return; } } - + // Create a hard link from the lock file name. If this succeeds, we're done. - llvm::error_code EC - = llvm::sys::fs::create_hard_link(UniqueLockFileName.str(), + llvm::error_code EC + = llvm::sys::fs::create_hard_link(UniqueLockFileName.str(), LockFileName.str()); if (EC == llvm::errc::success) return; - // Creating the hard link failed. - + // Creating the hard link failed. + #ifdef LLVM_ON_UNIX // The creation of the hard link may appear to fail, but if stat'ing the // unique file returns a link count of 2, then we can still declare success. @@ -847,12 +847,12 @@ LockFileManager::LockFileManager(StringRef FileName) #endif // Someone else managed to create the lock file first. Wipe out our unique - // lock file (it's useless now) and read the process ID from the lock file. + // lock file (it's useless now) and read the process ID from the lock file. bool Existed; llvm::sys::fs::remove(UniqueLockFileName.str(), Existed); if ((Owner = readLockFile(LockFileName))) return; - + // There is a lock file that nobody owns; try to clean it up and report // an error. llvm::sys::fs::remove(LockFileName.str(), Existed); @@ -865,14 +865,14 @@ LockFileManager::LockFileState LockFileManager::getState() const { if (Error) return LFS_Error; - + return LFS_Owned; } LockFileManager::~LockFileManager() { if (getState() != LFS_Owned) return; - + // Since we own the lock, remove the lock file and our own unique lock file. bool Existed; llvm::sys::fs::remove(LockFileName.str(), Existed); @@ -882,7 +882,7 @@ LockFileManager::~LockFileManager() { void LockFileManager::waitForUnlock() { if (getState() != LFS_Shared) return; - + #if LLVM_ON_WIN32 unsigned long Interval = 1; #else @@ -894,7 +894,7 @@ void LockFileManager::waitForUnlock() { const unsigned MaxSeconds = 3600; do { // Sleep for the designated interval, to allow the owning process time to - // finish up and + // finish up and // FIXME: Should we hook in to system APIs to get a notification when the // lock file is deleted? #if LLVM_ON_WIN32 @@ -909,7 +909,7 @@ void LockFileManager::waitForUnlock() { if (!processStillExecuting((*Owner).first, (*Owner).second)) return; - + // Exponentially increase the time we wait for the lock to be removed. #if LLVM_ON_WIN32 Interval *= 2; @@ -928,7 +928,7 @@ void LockFileManager::waitForUnlock() { Interval.tv_sec < MaxSeconds #endif ); - + // Give up. } @@ -943,31 +943,31 @@ static void compileModule(CompilerInstance &ImportingInstance, switch (Locked) { case LockFileManager::LFS_Error: return; - + case LockFileManager::LFS_Owned: // We're responsible for building the module ourselves. Do so below. break; - + case LockFileManager::LFS_Shared: // Someone else is responsible for building the module. Wait for them to // finish. Locked.waitForUnlock(); break; } - + // Construct a compiler invocation for creating this module. llvm::IntrusiveRefCntPtr Invocation (new CompilerInvocation(ImportingInstance.getInvocation())); - + // For any options that aren't intended to affect how a module is built, // reset them to their default values. Invocation->getLangOpts().resetNonModularOptions(); Invocation->getPreprocessorOpts().resetNonModularOptions(); - - // Note that this module is part of the module build path, so that we + + // Note that this module is part of the module build path, so that we // can detect cycles in the module graph. Invocation->getPreprocessorOpts().ModuleBuildPath.push_back(ModuleName); - + // Set up the inputs/outputs so that we build the module from its umbrella // header. FrontendOptions &FrontendOpts = Invocation->getFrontendOpts(); @@ -975,38 +975,38 @@ static void compileModule(CompilerInstance &ImportingInstance, FrontendOpts.DisableFree = false; FrontendOpts.Inputs.clear(); FrontendOpts.Inputs.push_back( - std::make_pair(getSourceInputKindFromOptions(Invocation->getLangOpts()), + std::make_pair(getSourceInputKindFromOptions(Invocation->getLangOpts()), UmbrellaHeader)); - + Invocation->getDiagnosticOpts().VerifyDiagnostics = 0; - - + + assert(ImportingInstance.getInvocation().getModuleHash() == Invocation->getModuleHash() && "Module hash mismatch!"); - + // Construct a compiler instance that will be used to actually create the // module. CompilerInstance Instance; Instance.setInvocation(&*Invocation); - Instance.createDiagnostics(/*argc=*/0, /*argv=*/0, + Instance.createDiagnostics(/*argc=*/0, /*argv=*/0, &ImportingInstance.getDiagnosticClient(), /*ShouldOwnClient=*/true, /*ShouldCloneClient=*/true); // Construct a module-generating action. GeneratePCHAction CreateModuleAction(true); - + // Execute the action to actually build the module in-place. Use a separate // thread so that we get a stack large enough. const unsigned ThreadStackSize = 8 << 20; llvm::CrashRecoveryContext CRC; CompileModuleData Data = { Instance, CreateModuleAction }; CRC.RunSafelyOnThread(&doCompileModule, &Data, ThreadStackSize); -} +} -ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, +ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, IdentifierInfo &ModuleName, - SourceLocation ModuleNameLoc) { + SourceLocation ModuleNameLoc) { // Determine what file we're searching from. SourceManager &SourceMgr = getSourceManager(); SourceLocation ExpandedImportLoc = SourceMgr.getExpansionLoc(ImportLoc); @@ -1022,17 +1022,17 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, = PP->getHeaderSearchInfo().lookupModule(ModuleName.getName(), &ModuleFileName, &UmbrellaHeader); - + bool BuildingModule = false; if (!ModuleFile && !UmbrellaHeader.empty()) { // We didn't find the module, but there is an umbrella header that // can be used to create the module file. Create a separate compilation // module to do so. - + // Check whether there is a cycle in the module graph. SmallVectorImpl &ModuleBuildPath = getPreprocessorOpts().ModuleBuildPath; - SmallVectorImpl::iterator Pos + SmallVectorImpl::iterator Pos = std::find(ModuleBuildPath.begin(), ModuleBuildPath.end(), ModuleName.getName()); if (Pos != ModuleBuildPath.end()) { @@ -1042,28 +1042,28 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, CyclePath += " -> "; } CyclePath += ModuleName.getName(); - + getDiagnostics().Report(ModuleNameLoc, diag::err_module_cycle) << ModuleName.getName() << CyclePath; return 0; } - + getDiagnostics().Report(ModuleNameLoc, diag::warn_module_build) << ModuleName.getName(); BuildingModule = true; compileModule(*this, ModuleName.getName(), ModuleFileName, UmbrellaHeader); ModuleFile = PP->getHeaderSearchInfo().lookupModule(ModuleName.getName()); } - + if (!ModuleFile) { - getDiagnostics().Report(ModuleNameLoc, + getDiagnostics().Report(ModuleNameLoc, BuildingModule? diag::err_module_not_built : diag::err_module_not_found) << ModuleName.getName() << SourceRange(ImportLoc, ModuleNameLoc); return 0; } - + // If we don't already have an ASTReader, create one now. if (!ModuleManager) { if (!hasASTContext()) @@ -1073,7 +1073,7 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, const PreprocessorOptions &PPOpts = getPreprocessorOpts(); ModuleManager = new ASTReader(getPreprocessor(), *Context, Sysroot.empty() ? "" : Sysroot.c_str(), - PPOpts.DisablePCHValidation, + PPOpts.DisablePCHValidation, PPOpts.DisableStatCache); if (hasASTConsumer()) { ModuleManager->setDeserializationListener( @@ -1089,7 +1089,7 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, if (hasASTConsumer()) ModuleManager->StartTranslationUnit(&getASTConsumer()); } - + // Try to load the module we found. switch (ModuleManager->ReadAST(ModuleFile->getName(), serialization::MK_Module)) { @@ -1100,12 +1100,12 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc, // FIXME: The ASTReader will already have complained, but can we showhorn // that diagnostic information into a more useful form? return 0; - + case ASTReader::Failure: // Already complained. return 0; } - + // FIXME: The module file's FileEntry makes a poor key indeed! return (ModuleKey)ModuleFile; } diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 489ceab950..7754c9855d 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -79,7 +79,7 @@ StmtResult Parser::ParseStatementOrDeclaration(StmtVector &Stmts, bool OnlyStatement) { const char *SemiError = 0; StmtResult Res; - + ParenBraceBracketBalancer BalancerRAIIObj(*this); ParsedAttributesWithRange attrs(AttrFactory); @@ -102,14 +102,14 @@ Retry: Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement); cutOffParsing(); return StmtError(); - + case tok::identifier: { Token Next = NextToken(); if (Next.is(tok::colon)) { // C99 6.8.1: labeled-statement // identifier ':' statement return ParseLabeledStatement(attrs); } - + if (Next.isNot(tok::coloncolon)) { CXXScopeSpec SS; IdentifierInfo *Name = Tok.getIdentifierInfo(); @@ -130,11 +130,11 @@ Retry: Tok.setKind(Name->getTokenID()); goto Retry; } - + // Fall through via the normal error path. // FIXME: This seems like it could only happen for context-sensitive // keywords. - + case Sema::NC_Error: // Handle errors here by skipping up to the next semicolon or '}', and // eat the semicolon if that's what stopped us. @@ -142,33 +142,33 @@ Retry: if (Tok.is(tok::semi)) ConsumeToken(); return StmtError(); - + case Sema::NC_Unknown: // Either we don't know anything about this identifier, or we know that - // we're in a syntactic context we haven't handled yet. - break; - + // we're in a syntactic context we haven't handled yet. + break; + case Sema::NC_Type: Tok.setKind(tok::annot_typename); setTypeAnnotation(Tok, Classification.getType()); Tok.setAnnotationEndLoc(NameLoc); PP.AnnotateCachedTokens(Tok); break; - + case Sema::NC_Expression: Tok.setKind(tok::annot_primary_expr); setExprAnnotation(Tok, Classification.getExpression()); Tok.setAnnotationEndLoc(NameLoc); PP.AnnotateCachedTokens(Tok); break; - + case Sema::NC_TypeTemplate: case Sema::NC_FunctionTemplate: { ConsumeToken(); // the identifier UnqualifiedId Id; Id.setIdentifier(Name, NameLoc); if (AnnotateTemplateIdToken( - TemplateTy::make(Classification.getTemplateName()), + TemplateTy::make(Classification.getTemplateName()), Classification.getTemplateNameKind(), SS, Id, SourceLocation(), /*AllowTypeAnnotation=*/false)) { @@ -177,10 +177,10 @@ Retry: SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true); if (Tok.is(tok::semi)) ConsumeToken(); - return StmtError(); + return StmtError(); } - - // If the next token is '::', jump right into parsing a + + // If the next token is '::', jump right into parsing a // nested-name-specifier. We don't want to leave the template-id // hanging. if (NextToken().is(tok::coloncolon) && TryAnnotateCXXScopeToken(false)){ @@ -189,22 +189,22 @@ Retry: SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true); if (Tok.is(tok::semi)) ConsumeToken(); - return StmtError(); + return StmtError(); } - + // We've annotated a template-id, so try again now. goto Retry; } - + case Sema::NC_NestedNameSpecifier: // FIXME: Implement this! break; } } - + // Fall through } - + default: { if ((getLang().CPlusPlus || !OnlyStatement) && isDeclarationStatement()) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; @@ -300,7 +300,7 @@ Retry: StmtResult Parser::ParseExprStatement(ParsedAttributes &Attrs) { // If a case keyword is missing, this is where it should be inserted. Token OldToken = Tok; - + // FIXME: Use the attributes // expression[opt] ';' ExprResult Expr(ParseExpression()); @@ -313,18 +313,18 @@ StmtResult Parser::ParseExprStatement(ParsedAttributes &Attrs) { ConsumeToken(); return StmtError(); } - + if (Tok.is(tok::colon) && getCurScope()->isSwitchScope() && Actions.CheckCaseExpression(Expr.get())) { // If a constant expression is followed by a colon inside a switch block, // suggest a missing case keyword. Diag(OldToken, diag::err_expected_case_before_expression) << FixItHint::CreateInsertion(OldToken.getLocation(), "case "); - + // Recover parsing as a case statement. return ParseCaseStatement(Attrs, /*MissingCase=*/true, Expr); } - + // Otherwise, eat the semicolon. ExpectAndConsumeSemi(diag::err_expected_semi_after_expr); return Actions.ActOnExprStmt(Actions.MakeFullExpr(Expr.get())); @@ -461,12 +461,12 @@ StmtResult Parser::ParseLabeledStatement(ParsedAttributes &attrs) { // Broken substmt shouldn't prevent the label from being added to the AST. if (SubStmt.isInvalid()) SubStmt = Actions.ActOnNullStmt(ColonLoc); - + LabelDecl *LD = Actions.LookupOrCreateLabel(IdentTok.getIdentifierInfo(), IdentTok.getLocation()); if (AttributeList *Attrs = attrs.getList()) Actions.ProcessDeclAttributeList(Actions.CurScope, LD, Attrs); - + return Actions.ActOnLabelStmt(IdentTok.getLocation(), LD, ColonLoc, SubStmt.get()); } @@ -515,12 +515,12 @@ StmtResult Parser::ParseCaseStatement(ParsedAttributes &attrs, bool MissingCase, cutOffParsing(); return StmtError(); } - + /// We don't want to treat 'case x : y' as a potential typo for 'case x::y'. /// Disable this form of error recovery while we're parsing the case /// expression. ColonProtectionRAIIObject ColonProtection(*this); - + ExprResult LHS(MissingCase ? Expr : ParseConstantExpression()); MissingCase = false; if (LHS.isInvalid()) { @@ -541,7 +541,7 @@ StmtResult Parser::ParseCaseStatement(ParsedAttributes &attrs, bool MissingCase, return StmtError(); } } - + ColonProtection.restore(); if (Tok.is(tok::colon)) { @@ -558,7 +558,7 @@ StmtResult Parser::ParseCaseStatement(ParsedAttributes &attrs, bool MissingCase, << FixItHint::CreateInsertion(ExpectedLoc, ":"); ColonLoc = ExpectedLoc; } - + StmtResult Case = Actions.ActOnCaseStmt(CaseLoc, LHS.get(), DotDotDotLoc, RHS.get(), ColonLoc); @@ -635,7 +635,7 @@ StmtResult Parser::ParseDefaultStatement(ParsedAttributes &attrs) { << FixItHint::CreateInsertion(ExpectedLoc, ":"); ColonLoc = ExpectedLoc; } - + // Diagnose the common error "switch (X) {... default: }", which is not valid. if (Tok.is(tok::r_brace)) { SourceLocation AfterColonLoc = PP.getLocForEndOfToken(ColonLoc); @@ -708,7 +708,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { Tok.getLocation(), "in compound statement ('{}')"); InMessageExpressionRAIIObject InMessage(*this, false); - + SourceLocation LBraceLoc = ConsumeBrace(); // eat the '{'. StmtVector Stmts(Actions); @@ -718,33 +718,33 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { while (Tok.is(tok::kw___label__)) { SourceLocation LabelLoc = ConsumeToken(); Diag(LabelLoc, diag::ext_gnu_local_label); - + SmallVector DeclsInGroup; while (1) { if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); break; } - + IdentifierInfo *II = Tok.getIdentifierInfo(); SourceLocation IdLoc = ConsumeToken(); DeclsInGroup.push_back(Actions.LookupOrCreateLabel(II, IdLoc, LabelLoc)); - + if (!Tok.is(tok::comma)) break; ConsumeToken(); } - + DeclSpec DS(AttrFactory); DeclGroupPtrTy Res = Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup.data(), DeclsInGroup.size()); StmtResult R = Actions.ActOnDeclStmt(Res, LabelLoc, Tok.getLocation()); - + ExpectAndConsume(tok::semi, diag::err_expected_semi_declaration); if (R.isUsable()) Stmts.push_back(R.release()); } - + while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) { if (Tok.is(tok::annot_pragma_unused)) { HandlePragmaUnused(); @@ -832,12 +832,12 @@ bool Parser::ParseParenExprOrCondition(ExprResult &ExprResult, SourceLocation Loc, bool ConvertToBoolean) { SourceLocation LParenLoc = ConsumeParen(); - if (getLang().CPlusPlus) + if (getLang().CPlusPlus) ParseCXXCondition(ExprResult, DeclResult, Loc, ConvertToBoolean); else { ExprResult = ParseExpression(); DeclResult = 0; - + // If required, convert to a boolean value. if (!ExprResult.isInvalid() && ConvertToBoolean) ExprResult @@ -954,7 +954,7 @@ StmtResult Parser::ParseIfStatement(ParsedAttributes &attrs) { C99orCXX && Tok.isNot(tok::l_brace)); ElseStmt = ParseStatement(); - + // Pop the 'else' scope if needed. InnerScope.Exit(); } else if (Tok.is(tok::code_completion)) { @@ -1035,7 +1035,7 @@ StmtResult Parser::ParseSwitchStatement(ParsedAttributes &attrs) { = Actions.ActOnStartOfSwitchStmt(SwitchLoc, Cond.get(), CondVar); if (Switch.isInvalid()) { - // Skip the switch body. + // Skip the switch body. // FIXME: This is not optimal recovery, but parsing the body is more // dangerous due to the presence of case and default statements, which // will have no place to connect back with the switch. @@ -1046,7 +1046,7 @@ StmtResult Parser::ParseSwitchStatement(ParsedAttributes &attrs) { SkipUntil(tok::semi); return move(Switch); } - + // C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if // there is no compound stmt. C90 does not have this clause. We only do this // if the body isn't a compound statement to avoid push/pop in common cases. @@ -1071,7 +1071,7 @@ StmtResult Parser::ParseSwitchStatement(ParsedAttributes &attrs) { if (Body.isInvalid()) // FIXME: Remove the case statement list from the Switch statement. Body = Actions.ActOnNullStmt(Tok.getLocation()); - + return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.get(), Body.get()); } @@ -1284,15 +1284,15 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { ForRangeInit ForRangeInit; FullExprArg ThirdPart(Actions); Decl *SecondVar = 0; - + if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(getCurScope(), + Actions.CodeCompleteOrdinaryName(getCurScope(), C99orCXXorObjC? Sema::PCC_ForInit : Sema::PCC_Expression); cutOffParsing(); return StmtError(); } - + // Parse the first part of the for specifier. if (Tok.is(tok::semi)) { // for (; // no first part, eat the ';'. @@ -1311,7 +1311,7 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; StmtVector Stmts(Actions); - DeclGroupPtrTy DG = ParseSimpleDeclaration(Stmts, Declarator::ForContext, + DeclGroupPtrTy DG = ParseSimpleDeclaration(Stmts, Declarator::ForContext, DeclEnd, attrs, false, MightBeForRangeStmt ? &ForRangeInit : 0); @@ -1328,7 +1328,7 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { Actions.ActOnForEachDeclStmt(DG); // ObjC: for (id x in expr) ConsumeToken(); // consume 'in' - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCForCollection(getCurScope(), DG); cutOffParsing(); @@ -1355,7 +1355,7 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { ConsumeToken(); } else if (ForEach) { ConsumeToken(); // consume 'in' - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCForCollection(getCurScope(), DeclGroupPtrTy()); cutOffParsing(); @@ -1387,7 +1387,7 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { else { Second = ParseExpression(); if (!Second.isInvalid()) - Second = Actions.ActOnBooleanCondition(getCurScope(), ForLoc, + Second = Actions.ActOnBooleanCondition(getCurScope(), ForLoc, Second.get()); } SecondPartIsInvalid = Second.isInvalid(); @@ -1464,7 +1464,7 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { if (ForEach) return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc, FirstPart.take(), - Collection.take(), RParenLoc, + Collection.take(), RParenLoc, Body.take()); if (ForRange) @@ -1553,7 +1553,7 @@ StmtResult Parser::ParseReturnStatement(ParsedAttributes &attrs) { cutOffParsing(); return StmtError(); } - + // FIXME: This is a hack to allow something like C++0x's generalized // initializer lists, but only enough of this feature to allow Clang to // parse libstdc++ 4.5's headers. @@ -1757,7 +1757,7 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) { // We have a simple asm expression like 'asm("foo")'. SourceLocation RParenLoc = ConsumeParen(); return Actions.ActOnAsmStmt(AsmLoc, /*isSimple*/ true, isVolatile, - /*NumOutputs*/ 0, /*NumInputs*/ 0, 0, + /*NumOutputs*/ 0, /*NumInputs*/ 0, 0, move_arg(Constraints), move_arg(Exprs), AsmString.take(), move_arg(Clobbers), RParenLoc); @@ -1769,12 +1769,12 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) { // In C++ mode, parse "::" like ": :". AteExtraColon = Tok.is(tok::coloncolon); ConsumeToken(); - + if (!AteExtraColon && ParseAsmOperandsOpt(Names, Constraints, Exprs)) return StmtError(); } - + unsigned NumOutputs = Names.size(); // Parse Inputs, if present. @@ -1787,7 +1787,7 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) { AteExtraColon = Tok.is(tok::coloncolon); ConsumeToken(); } - + if (!AteExtraColon && ParseAsmOperandsOpt(Names, Constraints, Exprs)) return StmtError(); @@ -1907,7 +1907,7 @@ Decl *Parser::ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope) { return Actions.ActOnFinishFunctionBody(Decl, 0); } } - + PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc, "parsing function body"); @@ -1942,7 +1942,7 @@ Decl *Parser::ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope) { ParseConstructorInitializer(Decl); else Actions.ActOnDefaultCtorInitializers(Decl); - + if (PP.isCodeCompletionEnabled()) { if (trySkippingFunctionBodyForCodeCompletion()) { BodyScope.Exit(); @@ -2119,7 +2119,7 @@ void Parser::ParseMicrosoftIfExistsStatement(StmtVector &Stmts) { bool Result; if (ParseMicrosoftIfExistsCondition(Result)) return; - + if (Tok.isNot(tok::l_brace)) { Diag(Tok, diag::err_expected_lbrace); return; diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 694d94432f..66cb679372 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -29,14 +29,14 @@ bool TemplateDeclInstantiator::SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl) { if (!OldDecl->getQualifierLoc()) return false; - + NestedNameSpecifierLoc NewQualifierLoc - = SemaRef.SubstNestedNameSpecifierLoc(OldDecl->getQualifierLoc(), + = SemaRef.SubstNestedNameSpecifierLoc(OldDecl->getQualifierLoc(), TemplateArgs); - + if (!NewQualifierLoc) return true; - + NewDecl->setQualifierInfo(NewQualifierLoc); return false; } @@ -45,14 +45,14 @@ bool TemplateDeclInstantiator::SubstQualifier(const TagDecl *OldDecl, TagDecl *NewDecl) { if (!OldDecl->getQualifierLoc()) return false; - + NestedNameSpecifierLoc NewQualifierLoc - = SemaRef.SubstNestedNameSpecifierLoc(OldDecl->getQualifierLoc(), + = SemaRef.SubstNestedNameSpecifierLoc(OldDecl->getQualifierLoc(), TemplateArgs); - + if (!NewQualifierLoc) return true; - + NewDecl->setQualifierInfo(NewQualifierLoc); return false; } @@ -79,7 +79,7 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, else { TypeSourceInfo *Result = SubstType(Aligned->getAlignmentType(), TemplateArgs, - Aligned->getLocation(), + Aligned->getLocation(), DeclarationName()); if (Result) AddAlignedAttr(Aligned->getLocation(), New, Result); @@ -163,13 +163,13 @@ Decl *TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D, newTag->setTypedefNameForAnonDecl(Typedef); } } - + if (TypedefNameDecl *Prev = D->getPreviousDeclaration()) { NamedDecl *InstPrev = SemaRef.FindInstantiatedDecl(D->getLocation(), Prev, TemplateArgs); if (!InstPrev) return 0; - + Typedef->setPreviousDeclaration(cast(InstPrev)); } @@ -228,7 +228,7 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { if (!PrevAliasTemplate) Inst->setInstantiatedFromMemberTemplate(D); - + Owner->addDecl(Inst); return Inst; @@ -285,7 +285,7 @@ bool Sema::InstantiateInitializer(Expr *Init, return false; } } - + ExprResult Result = SubstExpr(Init, TemplateArgs); if (Result.isInvalid()) return true; @@ -315,7 +315,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { << D->isStaticDataMember() << DI->getType(); return 0; } - + // Build the instantiated declaration VarDecl *Var = VarDecl::Create(SemaRef.Context, Owner, D->getInnerLocStart(), @@ -338,12 +338,12 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { Var->setLexicalDeclContext(D->getLexicalDeclContext()); Var->setAccess(D->getAccess()); - + if (!D->isStaticDataMember()) { Var->setUsed(D->isUsed(false)); Var->setReferenced(D->isReferenced()); } - + // FIXME: In theory, we could have a previous declaration for variables that // are not static data members. bool Redeclaration = false; @@ -364,13 +364,13 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var); } SemaRef.InstantiateAttrs(TemplateArgs, D, Var); - + // Link instantiations of static data members back to the template from // which they were instantiated. if (Var->isStaticDataMember()) - SemaRef.Context.setInstantiatedFromStaticDataMember(Var, D, + SemaRef.Context.setInstantiatedFromStaticDataMember(Var, D, TSK_ImplicitInstantiation); - + if (Var->getAnyInitializer()) { // We already have an initializer in the class. } else if (D->getInit()) { @@ -405,7 +405,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { // because of a bogus initializer. Var->setInvalidDecl(); } - + SemaRef.PopExpressionEvaluationContext(); } else if ((!Var->isStaticDataMember() || Var->isOutOfLine()) && !Var->isCXXForRangeDecl()) @@ -485,14 +485,14 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { } SemaRef.InstantiateAttrs(TemplateArgs, D, Field); - + if (Invalid) Field->setInvalidDecl(); if (!Field->getDeclName()) { // Keep track of where this decl came from. SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D); - } + } if (CXXRecordDecl *Parent= dyn_cast(Field->getDeclContext())) { if (Parent->isAnonymousStructOrUnion() && Parent->getRedeclContext()->isFunctionOrMethod()) @@ -514,11 +514,11 @@ Decl *TemplateDeclInstantiator::VisitIndirectFieldDecl(IndirectFieldDecl *D) { for (IndirectFieldDecl::chain_iterator PI = D->chain_begin(), PE = D->chain_end(); PI != PE; ++PI) { - NamedDecl *Next = SemaRef.FindInstantiatedDecl(D->getLocation(), *PI, + NamedDecl *Next = SemaRef.FindInstantiatedDecl(D->getLocation(), *PI, TemplateArgs); if (!Next) return 0; - + NamedChain[i++] = Next; } @@ -556,13 +556,13 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { FriendDecl *FD = SemaRef.CheckFriendTypeDecl(D->getFriendLoc(), InstTy); if (!FD) return 0; - + FD->setAccess(AS_public); FD->setUnsupportedFriend(D->isUnsupportedFriend()); Owner->addDecl(FD); return FD; - } - + } + NamedDecl *ND = D->getFriendDecl(); assert(ND && "friend decl must be a decl or a type!"); @@ -574,7 +574,7 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { if (!NewND) return 0; FriendDecl *FD = - FriendDecl::Create(SemaRef.Context, Owner, D->getLocation(), + FriendDecl::Create(SemaRef.Context, Owner, D->getLocation(), cast(NewND), D->getFriendLoc()); FD->setAccess(AS_public); FD->setUnsupportedFriend(D->isUnsupportedFriend()); @@ -616,7 +616,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { TemplateArgs, UnderlyingLoc, DeclarationName())); - + if (!Enum->getIntegerTypeSourceInfo()) Enum->setIntegerType(SemaRef.Context.IntTy); } @@ -637,7 +637,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { if (D->getDeclContext()->isFunctionOrMethod()) SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum); - + SmallVector Enumerators; EnumConstantDecl *LastEnumConst = 0; @@ -679,7 +679,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Enum->addDecl(EnumConst); Enumerators.push_back(EnumConst); LastEnumConst = EnumConst; - + if (D->getDeclContext()->isFunctionOrMethod()) { // If the enumeration is within a function or method, record the enum // constant as a local. @@ -784,7 +784,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { // template parameters of the original declaration. In this one // case, we don't complain about the ill-formed friend // declaration. - if (isFriend && Pattern->getIdentifier() && + if (isFriend && Pattern->getIdentifier() && Pattern->getIdentifier()->isStr("_Map_base") && DC->isNamespace() && cast(DC)->getIdentifier() && @@ -807,7 +807,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { // Make sure the parameter lists match. if (!SemaRef.TemplateParameterListsAreEqual(InstParams, PrevParams, - Complain, + Complain, Sema::TPL_TemplateMatch)) { if (Complain) return 0; @@ -854,7 +854,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (!PrevClassTemplate) Inst->setInstantiatedFromMemberTemplate(D); } - + // Trigger creation of the type for the instantiation. SemaRef.Context.getInjectedClassNameType(RecordInst, Inst->getInjectedClassNameSpecialization()); @@ -864,7 +864,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { DC->makeDeclVisibleInContext(Inst, /*Recoverable*/ false); return Inst; } - + Owner->addDecl(Inst); if (!PrevClassTemplate) { @@ -885,19 +885,19 @@ Decl * TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl( ClassTemplatePartialSpecializationDecl *D) { ClassTemplateDecl *ClassTemplate = D->getSpecializedTemplate(); - + // Lookup the already-instantiated declaration in the instantiation // of the class template and return that. DeclContext::lookup_result Found = Owner->lookup(ClassTemplate->getDeclName()); if (Found.first == Found.second) return 0; - + ClassTemplateDecl *InstClassTemplate = dyn_cast(*Found.first); if (!InstClassTemplate) return 0; - + if (ClassTemplatePartialSpecializationDecl *Result = InstClassTemplate->findPartialSpecInstantiatedFromMember(D)) return Result; @@ -909,7 +909,7 @@ Decl * TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { // Create a local instantiation scope for this function template, which // will contain the instantiations of the template parameters and then get - // merged with the local instantiation scope for the function template + // merged with the local instantiation scope for the function template // itself. LocalInstantiationScope Scope(SemaRef); @@ -917,16 +917,16 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) return NULL; - + FunctionDecl *Instantiated = 0; if (CXXMethodDecl *DMethod = dyn_cast(D->getTemplatedDecl())) - Instantiated = cast_or_null(VisitCXXMethodDecl(DMethod, + Instantiated = cast_or_null(VisitCXXMethodDecl(DMethod, InstParams)); else Instantiated = cast_or_null(VisitFunctionDecl( - D->getTemplatedDecl(), + D->getTemplatedDecl(), InstParams)); - + if (!Instantiated) return 0; @@ -934,10 +934,10 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { // Link the instantiated function template declaration to the function // template from which it was instantiated. - FunctionTemplateDecl *InstTemplate + FunctionTemplateDecl *InstTemplate = Instantiated->getDescribedFunctionTemplate(); InstTemplate->setAccess(D->getAccess()); - assert(InstTemplate && + assert(InstTemplate && "VisitFunctionDecl/CXXMethodDecl didn't create a template!"); bool isFriend = (InstTemplate->getFriendObjectKind() != Decl::FOK_None); @@ -947,7 +947,7 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { if (!InstTemplate->getInstantiatedFromMemberTemplate() && !(isFriend && !D->getTemplatedDecl()->isThisDeclarationADefinition())) InstTemplate->setInstantiatedFromMemberTemplate(D); - + // Make declarations visible in the appropriate context. if (!isFriend) Owner->addDecl(InstTemplate); @@ -1013,7 +1013,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, FunctionTemplateDecl *FunctionTemplate = D->getDescribedFunctionTemplate(); void *InsertPos = 0; if (FunctionTemplate && !TemplateParams) { - std::pair Innermost + std::pair Innermost = TemplateArgs.getInnermost(); FunctionDecl *SpecFunc @@ -1033,7 +1033,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, bool MergeWithParentScope = (TemplateParams != 0) || Owner->isFunctionOrMethod() || - !(isa(Owner) && + !(isa(Owner) && cast(Owner)->isDefinedOutsideFunctionOrMethod()); LocalInstantiationScope Scope(SemaRef, MergeWithParentScope); @@ -1063,7 +1063,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, DC = SemaRef.computeDeclContext(SS); if (!DC) return 0; } else { - DC = SemaRef.FindInstantiatedContext(D->getLocation(), D->getDeclContext(), + DC = SemaRef.FindInstantiatedContext(D->getLocation(), D->getDeclContext(), TemplateArgs); } @@ -1120,7 +1120,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, // // X x; // - // We are instantiating the friend function template "f" within X, + // We are instantiating the friend function template "f" within X, // which means substituting int for T, but leaving "f" as a friend function // template. // Build the function template itself. @@ -1140,7 +1140,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, } } else if (FunctionTemplate) { // Record this function template specialization. - std::pair Innermost + std::pair Innermost = TemplateArgs.getInnermost(); Function->setFunctionTemplateSpecialization(FunctionTemplate, TemplateArgumentList::CreateCopy(SemaRef.Context, @@ -1156,13 +1156,13 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, // instantiations and modifying them. Function->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation); } - + if (InitFunctionInstantiation(Function, D)) Function->setInvalidDecl(); bool Redeclaration = false; bool isExplicitSpecialization = false; - + LookupResult Previous(SemaRef, Function->getDeclName(), SourceLocation(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); @@ -1194,15 +1194,15 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, &ExplicitArgs, Previous)) Function->setInvalidDecl(); - + isExplicitSpecialization = true; } else if (TemplateParams || !FunctionTemplate) { - // Look only into the namespace where the friend would be declared to - // find a previous declaration. This is the innermost enclosing namespace, + // Look only into the namespace where the friend would be declared to + // find a previous declaration. This is the innermost enclosing namespace, // as described in ActOnFriendFunctionDecl. SemaRef.LookupQualifiedName(Previous, DC); - + // In C++, the previous declaration we find might be a tag type // (class or enum). In this case, the new declaration will hide the // tag type. Note that this does does not apply if we're declaring a @@ -1210,7 +1210,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, if (Previous.isSingleTagDecl()) Previous.clear(); } - + SemaRef.CheckFunctionDeclaration(/*Scope*/ 0, Function, Previous, isExplicitSpecialization, Redeclaration); @@ -1238,11 +1238,11 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, const FunctionDecl *Definition = 0; if (Function->isDefined(Definition) && Definition->getTemplateSpecializationKind() == TSK_Undeclared) { - SemaRef.Diag(Function->getLocation(), diag::err_redefinition) + SemaRef.Diag(Function->getLocation(), diag::err_redefinition) << Function->getDeclName(); SemaRef.Diag(Definition->getLocation(), diag::note_previous_definition); - Function->setInvalidDecl(); - } + Function->setInvalidDecl(); + } // Check for redefinitions due to other instantiations of this or // a similar friend function. else for (FunctionDecl::redecl_iterator R = Function->redecls_begin(), @@ -1269,7 +1269,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, if (const FunctionDecl *RPattern = R->getTemplateInstantiationPattern()) if (RPattern->isDefined(RPattern)) { - SemaRef.Diag(Function->getLocation(), diag::err_redefinition) + SemaRef.Diag(Function->getLocation(), diag::err_redefinition) << Function->getDeclName(); SemaRef.Diag(R->getLocation(), diag::note_previous_definition); Function->setInvalidDecl(); @@ -1298,7 +1298,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, // We are creating a function template specialization from a function // template. Check whether there is already a function template // specialization for this particular set of template arguments. - std::pair Innermost + std::pair Innermost = TemplateArgs.getInnermost(); FunctionDecl *SpecFunc @@ -1317,7 +1317,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, isFriend = (D->getFriendObjectKind() != Decl::FOK_None); bool MergeWithParentScope = (TemplateParams != 0) || - !(isa(Owner) && + !(isa(Owner) && cast(Owner)->isDefinedOutsideFunctionOrMethod()); LocalInstantiationScope Scope(SemaRef, MergeWithParentScope); @@ -1354,17 +1354,17 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, if (!isa(T.IgnoreParens())) { assert(!Params.size() && "Instantiating type could not yield parameters"); SmallVector ParamTypes; - if (SemaRef.SubstParmTypes(D->getLocation(), D->param_begin(), - D->getNumParams(), TemplateArgs, ParamTypes, + if (SemaRef.SubstParmTypes(D->getLocation(), D->param_begin(), + D->getNumParams(), TemplateArgs, ParamTypes, &Params)) - return 0; + return 0; } NestedNameSpecifierLoc QualifierLoc = D->getQualifierLoc(); if (QualifierLoc) { QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc, TemplateArgs); - if (!QualifierLoc) + if (!QualifierLoc) return 0; } @@ -1448,7 +1448,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Method->setDescribedFunctionTemplate(FunctionTemplate); } else if (FunctionTemplate) { // Record this function template specialization. - std::pair Innermost + std::pair Innermost = TemplateArgs.getInnermost(); Method->setFunctionTemplateSpecialization(FunctionTemplate, TemplateArgumentList::CreateCopy(SemaRef.Context, @@ -1459,7 +1459,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, // Record that this is an instantiation of a member function. Method->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation); } - + // If we are instantiating a member function defined // out-of-line, the instantiation will have the same lexical // context (which will be a namespace scope) as the template. @@ -1561,14 +1561,14 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl( D->wasDeclaredWithTypename(), D->isParameterPack()); Inst->setAccess(AS_public); - + if (D->hasDefaultArgument()) - Inst->setDefaultArgument(D->getDefaultArgumentInfo(), false); + Inst->setDefaultArgument(D->getDefaultArgumentInfo(), false); - // Introduce this template parameter's instantiation into the instantiation + // Introduce this template parameter's instantiation into the instantiation // scope. SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Inst); - + return Inst; } @@ -1579,23 +1579,23 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( SmallVector ExpandedParameterPackTypesAsWritten; SmallVector ExpandedParameterPackTypes; bool IsExpandedParameterPack = false; - TypeSourceInfo *DI; + TypeSourceInfo *DI; QualType T; bool Invalid = false; if (D->isExpandedParameterPack()) { - // The non-type template parameter pack is an already-expanded pack + // The non-type template parameter pack is an already-expanded pack // expansion of types. Substitute into each of the expanded types. ExpandedParameterPackTypes.reserve(D->getNumExpansionTypes()); ExpandedParameterPackTypesAsWritten.reserve(D->getNumExpansionTypes()); for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { TypeSourceInfo *NewDI =SemaRef.SubstType(D->getExpansionTypeSourceInfo(I), TemplateArgs, - D->getLocation(), + D->getLocation(), D->getDeclName()); if (!NewDI) return 0; - + ExpandedParameterPackTypesAsWritten.push_back(NewDI); QualType NewT =SemaRef.CheckNonTypeTemplateParameterType(NewDI->getType(), D->getLocation()); @@ -1603,7 +1603,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( return 0; ExpandedParameterPackTypes.push_back(NewT); } - + IsExpandedParameterPack = true; DI = D->getTypeSourceInfo(); T = DI->getType(); @@ -1615,7 +1615,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( TypeLoc Pattern = Expansion.getPatternLoc(); SmallVector Unexpanded; SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded); - + // Determine whether the set of unexpanded parameter packs can and should // be expanded. bool Expand = true; @@ -1627,19 +1627,19 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( Pattern.getSourceRange(), Unexpanded, TemplateArgs, - Expand, RetainExpansion, + Expand, RetainExpansion, NumExpansions)) return 0; - + if (Expand) { for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I); TypeSourceInfo *NewDI = SemaRef.SubstType(Pattern, TemplateArgs, - D->getLocation(), + D->getLocation(), D->getDeclName()); if (!NewDI) return 0; - + ExpandedParameterPackTypesAsWritten.push_back(NewDI); QualType NewT = SemaRef.CheckNonTypeTemplateParameterType( NewDI->getType(), @@ -1648,7 +1648,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( return 0; ExpandedParameterPackTypes.push_back(NewT); } - + // Note that we have an expanded parameter pack. The "type" of this // expanded parameter pack is the original expansion type, but callers // will end up using the expanded parameter pack types for type-checking. @@ -1660,62 +1660,62 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( // pattern and create a new pack expansion type. Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, -1); TypeSourceInfo *NewPattern = SemaRef.SubstType(Pattern, TemplateArgs, - D->getLocation(), + D->getLocation(), D->getDeclName()); if (!NewPattern) return 0; - + DI = SemaRef.CheckPackExpansion(NewPattern, Expansion.getEllipsisLoc(), NumExpansions); if (!DI) return 0; - + T = DI->getType(); } } else { // Simple case: substitution into a parameter that is not a parameter pack. - DI = SemaRef.SubstType(D->getTypeSourceInfo(), TemplateArgs, + DI = SemaRef.SubstType(D->getTypeSourceInfo(), TemplateArgs, D->getLocation(), D->getDeclName()); if (!DI) return 0; - + // Check that this type is acceptable for a non-type template parameter. - T = SemaRef.CheckNonTypeTemplateParameterType(DI->getType(), + T = SemaRef.CheckNonTypeTemplateParameterType(DI->getType(), D->getLocation()); if (T.isNull()) { T = SemaRef.Context.IntTy; Invalid = true; } } - + NonTypeTemplateParmDecl *Param; if (IsExpandedParameterPack) - Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner, + Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(), - D->getDepth() - TemplateArgs.getNumLevels(), - D->getPosition(), + D->getDepth() - TemplateArgs.getNumLevels(), + D->getPosition(), D->getIdentifier(), T, DI, ExpandedParameterPackTypes.data(), ExpandedParameterPackTypes.size(), ExpandedParameterPackTypesAsWritten.data()); else - Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner, + Param = NonTypeTemplateParmDecl::Create(SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(), - D->getDepth() - TemplateArgs.getNumLevels(), - D->getPosition(), - D->getIdentifier(), T, + D->getDepth() - TemplateArgs.getNumLevels(), + D->getPosition(), + D->getIdentifier(), T, D->isParameterPack(), DI); - + Param->setAccess(AS_public); if (Invalid) Param->setInvalidDecl(); - + Param->setDefaultArgument(D->getDefaultArgument(), false); - - // Introduce this template parameter's instantiation into the instantiation + + // Introduce this template parameter's instantiation into the instantiation // scope. SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param); return Param; @@ -1734,34 +1734,34 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( InstParams = SubstTemplateParams(TempParams); if (!InstParams) return NULL; - } - + } + // Build the template template parameter. TemplateTemplateParmDecl *Param = TemplateTemplateParmDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getDepth() - TemplateArgs.getNumLevels(), - D->getPosition(), D->isParameterPack(), + D->getDepth() - TemplateArgs.getNumLevels(), + D->getPosition(), D->isParameterPack(), D->getIdentifier(), InstParams); Param->setDefaultArgument(D->getDefaultArgument(), false); Param->setAccess(AS_public); - - // Introduce this template parameter's instantiation into the instantiation + + // Introduce this template parameter's instantiation into the instantiation // scope. SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param); - + return Param; } Decl *TemplateDeclInstantiator::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { // Using directives are never dependent (and never contain any types or // expressions), so they require no explicit instantiation work. - + UsingDirectiveDecl *Inst = UsingDirectiveDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getNamespaceKeyLocation(), + D->getNamespaceKeyLocation(), D->getQualifierLoc(), - D->getIdentLocation(), - D->getNominatedNamespace(), + D->getIdentLocation(), + D->getNominatedNamespace(), D->getCommonAncestor()); Owner->addDecl(Inst); return Inst; @@ -1865,7 +1865,7 @@ Decl *TemplateDeclInstantiator::VisitUsingShadowDecl(UsingShadowDecl *D) { Decl * TemplateDeclInstantiator ::VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) { NestedNameSpecifierLoc QualifierLoc - = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), + = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), TemplateArgs); if (!QualifierLoc) return 0; @@ -1893,7 +1893,7 @@ Decl * TemplateDeclInstantiator = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), TemplateArgs); if (!QualifierLoc) return 0; - + CXXScopeSpec SS; SS.Adopt(QualifierLoc); @@ -1976,13 +1976,13 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) { return InstL; } -/// \brief Instantiate the declaration of a class template partial +/// \brief Instantiate the declaration of a class template partial /// specialization. /// /// \param ClassTemplate the (instantiated) class template that is partially // specialized by the instantiation of \p PartialSpec. /// -/// \param PartialSpec the (uninstantiated) class template partial +/// \param PartialSpec the (uninstantiated) class template partial /// specialization that we are instantiating. /// /// \returns The instantiated partial specialization, if successful; otherwise, @@ -1995,28 +1995,28 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( // specialization, which will contain the instantiations of the template // parameters. LocalInstantiationScope Scope(SemaRef); - + // Substitute into the template parameters of the class template partial // specialization. TemplateParameterList *TempParams = PartialSpec->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) return 0; - + // Substitute into the template arguments of the class template partial // specialization. TemplateArgumentListInfo InstTemplateArgs; // no angle locations - if (SemaRef.Subst(PartialSpec->getTemplateArgsAsWritten(), - PartialSpec->getNumTemplateArgsAsWritten(), + if (SemaRef.Subst(PartialSpec->getTemplateArgsAsWritten(), + PartialSpec->getNumTemplateArgsAsWritten(), InstTemplateArgs, TemplateArgs)) return 0; - + // Check that the template argument list is well-formed for this // class template. SmallVector Converted; - if (SemaRef.CheckTemplateArgumentList(ClassTemplate, + if (SemaRef.CheckTemplateArgumentList(ClassTemplate, PartialSpec->getLocation(), - InstTemplateArgs, + InstTemplateArgs, false, Converted)) return 0; @@ -2027,10 +2027,10 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( ClassTemplateSpecializationDecl *PrevDecl = ClassTemplate->findPartialSpecialization(Converted.data(), Converted.size(), InsertPos); - + // Build the canonical type that describes the converted template // arguments of the class template partial specialization. - QualType CanonType + QualType CanonType = SemaRef.Context.getTemplateSpecializationType(TemplateName(ClassTemplate), Converted.data(), Converted.size()); @@ -2048,7 +2048,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( PartialSpec->getLocation(), InstTemplateArgs, CanonType); - + if (PrevDecl) { // We've already seen a partial specialization with the same template // parameters and template arguments. This can happen, for example, when @@ -2071,17 +2071,17 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( << SemaRef.Context.getTypeDeclType(PrevDecl); return 0; } - - + + // Create the class template partial specialization declaration. ClassTemplatePartialSpecializationDecl *InstPartialSpec - = ClassTemplatePartialSpecializationDecl::Create(SemaRef.Context, + = ClassTemplatePartialSpecializationDecl::Create(SemaRef.Context, PartialSpec->getTagKind(), - Owner, + Owner, PartialSpec->getLocStart(), PartialSpec->getLocation(), InstParams, - ClassTemplate, + ClassTemplate, Converted.data(), Converted.size(), InstTemplateArgs, @@ -2094,7 +2094,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( InstPartialSpec->setInstantiatedFromMember(PartialSpec); InstPartialSpec->setTypeAsWritten(WrittenTy); - + // Add this partial specialization to the set of class template partial // specializations. ClassTemplate->AddPartialSpecialization(InstPartialSpec, InsertPos); @@ -2129,7 +2129,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, if (!OldParam->isParameterPack() || (NewIdx < NumNewParams && NewProtoLoc->getArg(NewIdx)->isParameterPack())) { - // Simple case: normal parameter, or a parameter pack that's + // Simple case: normal parameter, or a parameter pack that's // instantiated to a (still-dependent) parameter pack. ParmVarDecl *NewParam = NewProtoLoc->getArg(NewIdx++); Params.push_back(NewParam); @@ -2137,7 +2137,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, NewParam); continue; } - + // Parameter pack: make the instantiation an argument pack. SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack( OldParam); @@ -2218,33 +2218,33 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, SmallVector Unexpanded; SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(), Unexpanded); - assert(!Unexpanded.empty() && + assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); bool Expand = false; bool RetainExpansion = false; llvm::Optional NumExpansions = PackExpansion->getNumExpansions(); - if (SemaRef.CheckParameterPacksForExpansion(New->getLocation(), + if (SemaRef.CheckParameterPacksForExpansion(New->getLocation(), SourceRange(), Unexpanded, TemplateArgs, - Expand, + Expand, RetainExpansion, NumExpansions)) break; if (!Expand) { // We can't expand this pack expansion into separate arguments yet; - // just substitute into the pattern and create a new pack expansion + // just substitute into the pattern and create a new pack expansion // type. Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, -1); - QualType T = SemaRef.SubstType(PackExpansion->getPattern(), + QualType T = SemaRef.SubstType(PackExpansion->getPattern(), TemplateArgs, New->getLocation(), New->getDeclName()); if (T.isNull()) break; - + T = SemaRef.Context.getPackExpansionType(T, NumExpansions); Exceptions.push_back(T); continue; @@ -2254,8 +2254,8 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, bool Invalid = false; for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, ArgIdx); - - QualType T = SemaRef.SubstType(PackExpansion->getPattern(), + + QualType T = SemaRef.SubstType(PackExpansion->getPattern(), TemplateArgs, New->getLocation(), New->getDeclName()); if (T.isNull()) { @@ -2271,11 +2271,11 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, continue; } - + QualType T = SemaRef.SubstType(Proto->getExceptionType(I), TemplateArgs, New->getLocation(), New->getDeclName()); - if (T.isNull() || + if (T.isNull() || SemaRef.CheckSpecifiedExceptionType(T, New->getLocation())) continue; @@ -2289,7 +2289,7 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, NoexceptExpr = E.take(); } - // Rebuild the function type + // Rebuild the function type FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); EPI.ExceptionSpecType = Proto->getExceptionSpecType(); @@ -2395,7 +2395,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, } // Call the LateTemplateParser callback if there a need to late parse - // a templated function definition. + // a templated function definition. if (!Pattern && PatternDecl->isLateTemplateParsed() && LateTemplateParser) { LateTemplateParser(OpaqueParser, PatternDecl); @@ -2405,16 +2405,16 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (!Pattern && !PatternDecl->isDefaulted()) { if (DefinitionRequired) { if (Function->getPrimaryTemplate()) - Diag(PointOfInstantiation, + Diag(PointOfInstantiation, diag::err_explicit_instantiation_undefined_func_template) << Function->getPrimaryTemplate(); else - Diag(PointOfInstantiation, + Diag(PointOfInstantiation, diag::err_explicit_instantiation_undefined_member) << 1 << Function->getDeclName() << Function->getDeclContext(); - + if (PatternDecl) - Diag(PatternDecl->getLocation(), + Diag(PatternDecl->getLocation(), diag::note_explicit_instantiation_here); Function->setInvalidDecl(); } else if (Function->getTemplateSpecializationKind() @@ -2437,8 +2437,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, InstantiatingTemplate Inst(*this, PointOfInstantiation, Function); if (Inst) - return; - + return; + // If we're performing recursive template instantiation, create our own // queue of pending implicit instantiations that we will instantiate later, // while we're still within our own instantiation context. @@ -2449,7 +2449,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, PendingInstantiations.swap(SavedPendingInstantiations); } - EnterExpressionEvaluationContext EvalContext(*this, + EnterExpressionEvaluationContext EvalContext(*this, Sema::PotentiallyEvaluated); ActOnStartOfFunctionDef(0, Function); @@ -2478,11 +2478,11 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, ++FParamIdx; continue; } - + // Expand the parameter pack. Scope.MakeInstantiatedLocalArgPack(PatternParam); - for (unsigned NumFParams = Function->getNumParams(); - FParamIdx < NumFParams; + for (unsigned NumFParams = Function->getNumParams(); + FParamIdx < NumFParams; ++FParamIdx) { ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx); FunctionParam->setDeclName(PatternParam->getDeclName()); @@ -2514,7 +2514,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (Body.isInvalid()) Function->setInvalidDecl(); - + ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true); } @@ -2578,7 +2578,7 @@ void Sema::InstantiateStaticDataMemberDefinition( // Find the out-of-line definition of this static data member. VarDecl *Def = Var->getInstantiatedFromStaticDataMember(); assert(Def && "This data member was not instantiated from a template?"); - assert(Def->isStaticDataMember() && "Not a static data member?"); + assert(Def->isStaticDataMember() && "Not a static data member?"); Def = Def->getOutOfLineDefinition(); if (!Def) { @@ -2588,7 +2588,7 @@ void Sema::InstantiateStaticDataMemberDefinition( // another translation unit. if (DefinitionRequired) { Def = Var->getInstantiatedFromStaticDataMember(); - Diag(PointOfInstantiation, + Diag(PointOfInstantiation, diag::err_explicit_instantiation_undefined_member) << 2 << Var->getDeclName() << Var->getDeclContext(); Diag(Def->getLocation(), diag::note_explicit_instantiation_here); @@ -2604,12 +2604,12 @@ void Sema::InstantiateStaticDataMemberDefinition( // Never instantiate an explicit specialization. if (Var->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) return; - + // C++0x [temp.explicit]p9: // Except for inline functions, other explicit instantiation declarations // have the effect of suppressing the implicit instantiation of the entity // to which they refer. - if (Var->getTemplateSpecializationKind() + if (Var->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDeclaration) return; @@ -2692,7 +2692,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, SmallVector NewInits; bool AnyErrors = false; - + // Instantiate all the initializers. for (CXXConstructorDecl::init_const_iterator Inits = Tmpl->init_begin(), InitsEnd = Tmpl->init_end(); @@ -2708,7 +2708,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, ASTOwningVector NewArgs(*this); SourceLocation EllipsisLoc; - + if (Init->isPackExpansion()) { // This is a pack expansion. We should expand it now. TypeLoc BaseTL = Init->getBaseClassInfo()->getTypeLoc(); @@ -2717,10 +2717,10 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, bool ShouldExpand = false; bool RetainExpansion = false; llvm::Optional NumExpansions; - if (CheckParameterPacksForExpansion(Init->getEllipsisLoc(), + if (CheckParameterPacksForExpansion(Init->getEllipsisLoc(), BaseTL.getSourceRange(), Unexpanded, - TemplateArgs, ShouldExpand, + TemplateArgs, ShouldExpand, RetainExpansion, NumExpansions)) { AnyErrors = true; @@ -2728,22 +2728,22 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, continue; } assert(ShouldExpand && "Partial instantiation of base initializer?"); - - // Loop over all of the arguments in the argument pack(s), + + // Loop over all of the arguments in the argument pack(s), for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I); // Instantiate the initializer. - if (InstantiateInitializer(Init->getInit(), TemplateArgs, + if (InstantiateInitializer(Init->getInit(), TemplateArgs, LParenLoc, NewArgs, RParenLoc)) { AnyErrors = true; break; } // Instantiate the base type. - TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), - TemplateArgs, - Init->getSourceLocation(), + TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), + TemplateArgs, + Init->getSourceLocation(), New->getDeclName()); if (!BaseTInfo) { AnyErrors = true; @@ -2760,26 +2760,26 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, AnyErrors = true; break; } - + NewInits.push_back(NewInit.get()); NewArgs.clear(); } - + continue; } // Instantiate the initializer. - if (InstantiateInitializer(Init->getInit(), TemplateArgs, + if (InstantiateInitializer(Init->getInit(), TemplateArgs, LParenLoc, NewArgs, RParenLoc)) { AnyErrors = true; continue; } - + MemInitResult NewInit; if (Init->isBaseInitializer()) { - TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), - TemplateArgs, - Init->getSourceLocation(), + TypeSourceInfo *BaseTInfo = SubstType(Init->getBaseClassInfo(), + TemplateArgs, + Init->getSourceLocation(), New->getDeclName()); if (!BaseTInfo) { AnyErrors = true; @@ -2858,20 +2858,20 @@ static bool isInstantiationOf(ClassTemplateDecl *Pattern, static bool isInstantiationOf(FunctionTemplateDecl *Pattern, FunctionTemplateDecl *Instance) { Pattern = Pattern->getCanonicalDecl(); - + do { Instance = Instance->getCanonicalDecl(); if (Pattern == Instance) return true; Instance = Instance->getInstantiatedFromMemberTemplate(); } while (Instance); - + return false; } -static bool +static bool isInstantiationOf(ClassTemplatePartialSpecializationDecl *Pattern, ClassTemplatePartialSpecializationDecl *Instance) { - Pattern + Pattern = cast(Pattern->getCanonicalDecl()); do { Instance = cast( @@ -2880,7 +2880,7 @@ isInstantiationOf(ClassTemplatePartialSpecializationDecl *Pattern, return true; Instance = Instance->getInstantiatedFromMember(); } while (Instance); - + return false; } @@ -3086,11 +3086,11 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; llvm::PointerUnion *Found = CurrentInstantiationScope->findInstantiationOf(D); - + if (Found) { if (Decl *FD = Found->dyn_cast()) return cast(FD); - + unsigned PackIdx = ArgumentPackSubstitutionIndex; return cast((*Found->get())[PackIdx]); } @@ -3098,10 +3098,10 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, // If we didn't find the decl, then we must have a label decl that hasn't // been found yet. Lazily instantiate it and return it now. assert(isa(D)); - + Decl *Inst = SubstDecl(D, CurContext, TemplateArgs); assert(Inst && "Failed to instantiate label??"); - + CurrentInstantiationScope->InstantiatedLocal(D, Inst); return cast(Inst); } @@ -3109,7 +3109,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, if (CXXRecordDecl *Record = dyn_cast(D)) { if (!Record->isDependentContext()) return D; - + // If the RecordDecl is actually the injected-class-name or a // "templated" declaration for a class template, class template // partial specialization, or a member class of a class template, @@ -3117,7 +3117,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, // or partial specialization to find the new DeclContext. QualType T; ClassTemplateDecl *ClassTemplate = Record->getDescribedClassTemplate(); - + if (ClassTemplate) { T = ClassTemplate->getInjectedClassNameSpecialization(); } else if (ClassTemplatePartialSpecializationDecl *PartialSpec @@ -3130,26 +3130,26 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, assert(isa(T) && "type of partial specialization is not an InjectedClassNameType"); T = cast(T)->getInjectedSpecializationType(); - } - + } + if (!T.isNull()) { // Substitute into the injected-class-name to get the type // corresponding to the instantiation we want, which may also be // the current instantiation (if we're in a template // definition). This substitution should never fail, since we // know we can instantiate the injected-class-name or we - // wouldn't have gotten to the injected-class-name! + // wouldn't have gotten to the injected-class-name! // FIXME: Can we use the CurrentInstantiationScope to avoid this // extra instantiation in the common case? T = SubstType(T, TemplateArgs, Loc, DeclarationName()); assert(!T.isNull() && "Instantiation of injected-class-name cannot fail."); - + if (!T->isDependentType()) { assert(T->isRecordType() && "Instantiation must produce a record type"); return T->getAs()->getDecl(); } - + // We are performing "partial" template instantiation to create // the member declarations for the members of a class template // specialization. Therefore, D is actually referring to something @@ -3162,7 +3162,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, DC = DC->getParent()) { if (ClassTemplateSpecializationDecl *Spec = dyn_cast(DC)) - if (isInstantiationOf(ClassTemplate, + if (isInstantiationOf(ClassTemplate, Spec->getSpecializedTemplate())) return Spec; @@ -3173,10 +3173,10 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, // We're performing "instantiation" of a member of the current // instantiation while we are type-checking the // definition. Compute the declaration context and return that. - assert(!SawNonDependentContext && + assert(!SawNonDependentContext && "No dependent context while instantiating record"); DeclContext *DC = computeDeclContext(T); - assert(DC && + assert(DC && "Unable to find declaration for the current instantiation"); return cast(DC); } @@ -3187,7 +3187,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, if (!ParentDC->isDependentContext()) return D; - + ParentDC = FindInstantiatedContext(Loc, ParentDC, TemplateArgs); if (!ParentDC) return 0; @@ -3241,7 +3241,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, // declaration failed to instantiate. There's no point in complaining // further, since this is normal in invalid code. } else if (IsBeingInstantiated) { - // The class in which this member exists is currently being + // The class in which this member exists is currently being // instantiated, and we haven't gotten around to instantiating this // member yet. This can happen when the code uses forward declarations // of member classes, and introduces ordering dependencies via @@ -3255,7 +3255,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, llvm_unreachable("Unable to find instantiation of declaration!"); } } - + D = Result; } @@ -3272,7 +3272,7 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) { PendingInstantiations.insert(PendingInstantiations.begin(), Pending.begin(), Pending.end()); } - + while (!PendingLocalImplicitInstantiations.empty() || (!LocalOnly && !PendingInstantiations.empty())) { PendingImplicitInstantiation Inst; -- 2.50.1