Argyrios Kyrtzidis | 0eca89e | 2010-08-20 16:03:52 +0000 | [diff] [blame^] | 1 | //===--- ASTCommon.cpp - Common stuff for ASTReader/ASTWriter----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines common functions that both ASTReader and ASTWriter use. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "ASTCommon.h" |
| 15 | #include "clang/Basic/IdentifierTable.h" |
| 16 | #include "llvm/ADT/StringExtras.h" |
| 17 | |
| 18 | using namespace clang; |
| 19 | |
| 20 | unsigned serialization::ComputeHash(Selector Sel) { |
| 21 | unsigned N = Sel.getNumArgs(); |
| 22 | if (N == 0) |
| 23 | ++N; |
| 24 | unsigned R = 5381; |
| 25 | for (unsigned I = 0; I != N; ++I) |
| 26 | if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(I)) |
| 27 | R = llvm::HashString(II->getName(), R); |
| 28 | return R; |
| 29 | } |