[PATCH] D20811: [analyzer] Model some library functions
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 28 04:41:46 PDT 2016
NoQ added inline comments.
================
Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:509
@@ +508,3 @@
+ // }
+ // }
+ //}
----------------
dcoughlin wrote:
> I disagree about compactness being valuable here. I think it is more important to intrinsically document the spec. These will be written once and read frequently. When they are written, they will copied from a previous example -- probably by someone who is not familiar with the code or the spec format.
>
> Another possibility (not sure if it is the right one here) is to use macro tricks to define a simple DSL like Kulpreet did in the LocalizationChecker.cpp.
> These will be written once and read frequently.
If only it was so :))
Hmm. What do you think of the following format? Macros mostly expand to empty or (argument), but it should be more readable than the `/*`...`*/` noise.
```
SPEC {
FOR_FUNCTION("isalnum"),
SPEC_DATA {
ARGUMENT_TYPES { IntTy },
RETURN_TYPE(IntTy),
INVALIDATION_APPROACH(EvalCallAsPure),
BRANCHES {
BRANCH { // Boils down to isupper() or islower() or isdigit()
RANGE {
ARG_NO(0), RANGE_KIND(WithinRange),
SET { SEG('0', '9') U SEG('A', 'Z') U SEG('a', 'z') }
},
RANGE {
RET_VAL, RANGE_KIND(OutOfRange),
SET { SEG(0, 0) }
}
},
BRANCH { // The locale-specific branch.
RANGE {
ARG_NO(0), RANGE_KIND(WithinRange),
SET { SEG(128, 255) }
}
},
BRANCH { // Other.
RANGE {
ARG_NO(0), RANGE_KIND(OutOfRange),
SET { SEG('0', '9') U SEG('A', 'Z')
U SEG('a', 'z') U SEG(128, 255)}
},
RANGE {
RET_VAL, RANGE_KIND(WithinRange),
SET { SEG(0, 0) }
}
}
}
}
},
```
https://reviews.llvm.org/D20811
More information about the cfe-commits
mailing list