<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 18, 2015 at 5:10 PM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Fri Sep 18 19:10:32 2015<br>
New Revision: 248069<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248069&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248069&view=rev</a><br>
Log:<br>
Refactor ASTReader::getSourceDescriptor(const Module &) into a constructor<br>
of ASTSourceDescriptor. It was effectively a static function.<br>
<br>
NFC.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/ExternalASTSource.h<br>
    cfe/trunk/include/clang/Serialization/ASTReader.h<br>
    cfe/trunk/lib/AST/ExternalASTSource.cpp<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
    cfe/trunk/lib/Serialization/ASTReader.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248069&r1=248068&r2=248069&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248069&r1=248068&r2=248069&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)<br>
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Fri Sep 18 19:10:32 2015<br>
@@ -142,19 +142,23 @@ public:<br>
   /// \brief Retrieve the module that corresponds to the given module ID.<br>
   virtual Module *getModule(unsigned ID) { return nullptr; }<br>
<br>
-  /// \brief Holds everything needed to generate debug info for an<br>
-  /// imported module or precompiled header file.<br>
+  /// Abstracts clang modules and precompiled header files and holds<br>
+  /// everything needed to generate debug info for an imported module<br>
+  /// or PCH.<br>
   struct ASTSourceDescriptor {<br>
+    ASTSourceDescriptor(std::string Name, std::string Path, std::string ASTFile,<br>
+                        uint64_t Signature)<br>
+        : ModuleName(Name), Path(Path), ASTFile(ASTFile),<br></blockquote><div><br></div><div>Missing std::moves on all three of these initializers ^</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+          Signature(Signature){};<br>
+    ASTSourceDescriptor(const Module &M);<br>
     std::string ModuleName;<br>
     std::string Path;<br>
     std::string ASTFile;<br>
-    uint64_t Signature;<br>
+    uint64_t Signature = 0;<br>
   };<br>
<br>
-  /// \brief Return a descriptor for the corresponding module, if one exists.<br>
+  /// Return a descriptor for the corresponding module, if one exists.<br>
   virtual llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID);<br>
-  /// \brief Return a descriptor for the module.<br>
-  virtual ASTSourceDescriptor getSourceDescriptor(const Module &M);<br>
<br>
   /// \brief Finds all declarations lexically contained within the given<br>
   /// DeclContext, after applying an optional filter predicate.<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=248069&r1=248068&r2=248069&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=248069&r1=248068&r2=248069&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Sep 18 19:10:32 2015<br>
@@ -1889,8 +1889,6 @@ public:<br>
<br>
   /// \brief Return a descriptor for the corresponding module.<br>
   llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID) override;<br>
-  /// \brief Return a descriptor for the module.<br>
-  ASTSourceDescriptor getSourceDescriptor(const Module &M) override;<br>
<br>
   /// \brief Retrieve a selector from the given module with its local ID<br>
   /// number.<br>
<br>
Modified: cfe/trunk/lib/AST/ExternalASTSource.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=248069&r1=248068&r2=248069&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=248069&r1=248068&r2=248069&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ExternalASTSource.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExternalASTSource.cpp Fri Sep 18 19:10:32 2015<br>
@@ -16,6 +16,7 @@<br>
 #include "clang/AST/ExternalASTSource.h"<br>
 #include "clang/AST/ASTContext.h"<br>
 #include "clang/AST/DeclarationName.h"<br>
+#include "clang/Basic/Module.h"<br>
 #include "llvm/Support/ErrorHandling.h"<br>
<br>
 using namespace clang;<br>
@@ -27,9 +28,12 @@ ExternalASTSource::getSourceDescriptor(u<br>
   return None;<br>
 }<br>
<br>
-ExternalASTSource::ASTSourceDescriptor<br>
-ExternalASTSource::getSourceDescriptor(const Module &M) {<br>
-  return ASTSourceDescriptor();<br>
+ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)<br>
+    : ModuleName(M.getFullModuleName()), Signature(M.Signature) {<br>
+  if (M.Directory)<br>
+    Path = M.Directory->getName();<br>
+  if (auto *File = M.getASTFile())<br>
+    ASTFile = File->getName();<br>
 }<br>
<br>
 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248069&r1=248068&r2=248069&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248069&r1=248068&r2=248069&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 19:10:32 2015<br>
@@ -3391,8 +3391,7 @@ void CGDebugInfo::EmitUsingDecl(const Us<br>
 }<br>
<br>
 void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {<br>
-  auto *Reader = CGM.getContext().getExternalSource();<br>
-  auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());<br>
+  auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());<br>
   DBuilder.createImportedDeclaration(<br>
       getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),<br>
       getOrCreateModuleRef(Info, DebugTypeExtRefs),<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=248069&r1=248068&r2=248069&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=248069&r1=248068&r2=248069&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Sep 18 19:10:32 2015<br>
@@ -7403,33 +7403,17 @@ unsigned ASTReader::getModuleFileID(Modu<br>
   return (I - PCHModules.end()) << 1;<br>
 }<br>
<br>
-ExternalASTSource::ASTSourceDescriptor<br>
-ASTReader::getSourceDescriptor(const Module &M) {<br>
-  StringRef Dir, Filename;<br>
-  if (M.Directory)<br>
-    Dir = M.Directory->getName();<br>
-  if (auto *File = M.getASTFile())<br>
-    Filename = File->getName();<br>
-  return ASTReader::ASTSourceDescriptor{<br>
-             M.getFullModuleName(), Dir, Filename,<br>
-             M.Signature<br>
-         };<br>
-}<br>
-<br>
 llvm::Optional<ExternalASTSource::ASTSourceDescriptor><br>
 ASTReader::getSourceDescriptor(unsigned ID) {<br>
   if (const Module *M = getSubmodule(ID))<br>
-    return getSourceDescriptor(*M);<br>
+    return ExternalASTSource::ASTSourceDescriptor(*M);<br>
<br>
   // If there is only a single PCH, return it instead.<br>
   // Chained PCH are not suported.<br>
   if (ModuleMgr.size() == 1) {<br>
     ModuleFile &MF = ModuleMgr.getPrimaryModule();<br>
-    return ASTReader::ASTSourceDescriptor{<br>
-      MF.OriginalSourceFileName, MF.OriginalDir,<br>
-      MF.FileName,<br>
-      MF.Signature<br>
-    };<br>
+    return ASTReader::ASTSourceDescriptor(<br>
+        MF.OriginalSourceFileName, MF.OriginalDir, MF.FileName, MF.Signature);<br>
   }<br>
   return None;<br>
 }<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>