Skip to content
Open

J4 #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5849,15 +5849,8 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl,

// The next token must be valid after an enum definition. If not, a ';'
// was probably forgotten.
bool CanBeBitfield = getCurScope()->isClassScope();
if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
ExpectAndConsume(tok::semi, diag::err_expected_after, "enum");
// Push this token back into the preprocessor and change our current token
// to ';' so that the rest of the code recovers as though there were an
// ';' after the definition.
PP.EnterToken(Tok, /*IsReinject=*/true);
Tok.setKind(tok::semi);
}
bool CanBeBitfield=getCurScope( )-> isClassScope( );if(!isValidAfterTypeSpecifier(CanBeBitfield)){ExpectAndConsume(tok::semi,diag::err_expected_after,"enum");PP.EnterToken(Tok,true);Tok.setKind(tok::semi);}

}

/// isKnownToBeTypeSpecifier - Return true if we know that the specified token
Expand Down
25 changes: 11 additions & 14 deletions clang/lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,17 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) {
<< FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc));
}

bool Parser::expectIdentifier() {
if (Tok.is(tok::identifier))
return false;
if (const auto *II = Tok.getIdentifierInfo()) {
if (II->isCPlusPlusKeyword(getLangOpts())) {
Diag(Tok, diag::err_expected_token_instead_of_objcxx_keyword)
<< tok::identifier << Tok.getIdentifierInfo();
// Objective-C++: Recover by treating this keyword as a valid identifier.
return false;
}
}
Diag(Tok, diag::err_expected) << tok::identifier;
return true;
}
bool Parser :: expectIdentifier ( )
{
if (Tok . is(tok ::identifier)) return false; if (const auto*II=Tok.getIdentifierInfo()) {
if(II -> isCPlusPlusKeyword ( getLangOpts( ) )){Diag ( Tok ,diag::err_expected_token_instead_of_objcxx_keyword) <<tok ::identifier<<Tok . getIdentifierInfo () ;return false;}}

Diag(
Tok,
diag ::
err_expected) << tok :: identifier;
return true; }


void Parser::checkCompoundToken(SourceLocation FirstTokLoc,
tok::TokenKind FirstTokKind, CompoundToken Op) {
Expand Down
32 changes: 26 additions & 6 deletions remote_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,43 @@ def fetch_diff(owner, repo, pr_number):

def run_clang_tidy_diff(diff_text):
print("🎯 Running clang-tidy-diff on changed lines...")

# Debugging: Print out the diff content to verify it is in the correct format
print("📜 Diff content being processed:")
print(diff_text)

try:
# Run clang-tidy-diff.py with input diff_text
result = subprocess.run(
[
"python3", CLANG_TIDY_DIFF_PATH,
"-p", "/ptmp/jay/new/llvm-project-checks/build", # Path to compilation database
"-quiet",
"-j", "4",
"-clang-tidy-binary", "/ptmp/jay/new/llvm-project-checks/build/bin/clang-tidy"
"-j", "4", # Parallel jobs
"-clang-tidy-binary", "/ptmp/jay/new/llvm-project-checks/build/bin/clang-tidy",
"-checks=*" # Ensure all checks are enabled
],
input=diff_text.encode("utf-8"),
input=diff_text.encode("utf-8"), # Pass the diff text properly
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=False,
check=True # Ensure we get an error if clang-tidy fails
)

print(result.stdout.decode("utf-8"))
# Output clang-tidy-diff results
output = result.stdout.decode("utf-8")
if output:
print("✅ clang-tidy suggestions detected:")
print(output)
else:
print("⚠️ No clang-tidy suggestions detected.")

if result.stderr:
print("⚠️ Errors/Warnings:", result.stderr.decode("utf-8"), file=sys.stderr)
except subprocess.CalledProcessError as e:
print(f"❌ Failed to run clang-tidy-diff: {e.stderr.decode()}")
sys.exit(1)
except Exception as e:
print(f"❌ Failed to run clang-tidy-diff: {e}")
print(f"❌ Unexpected error: {e}")
sys.exit(1)

def main():
Expand All @@ -59,7 +76,10 @@ def main():
print("❌ Missing configuration: owner, repo, or pr_number")
sys.exit(1)

# Fetch diff from GitHub using the API
diff_text = fetch_diff(owner, repo, pr_number)

# Run clang-tidy-diff on the fetched diff
run_clang_tidy_diff(diff_text)

if __name__ == "__main__":
Expand Down