Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clang.cpp #77031

Closed
wants to merge 0 commits into from
Closed

Update Clang.cpp #77031

wants to merge 0 commits into from

Conversation

hw-1
Copy link

@hw-1 hw-1 commented Jan 5, 2024

fix bug with PCH check failed, detail with #76923

Copy link

github-actions bot commented Jan 5, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jan 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 5, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: hw-1 (hw-1)

Changes

fix bug with PCH check failed, detail with #76923


Full diff: https://github.com/llvm/llvm-project/pull/77031.diff

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2d8ef841d4f6be..bb8b496dbfe5fc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -951,7 +951,7 @@ static void handleAMDGPUCodeObjectVersionOptions(const Driver &D,
 static bool hasClangPchSignature(const Driver &D, StringRef Path) {
   if (llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MemBuf =
           D.getVFS().getBufferForFile(Path))
-    return (*MemBuf)->getBuffer().starts_with("CPCH");
+    return (*MemBuf)->getBuffer().substr(0x500,-1).starts_with("CPCH");
   return false;
 }
 

Copy link

github-actions bot commented Jan 5, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff c1eef483b2c1ab2564e0ee1e4d1a30db11f8049f 50e69eac786a646491e278478bb096e361d6c4c1 -- clang/lib/Driver/ToolChains/Clang.cpp
View the diff from clang-format here.
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index bb8b496dbf..0eb32c9b03 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -951,7 +951,7 @@ static void handleAMDGPUCodeObjectVersionOptions(const Driver &D,
 static bool hasClangPchSignature(const Driver &D, StringRef Path) {
   if (llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MemBuf =
           D.getVFS().getBufferForFile(Path))
-    return (*MemBuf)->getBuffer().substr(0x500,-1).starts_with("CPCH");
+    return (*MemBuf)->getBuffer().substr(0x500, -1).starts_with("CPCH");
   return false;
 }
 

@cor3ntin
Copy link
Contributor

cor3ntin commented Jan 5, 2024

Can you provide a more complete description of your change, a better title?
Does this change needs tests? A release note?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants