@@ -10,34 +10,45 @@ namespace codeql {
1010
1111// Abstracts a given trap output file, with its own universe of trap labels
1212class TrapDomain {
13- TargetFile out_ ;
13+ TargetFile out ;
1414
1515 public:
16- explicit TrapDomain (TargetFile&& out) : out_ {std::move (out)} {}
16+ explicit TrapDomain (TargetFile&& out) : out {std::move (out)} {}
1717
1818 template <typename Entry>
1919 void emit (const Entry& e) {
20- print (e) ;
20+ out << e << ' \n ' ;
2121 }
2222
2323 template <typename ... Args>
2424 void debug (const Args&... args) {
25- print ( " /* DEBUG:" ) ;
26- print (args ...);
27- print ( " */ " ) ;
25+ out << " /* DEBUG:\n " ;
26+ (out << ... << args );
27+ out << " \n */ \n " ;
2828 }
2929
3030 template <typename Tag>
3131 TrapLabel<Tag> createLabel () {
3232 auto ret = allocateLabel<Tag>();
3333 assignStar (ret);
34+ out << ' \n ' ;
3435 return ret;
3536 }
3637
3738 template <typename Tag, typename ... Args>
3839 TrapLabel<Tag> createLabel (Args&&... args) {
3940 auto ret = allocateLabel<Tag>();
4041 assignKey (ret, std::forward<Args>(args)...);
42+ out << ' \n ' ;
43+ return ret;
44+ }
45+
46+ template <typename Tag, typename ... Args>
47+ TrapLabel<Tag> createLabelWithImplementationId (const std::string_view& implementationId,
48+ Args&&... args) {
49+ auto ret = allocateLabel<Tag>();
50+ assignKey (ret, std::forward<Args>(args)...);
51+ out << " .implementation " << trapQuoted (implementationId) << ' \n ' ;
4152 return ret;
4253 }
4354
@@ -49,21 +60,16 @@ class TrapDomain {
4960 return TrapLabel<Tag>::unsafeCreateFromExplicitId (id_++);
5061 }
5162
52- template <typename ... Args>
53- void print (const Args&... args) {
54- (out_ << ... << args) << ' \n ' ;
55- }
56-
5763 template <typename Tag>
5864 void assignStar (TrapLabel<Tag> label) {
59- print ( label, " =*" ) ;
65+ out << label << " =*" ;
6066 }
6167
6268 template <typename Tag>
6369 void assignKey (TrapLabel<Tag> label, const std::string& key) {
6470 // prefix the key with the id to guarantee the same key is not used wrongly with different tags
6571 auto prefixed = std::string (Tag::prefix) + ' _' + key;
66- print ( label, " =@" , trapQuoted (prefixed) );
72+ out << label << " =@" << trapQuoted (prefixed);
6773 }
6874
6975 template <typename Tag, typename ... Args>
0 commit comments