<div dir="ltr"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">+  /// \brief Returns true if this is the first declaration.</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">
<span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">+  bool isFirstDecl() const {</span><br><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">This comment doesn't add anything. First declaration of what? in what?</span></div>
<div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">-- Sean Silva</span></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Oct 18, 2013 at 10:13 PM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rafael<br>
Date: Fri Oct 18 21:13:21 2013<br>
New Revision: 193027<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=193027&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=193027&view=rev</a><br>
Log:<br>
Add isFirstDecl to DecBase too and use it instead of getPreviousDecl() == 0.<br>
<br>
Redeclarable already had a isFirstDecl, but it was missing from DeclBase.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/Decl.h<br>
    cfe/trunk/include/clang/AST/DeclBase.h<br>
    cfe/trunk/include/clang/AST/DeclObjC.h<br>
    cfe/trunk/include/clang/AST/DeclTemplate.h<br>
    cfe/trunk/lib/AST/ASTContext.cpp<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
    cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Decl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/Decl.h (original)<br>
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 18 21:13:21 2013<br>
@@ -368,6 +368,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   /// \brief Returns true if this is an anonymous namespace declaration.<br>
   ///<br>
@@ -775,6 +776,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   static VarDecl *Create(ASTContext &C, DeclContext *DC,<br>
                          SourceLocation StartLoc, SourceLocation IdLoc,<br>
@@ -1563,6 +1565,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   static FunctionDecl *Create(ASTContext &C, DeclContext *DC,<br>
                               SourceLocation StartLoc, SourceLocation NLoc,<br>
@@ -2390,6 +2393,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   bool isModed() const { return MaybeModedTInfo.is<ModedTInfo*>(); }<br>
<br>
@@ -2574,6 +2578,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   SourceLocation getRBraceLoc() const { return RBraceLoc; }<br>
   void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }<br>
<br>
Modified: cfe/trunk/include/clang/AST/DeclBase.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/DeclBase.h (original)<br>
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Oct 18 21:13:21 2013<br>
@@ -785,7 +785,12 @@ public:<br>
   const Decl *getPreviousDecl() const {<br>
     return const_cast<Decl *>(this)->getPreviousDeclImpl();<br>
   }<br>
-<br>
+<br>
+  /// \brief Returns true if this is the first declaration.<br>
+  bool isFirstDecl() const {<br>
+    return getPreviousDecl() == 0;<br>
+  }<br>
+<br>
   /// \brief Retrieve the most recent declaration that declares the same entity<br>
   /// as this declaration (which may be this declaration).<br>
   Decl *getMostRecentDecl() { return getMostRecentDeclImpl(); }<br>
<br>
Modified: cfe/trunk/include/clang/AST/DeclObjC.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)<br>
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Oct 18 21:13:21 2013<br>
@@ -1201,6 +1201,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   /// Retrieves the canonical declaration of this Objective-C class.<br>
   ObjCInterfaceDecl *getCanonicalDecl() { return getFirstDecl(); }<br>
@@ -1503,6 +1504,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   /// Retrieves the canonical declaration of this Objective-C protocol.<br>
   ObjCProtocolDecl *getCanonicalDecl() { return getFirstDecl(); }<br>
<br>
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)<br>
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Oct 18 21:13:21 2013<br>
@@ -715,6 +715,7 @@ public:<br>
   using redeclarable_base::redecls_end;<br>
   using redeclarable_base::getPreviousDecl;<br>
   using redeclarable_base::getMostRecentDecl;<br>
+  using redeclarable_base::isFirstDecl;<br>
<br>
   // Implement isa/cast/dyncast/etc.<br>
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }<br>
<br>
Modified: cfe/trunk/lib/AST/ASTContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/AST/ASTContext.cpp (original)<br>
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Oct 18 21:13:21 2013<br>
@@ -2922,13 +2922,11 @@ QualType ASTContext::getTypeDeclTypeSlow<br>
          "Template type parameter types are always available.");<br>
<br>
   if (const RecordDecl *Record = dyn_cast<RecordDecl>(Decl)) {<br>
-    assert(!Record->getPreviousDecl() &&<br>
-           "struct/union has previous declaration");<br>
+    assert(Record->isFirstDecl() && "struct/union has previous declaration");<br>
     assert(!NeedsInjectedClassNameType(Record));<br>
     return getRecordType(Record);<br>
   } else if (const EnumDecl *Enum = dyn_cast<EnumDecl>(Decl)) {<br>
-    assert(!Enum->getPreviousDecl() &&<br>
-           "enum has previous declaration");<br>
+    assert(Enum->isFirstDecl() && "enum has previous declaration");<br>
     return getEnumType(Enum);<br>
   } else if (const UnresolvedUsingTypenameDecl *Using =<br>
                dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) {<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Oct 18 21:13:21 2013<br>
@@ -5388,7 +5388,7 @@ Sema::ActOnVariableDeclarator(Scope *S,<br>
<br>
   // If this is the first declaration of an extern C variable, update<br>
   // the map of such variables.<br>
-  if (!NewVD->getPreviousDecl() && !NewVD->isInvalidDecl() &&<br>
+  if (NewVD->isFirstDecl() && !NewVD->isInvalidDecl() &&<br>
       isIncompleteDeclExternC(*this, NewVD))<br>
     RegisterLocallyScopedExternCDecl(NewVD, S);<br>
<br>
@@ -7205,7 +7205,7 @@ Sema::ActOnFunctionDeclarator(Scope *S,<br>
<br>
   // If this is the first declaration of an extern C variable, update<br>
   // the map of such variables.<br>
-  if (!NewFD->getPreviousDecl() && !NewFD->isInvalidDecl() &&<br>
+  if (NewFD->isFirstDecl() && !NewFD->isInvalidDecl() &&<br>
       isIncompleteDeclExternC(*this, NewFD))<br>
     RegisterLocallyScopedExternCDecl(NewFD, S);<br>
<br>
@@ -8520,7 +8520,7 @@ void Sema::ActOnUninitializedDecl(Decl *<br>
           // is accepted by gcc. Hence here we issue a warning instead of<br>
           // an error and we do not invalidate the static declaration.<br>
           // NOTE: to avoid multiple warnings, only check the first declaration.<br>
-          if (Var->getPreviousDecl() == 0)<br>
+          if (Var->isFirstDecl())<br>
             RequireCompleteType(Var->getLocation(), Type,<br>
                                 diag::ext_typecheck_decl_incomplete_type);<br>
         }<br>
@@ -9619,7 +9619,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl<br>
     // The only way to be included in UndefinedButUsed is if there is an<br>
     // ODR use before the definition. Avoid the expensive map lookup if this<br>
     // is the first declaration.<br>
-    if (FD->getPreviousDecl() != 0 && FD->getPreviousDecl()->isUsed()) {<br>
+    if (!FD->isFirstDecl() && FD->getPreviousDecl()->isUsed()) {<br>
       if (!FD->isExternallyVisible())<br>
         UndefinedButUsed.erase(FD);<br>
       else if (FD->isInlined() &&<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=193027&r1=193026&r2=193027&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=193027&r1=193026&r2=193027&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Oct 18 21:13:21 2013<br>
@@ -3531,7 +3531,7 @@ void ASTWriter::WriteRedeclarations() {<br>
<br>
   for (unsigned I = 0, N = Redeclarations.size(); I != N; ++I) {<br>
     Decl *First = Redeclarations[I];<br>
-    assert(First->getPreviousDecl() == 0 && "Not the first declaration?");<br>
+    assert(First->isFirstDecl() && "Not the first declaration?");<br>
<br>
     Decl *MostRecent = First->getMostRecentDecl();<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>