[PATCH] D119409: [C++20] [Modules] Remain variable's definition in module interface

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 14 01:35:45 PST 2022


ChuanqiXu added inline comments.


================
Comment at: clang/test/CodeGenCXX/static-variable-in-module.cpp:2-8
+// RUN: mkdir %t
+// RUN: echo "struct S { S(); };" >> %t/foo.h
+// RUN: echo "static S s = S();" >> %t/foo.h
+// RUN: %clang -std=c++20 -I%t %s -S -emit-llvm -o - | FileCheck %s
+module;
+#include "foo.h"
+export module m;
----------------
ChuanqiXu wrote:
> urnathan wrote:
> > rather than generate a foo.h file, why not (ab)use the preprocessor with internal line directives?
> > 
> > ```
> > module;
> > # 3 __FILE__ 1 // use the next physical line number here (and below)
> > struct S { S(); };
> > static S s = S();
> > # 6 "" 2
> > export module m;
> > ...
> > ```
> Yeah, the form is useful when we need to add expected-* diagnostic message to GMF. But I feel it is a little bit hacker. I guess the form mimics looks like user more wouldn't be worse personally.
Ok, I admit this is really helpful and time saving : ) (Now all my new test cases would be wrote in this form)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119409/new/

https://reviews.llvm.org/D119409



More information about the cfe-commits mailing list