<commit_before>#include "CPlusPlusMangle.h"

#include "LLVM_Headers.h"
#include <clang/AST/ASTContext.h>
#include <clang/AST/DeclCXX.h>
#include <clang/AST/Mangle.h>
#include <clang/Basic/Builtins.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
#include "IR.h"
#include "Type.h"

namespace Halide {

namespace Internal {

namespace {

clang::DeclContext *namespaced_decl_scope(clang::ASTContext &context, const std::vector<std::string> &namespaces) {
    clang::DeclContext *decl_context = context.getTranslationUnitDecl();
    for (const auto &namespace_name : namespaces) {
        decl_context = clang::NamespaceDecl::Create(context, decl_context, false, clang::SourceLocation(), clang::SourceLocation(),
                                                    &context.Idents.get(namespace_name), NULL);
    }
    return decl_context;
}

clang::TagDecl::TagKind map_tag_decl_kind(halide_cplusplus_type_name::CPPTypeType halide_val) {
    switch (halide_val) {
    case halide_cplusplus_type_name::Simple:
        internal_error << "Simple types should have already been handled.\n";
    case halide_cplusplus_type_name::Struct:
        return clang::TTK_Struct;
    case halide_cplusplus_type_name::Class:
        return clang::TTK_Class;
    case halide_cplusplus_type_name::Union:
        return clang::TTK_Union;
    case halide_cplusplus_type_name::Enum:
        return clang::TTK_Enum;
    }
}

struct PreviousDeclarations {
    struct class_or_struct {
        halide_cplusplus_type_name::CPPTypeType cpp_type_type;
        clang::CXXRecordDecl *decl{nullptr};
    };
    std::map<std::string, class_or_struct> classes_and_structs;

    std::map<std::string, clang::EnumDecl *> enums;

    clang::CXXRecordDecl *DeclareRecord(clang::ASTContext &context, clang::DeclContext *decl_context,
                                        const halide_cplusplus_type_name &inner_name) {<commit_msg>Fix return path issue witht ag mapping.<commit_after>#include "CPlusPlusMangle.h"

#include "LLVM_Headers.h"
#include <clang/AST/ASTContext.h>
#include <clang/AST/DeclCXX.h>
#include <clang/AST/Mangle.h>
#include <clang/Basic/Builtins.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
#include "IR.h"
#include "Type.h"

namespace Halide {

namespace Internal {

namespace {

clang::DeclContext *namespaced_decl_scope(clang::ASTContext &context, const std::vector<std::string> &namespaces) {
    clang::DeclContext *decl_context = context.getTranslationUnitDecl();
    for (const auto &namespace_name : namespaces) {
        decl_context = clang::NamespaceDecl::Create(context, decl_context, false, clang::SourceLocation(), clang::SourceLocation(),
                                                    &context.Idents.get(namespace_name), NULL);
    }
    return decl_context;
}

clang::TagDecl::TagKind map_tag_decl_kind(halide_cplusplus_type_name::CPPTypeType halide_val) {
    switch (halide_val) {
    case halide_cplusplus_type_name::Simple:
        internal_error << "Simple types should have already been handled.\n";
	return clang::TTK_Struct; // Have to return here to avoid unknown case below.
    case halide_cplusplus_type_name::Struct:
        return clang::TTK_Struct;
    case halide_cplusplus_type_name::Class:
        return clang::TTK_Class;
    case halide_cplusplus_type_name::Union:
        return clang::TTK_Union;
    case halide_cplusplus_type_name::Enum:
        return clang::TTK_Enum;
    }
    internal_error << "Unknown halide_cplusplus_type_name::CPPTypeType.\n";
    return clang::TTK_Struct; // Avoid control flow analysis error.
}

struct PreviousDeclarations {
    struct class_or_struct {
        halide_cplusplus_type_name::CPPTypeType cpp_type_type;
        clang::CXXRecordDecl *decl{nullptr};
    };
    std::map<std::string, class_or_struct> classes_and_structs;

    std::map<std::string, clang::EnumDecl *> enums;

    clang::CXXRecordDecl *DeclareRecord(clang::ASTContext &context, clang::DeclContext *decl_context,
                                        const halide_cplusplus_type_name &inner_name) {
{'fraction_non_alphanumeric': 0.10908205502800097, 'fraction_numerical': 0.0, 'mean_word_length': 4.115815691158157, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4404829', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1316, 'n_words': 231}