<commit_before>#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

#include "../util/util.h"
#include "../util/util.h"

#include "const.h"
#include "sym.h"
#include "expr.h"
#include "cc1.h"
#include "type_is.h"

const char *constyness_strs[] = {
	"CONST_NO",
	"CONST_NUM",
	"CONST_ADDR",
	"CONST_STRK",
	"CONST_NEED_ADDR"
};

void const_fold(expr *e, consty *k)
{
	UCC_ASSERT(e->tree_type,
			"const_fold on %s before fold",
			e->f_str());

	memset(k, 0, sizeof *k);
	k->type = CONST_NO;

	if(e->f_const_fold){
		if(!e->const_eval.const_folded){
			e->const_eval.const_folded = 1;
			e->f_const_fold(e, &e->const_eval.k);
			e->const_eval.const_folded = 2;
		}else if(e->const_eval.const_folded == 1){
			ICW("const-folding a value during its own const-fold");
		}

		memcpy_safe(k, &e->const_eval.k);
	}

	if(k->type == CONST_NO && !k->nonconst)
		k->nonconst = e;
}

void const_fold_no(
		consty *k,
		consty *klhs, expr *lhs,
		consty *krhs, expr *rhs)
{<commit_msg>Catch CONST_[NEED_]ADDR labels with NULL .lbl entries<commit_after>#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

#include "../util/util.h"
#include "../util/util.h"

#include "const.h"
#include "sym.h"
#include "expr.h"
#include "cc1.h"
#include "type_is.h"

const char *constyness_strs[] = {
	"CONST_NO",
	"CONST_NUM",
	"CONST_ADDR",
	"CONST_STRK",
	"CONST_NEED_ADDR"
};

void const_fold(expr *e, consty *k)
{
	UCC_ASSERT(e->tree_type,
			"const_fold on %s before fold",
			e->f_str());

	memset(k, 0, sizeof *k);
	k->type = CONST_NO;

	if(e->f_const_fold){
		if(!e->const_eval.const_folded){
			e->const_eval.const_folded = 1;
			e->f_const_fold(e, &e->const_eval.k);
			e->const_eval.const_folded = 2;

			if((e->const_eval.k.type == CONST_ADDR
			|| e->const_eval.k.type == CONST_NEED_ADDR)
			&& e->const_eval.k.bits.addr.is_lbl)
			{
				assert(e->const_eval.k.bits.addr.bits.lbl);
			}
		}else if(e->const_eval.const_folded == 1){
			ICW("const-folding a value during its own const-fold");
		}

		memcpy_safe(k, &e->const_eval.k);
	}

	if(k->type == CONST_NO && !k->nonconst)
		k->nonconst = e;
}

void const_fold_no(
		consty *k,
		consty *klhs, expr *lhs,
		consty *krhs, expr *rhs)
{
{'fraction_non_alphanumeric': 0.19092542677448338, 'fraction_numerical': 0.004492362982929021, 'mean_word_length': 4.004494382022472, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '570363', 'n_tokens_mistral': 1062, 'n_tokens_neox': 998, 'n_words': 182}