[cfe-commits] r111629 - in /cfe/trunk/lib/Serialization: ASTCommon.cpp ASTCommon.h ASTReader.cpp ASTWriter.cpp CMakeLists.txt
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Aug 20 09:03:52 PDT 2010
Author: akirtzidis
Date: Fri Aug 20 11:03:52 2010
New Revision: 111629
URL: http://llvm.org/viewvc/llvm-project?rev=111629&view=rev
Log:
Share the common code of ComputeHash(Selector Sel) instead of keeping 2 copies in PCHReader and PCHWriter.
No functionality change.
Added:
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTCommon.h
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/CMakeLists.txt
Added: cfe/trunk/lib/Serialization/ASTCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=111629&view=auto
==============================================================================
--- cfe/trunk/lib/Serialization/ASTCommon.cpp (added)
+++ cfe/trunk/lib/Serialization/ASTCommon.cpp Fri Aug 20 11:03:52 2010
@@ -0,0 +1,29 @@
+//===--- ASTCommon.cpp - Common stuff for ASTReader/ASTWriter----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines common functions that both ASTReader and ASTWriter use.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ASTCommon.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "llvm/ADT/StringExtras.h"
+
+using namespace clang;
+
+unsigned serialization::ComputeHash(Selector Sel) {
+ unsigned N = Sel.getNumArgs();
+ if (N == 0)
+ ++N;
+ unsigned R = 5381;
+ for (unsigned I = 0; I != N; ++I)
+ if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(I))
+ R = llvm::HashString(II->getName(), R);
+ return R;
+}
Added: cfe/trunk/lib/Serialization/ASTCommon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.h?rev=111629&view=auto
==============================================================================
--- cfe/trunk/lib/Serialization/ASTCommon.h (added)
+++ cfe/trunk/lib/Serialization/ASTCommon.h Fri Aug 20 11:03:52 2010
@@ -0,0 +1,28 @@
+//===- ASTCommon.h - Common stuff for ASTReader/ASTWriter -*- C++ -*-=========//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines common functions that both ASTReader and ASTWriter use.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
+#define LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
+
+namespace clang {
+ class Selector;
+
+namespace serialization {
+
+unsigned ComputeHash(Selector Sel);
+
+} // namespace serialization
+
+} // namespace clang
+
+#endif
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=111629&r1=111628&r2=111629&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Aug 20 11:03:52 2010
@@ -13,6 +13,7 @@
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ASTDeserializationListener.h"
+#include "ASTCommon.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/Utils.h"
#include "clang/Sema/Sema.h"
@@ -477,14 +478,7 @@
}
static unsigned ComputeHash(Selector Sel) {
- unsigned N = Sel.getNumArgs();
- if (N == 0)
- ++N;
- unsigned R = 5381;
- for (unsigned I = 0; I != N; ++I)
- if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(I))
- R = llvm::HashString(II->getName(), R);
- return R;
+ return serialization::ComputeHash(Sel);
}
// This hopefully will just get inlined and removed by the optimizer.
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=111629&r1=111628&r2=111629&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Aug 20 11:03:52 2010
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Serialization/ASTWriter.h"
+#include "ASTCommon.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/IdentifierResolver.h"
#include "clang/AST/ASTContext.h"
@@ -1571,14 +1572,7 @@
explicit ASTMethodPoolTrait(ASTWriter &Writer) : Writer(Writer) { }
static unsigned ComputeHash(Selector Sel) {
- unsigned N = Sel.getNumArgs();
- if (N == 0)
- ++N;
- unsigned R = 5381;
- for (unsigned I = 0; I != N; ++I)
- if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(I))
- R = llvm::HashString(II->getName(), R);
- return R;
+ return serialization::ComputeHash(Sel);
}
std::pair<unsigned,unsigned>
Modified: cfe/trunk/lib/Serialization/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/CMakeLists.txt?rev=111629&r1=111628&r2=111629&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/CMakeLists.txt (original)
+++ cfe/trunk/lib/Serialization/CMakeLists.txt Fri Aug 20 11:03:52 2010
@@ -2,6 +2,7 @@
add_clang_library(clangSerialization
GeneratePCH.cpp
+ ASTCommon.cpp
ASTReader.cpp
ASTReaderDecl.cpp
ASTReaderStmt.cpp
More information about the cfe-commits
mailing list