MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ValidateCppIdent

Function ValidateCppIdent

tensorflow/compiler/aot/codegen.cc:771–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769}
770
771Status ValidateCppIdent(absl::string_view ident, absl::string_view msg) {
772 if (ident.empty()) {
773 return errors::InvalidArgument("empty identifier: ", msg);
774 }
775 // Require that the identifier starts with a nondigit, and is composed of
776 // nondigits and digits, as specified in section [2.11 Identifiers] of the
777 // C++11 Standard. Note that nondigit is defined as [_a-zA-Z] and digit is
778 // defined as [0-9].
779 //
780 // Technically the standard also allows for `universal-character-name`, with a
781 // table of allowed unicode ranges, as well as `other implementation-defined
782 // characters`. We disallow those here to give better error messages, at the
783 // expensive of being more restrictive than the standard.
784 if (ident[0] != '_' && !IsAlpha(ident[0])) {
785 return errors::InvalidArgument("illegal leading char: ", msg);
786 }
787 for (size_t pos = 1; pos < ident.size(); ++pos) {
788 if (ident[pos] != '_' && !IsAlphaNum(ident[pos])) {
789 return errors::InvalidArgument("illegal char: ", msg);
790 }
791 }
792 return Status::OK();
793}
794
795} // namespace tfcompile
796} // namespace tensorflow

Callers 3

ParseCppClassFunction · 0.85
TESTFunction · 0.85

Calls 5

InvalidArgumentFunction · 0.85
IsAlphaFunction · 0.70
IsAlphaNumFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68