mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-25 17:31:02 +00:00
[clang-rename] check whether -new-name is valid identifier in C++17
llvm-svn: 276259
This commit is contained in:
parent
8390d50e9c
commit
08c588c73a
@ -99,7 +99,18 @@ int main(int argc, const char **argv) {
|
||||
// Check the arguments for correctness.
|
||||
|
||||
if (NewName.empty()) {
|
||||
errs() << "clang-rename: no new name provided.\n\n";
|
||||
errs() << "ERROR: no new name provided.\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Check if NewName is a valid identifier in C++17.
|
||||
LangOptions Options;
|
||||
Options.CPlusPlus = true;
|
||||
Options.CPlusPlus1z = true;
|
||||
IdentifierTable Table(Options);
|
||||
auto NewNameTokKind = Table.get(NewName).getTokenID();
|
||||
if (!tok::isAnyIdentifier(NewNameTokKind)) {
|
||||
errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
2
clang-tools-extra/test/clang-rename/InvalidNewName.cpp
Normal file
2
clang-tools-extra/test/clang-rename/InvalidNewName.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
// RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
|
||||
// CHECK: ERROR: new name is not a valid identifier in C++17.
|
@ -1,4 +1,4 @@
|
||||
// Check for an error while -new-name argument has not been passed to
|
||||
// clang-rename.
|
||||
// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
|
||||
// CHECK: clang-rename: no new name provided.
|
||||
// CHECK: ERROR: no new name provided.
|
||||
|
Loading…
Reference in New Issue
Block a user