================
@@ -0,0 +1,64 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -verify %s
+
+void clang_analyzer_checkInlined(bool);
+void clang_analyzer_eval(bool);
+
+typedef void (*Callback)(unsigned);
+typedef void (&CallbackRef)(unsigned);
+
+static int Storage;
+
+static void pointerTarget(unsigned Value) {
+  int *Ptr = nullptr;
+
+  if (Value == 1)
+    Ptr = &Storage;
+
+  clang_analyzer_checkInlined(Value == 1); // expected-warning{{TRUE}}
+  *Ptr = 0;
+}
+
+static void referenceTarget(unsigned Value) {
+  int *Ptr = nullptr;
+
+  if (Value == 1)
+    Ptr = &Storage;
+
+  clang_analyzer_checkInlined(Value == 1); // expected-warning{{TRUE}}
----------------
steakhal wrote:

An alternative way of testing this is I think by passing `const char *` instead 
of `unsigned Value`. And just pass a fixed string literal from the callsite and 
see what a dump would print here.

If it prints the passed literal, then it was inlined from that callsite. If it 
prints something different, then it means that it wasn't inlined.

Ideally, if we could remove this niche `clang_analyzer_checkInlined` test 
function, that would be awesome. But that's a different story.

https://github.com/llvm/llvm-project/pull/217608
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to