MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / get_char_star_array_literal

Method get_char_star_array_literal

src/program/array.rs:48–70  ·  view source on GitHub ↗

get the char * array declared in InitListExpr, e.g., char *[] = {"hello", "world"}

(
        &self,
        node: &Node,
        len: Option<usize>,
    )

Source from the content-addressed store, hash-verified

46
47 /// get the char * array declared in InitListExpr, e.g., char *[] = {"hello", "world"}
48 pub fn get_char_star_array_literal(
49 &self,
50 node: &Node,
51 len: Option<usize>,
52 ) -> Result<Vec<String>> {
53 let mut strings: Vec<String> = Vec::new();
54 for child in self.get_childs(node) {
55 if let Clang::StringLiteral(sl) = &child.kind {
56 strings.push(sl.get_eval_value());
57 } else {
58 eyre::bail!("child should be StringLiteral: {child:?}")
59 }
60 }
61 if let Some(len) = len {
62 //assert_eq!(strings.len(), len);
63 if strings.is_empty() {
64 for _ in 0..len {
65 strings.push("str".to_string());
66 }
67 }
68 }
69 Ok(strings)
70 }
71}
72
73/// impl fns to get array of literals for each literal type.

Callers 2

Calls 4

get_eval_valueMethod · 0.80
get_childsMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected