diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-19 02:28:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-19 02:28:17 +0000 |
commit | cb444fe73933566646ab90aa515c6aadd9493ed4 (patch) | |
tree | 5b4b699180fddb676fabee8ba7178d0ad7f71c10 /clang/lib/AST/DeclTemplate.cpp | |
parent | 3f9e4442c87dad290e7bdcabc5db1e3fab8f3da8 (diff) | |
download | bcm5719-llvm-cb444fe73933566646ab90aa515c6aadd9493ed4.tar.gz bcm5719-llvm-cb444fe73933566646ab90aa515c6aadd9493ed4.zip |
Reduce indentation with an early exit.
llvm-svn: 193028
Diffstat (limited to 'clang/lib/AST/DeclTemplate.cpp')
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 5007eea0c78..7172fb7b487 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -129,33 +129,34 @@ static void AdoptTemplateParameterList(TemplateParameterList *Params, //===----------------------------------------------------------------------===// RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() const { - if (!Common) { - // Walk the previous-declaration chain until we either find a declaration - // with a common pointer or we run out of previous declarations. - SmallVector<const RedeclarableTemplateDecl *, 2> PrevDecls; - for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev; - Prev = Prev->getPreviousDecl()) { - if (Prev->Common) { - Common = Prev->Common; - break; - } - - PrevDecls.push_back(Prev); + if (Common) + return Common; + + // Walk the previous-declaration chain until we either find a declaration + // with a common pointer or we run out of previous declarations. + SmallVector<const RedeclarableTemplateDecl *, 2> PrevDecls; + for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev; + Prev = Prev->getPreviousDecl()) { + if (Prev->Common) { + Common = Prev->Common; + break; } - // If we never found a common pointer, allocate one now. - if (!Common) { - // FIXME: If any of the declarations is from an AST file, we probably - // need an update record to add the common data. - - Common = newCommon(getASTContext()); - } - - // Update any previous declarations we saw with the common pointer. - for (unsigned I = 0, N = PrevDecls.size(); I != N; ++I) - PrevDecls[I]->Common = Common; + PrevDecls.push_back(Prev); + } + + // If we never found a common pointer, allocate one now. + if (!Common) { + // FIXME: If any of the declarations is from an AST file, we probably + // need an update record to add the common data. + + Common = newCommon(getASTContext()); } + // Update any previous declarations we saw with the common pointer. + for (unsigned I = 0, N = PrevDecls.size(); I != N; ++I) + PrevDecls[I]->Common = Common; + return Common; } |