aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2015-02-09 20:13:11 +0000
committerBen Langmuir <blangmuir@apple.com>2015-02-09 20:13:11 +0000
commit9be5d1ece8858e273b3eedfc5971f904049ec2f8 (patch)
tree27f77a5ddebcf9a4f3f1a008e858fe81c3b6ea4f /clang/lib/Frontend/CompilerInvocation.cpp
parentab5a8d60707323fe058522bc4d1598b1835def9f (diff)
downloadllvm-9be5d1ece8858e273b3eedfc5971f904049ec2f8.zip
llvm-9be5d1ece8858e273b3eedfc5971f904049ec2f8.tar.gz
llvm-9be5d1ece8858e273b3eedfc5971f904049ec2f8.tar.bz2
Update r228592 for when gethostname() returns an error
If gethostname() is not successful, just skip adding the hostname to the module hash. And don't bother setting hostname[255] = 0, since if gethostname() is successful, it will be null-terminated already (and if it's not successful we don't read the string now. llvm-svn: 228601
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ac3c311..e1d9351a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2028,10 +2028,10 @@ std::string CompilerInvocation::getModuleHash() const {
// The LockFileManager cannot tell when processes from another host are
// running, so mangle the hostname in to the module hash to separate them.
char hostname[256];
- hostname[255] = 0;
hostname[0] = 0;
- gethostname(hostname, 255);
- code = hash_combine(code, StringRef(hostname));
+ if (gethostname(hostname, 255) == 0)
+ code = hash_combine(code, StringRef(hostname));
+ // Ignore failures in gethostname() by not including the hostname in the hash.
#endif
return llvm::APInt(64, code).toString(36, /*Signed=*/false);