Skip to content
Snippets Groups Projects
Clang_utils.cpp 114.17 KiB
/**************************************************************************/
/*                                                                        */
/*  This file is part of Frama-Clang                                      */
/*                                                                        */
/*  Copyright (C) 2012-2020                                               */
/*    CEA (Commissariat à l'énergie atomique et aux énergies              */
/*         alternatives)                                                  */
/*                                                                        */
/*  you can redistribute it and/or modify it under the terms of the GNU   */
/*  Lesser General Public License as published by the Free Software       */
/*  Foundation, version 2.1.                                              */
/*                                                                        */
/*  It is distributed in the hope that it will be useful,                 */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
/*  GNU Lesser General Public License for more details.                   */
/*                                                                        */
/*  See the GNU Lesser General Public License version 2.1                 */
/*  for more details (enclosed in the file LICENSE).                      */
/*                                                                        */
/**************************************************************************/

// Implementations of the functions declared in Clang_utils.h

#include "Clang_utils.h"
#include "ClangVisitor.h"

extern "C" {

void free_type(qual_type obj) {
  { list elt = (*obj).qualifier;
    while(elt) {
      list tmp=elt->next;
      free(elt);
      elt=tmp;
    }
  }
  if ((*obj).plain_type)
    free_typ((*obj).plain_type);
  free(obj);
}

} // end of extern "C"

bool is_same_qualification(list l1, list l2) {
  while(l1 && l2) {
    if (!qualification_equal(
          (qualification)l1->element.container,
          (qualification)l2->element.container))
      return false;
    l1 = l1->next;
    l2 = l2->next;
  }
  if (l1 || l2) return false;
  return true;
}

int compare_qualification(list l1, list l2);

int
compare_qualified_name(qualified_name n1, qualified_name n2) {
  int result = compare_qualification(n1->prequalification,
      n2->prequalification);
  if (result == 0)
    result = strcmp(n1->decl_name, n2->decl_name);
  return result;
}

int compare_template_parameter(template_parameter tp1, template_parameter tp2);