Skip to content

Commit

Permalink
Merge pull request #106 from yast/clang
Browse files Browse the repository at this point in the history
Optionally build with Clang instead of GCC (via bcond_with clang).
  • Loading branch information
mvidner committed Jun 2, 2016
2 parents 9a9a31e + c9d5908 commit d78c2ac
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 33 deletions.
2 changes: 1 addition & 1 deletion agent-ini/src/IniFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class IniSection;


enum IniType { VALUE, SECTION,};
struct IniContainerElement;
class IniContainerElement;

typedef list<IniContainerElement> IniContainer;
typedef IniContainer::iterator IniIterator;
Expand Down
3 changes: 3 additions & 0 deletions agent-ini/src/IniParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,9 @@ int IniParser::write_file(const string & target_filename, IniSection & section)
return 0;
}

std::string format (const char * format, ...)
__attribute__ ((format (printf, 1, 2)));

/** sprintf to a std::string, throwing runtime_error on OOM */
std::string format (const char * format, ...) {
// copied from y2util/stringutil.h but added the throw
Expand Down
1 change: 1 addition & 0 deletions libscr/src/include/scr/Y2AgentComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <ycp/YCPCode.h>
#include <ycp/YCPVoid.h>
#include <ycp/YCPTerm.h>
#include <ycp/YCPPath.h>

class SCRAgent;

Expand Down
5 changes: 5 additions & 0 deletions liby2/src/include/y2/Y2PluginComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ class Y2PluginComponent : public Y2Component
/**
* The component level the plugin was started in.
*/
#ifdef __clang__
int level __attribute__((__unused__));
// 'level' can be removed for SLE13; now keeping it for ABI.
#else
int level;
#endif

/**
* Handle of the dynamic loaded library.
Expand Down
8 changes: 5 additions & 3 deletions liby2util-r/src/MemUsage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ void MemUsage::MuDump ()
ie = m_mu_instances->end ();
for (; ii != ie; ++ii)
{
const char * name = typeid (**ii).name ();
MemUsage * tracked_ptr = *ii;
const char * name = typeid (*tracked_ptr).name ();
std::string dename = demangle (name);
if (m_mu_size.find (dename) == m_mu_size.end())
{
m_mu_size[dename] = (**ii).mem_size();
m_mu_size[dename] = (*tracked_ptr).mem_size();
}
++ m_mu_count[dename];
}
Expand Down Expand Up @@ -83,7 +84,8 @@ void MemUsage::MuDumpVal (const char *aname)
ie = m_mu_instances->end ();
for (; ii != ie; ++ii)
{
std::string dname = demangle (typeid (**ii).name ());
MemUsage * tracked_ptr = *ii;
std::string dname = demangle (typeid (*tracked_ptr).name ());
if (dname == aname)
{
fprintf (stderr, "p *(%s *)%p\n", aname, *ii);
Expand Down
3 changes: 3 additions & 0 deletions liby2util-r/src/include/y2util/stringutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ enum Trim {
TRIM = (L_TRIM|R_TRIM)
};

inline std::string vform( const char * format, va_list ap )
__attribute__ ((format (printf, 1, 0)));

inline std::string vform( const char * format, va_list ap ) {
char * buf = 0;
std::string val;
Expand Down
12 changes: 12 additions & 0 deletions liby2util-r/src/y2log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ void y2_logger_blanik(loglevel_t level, const string& component, const char *fil
*/
string y2_logfmt_common(bool simple, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
__attribute__ ((format (printf, 6, 0)));

string y2_logfmt_common(bool simple, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
{
/* Prepare the log text */
string logtext = stringutil::vform(format, ap);
Expand Down Expand Up @@ -264,6 +268,10 @@ string y2_logfmt_prefix (loglevel_t level)
}


void y2_vlogger_function(loglevel_t level, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
__attribute__ ((format (printf, 6, 0)));

void y2_vlogger_function(loglevel_t level, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
{
Expand All @@ -285,6 +293,10 @@ void y2_vlogger_function(loglevel_t level, const string& component, const char *
}
}

void y2_vlogger_blanik(loglevel_t level, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
__attribute__ ((format (printf, 6, 0)));

void y2_vlogger_blanik(loglevel_t level, const string& component, const char *file,
const int line, const char *function, const char *format, va_list ap)
{
Expand Down
7 changes: 5 additions & 2 deletions libycp/src/YBlock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ YBlock::toStringSwitch (map<YCPValue, int, ycp_less> cases, int defaultcase) con
{
// first, create reverse map of cases
int statementcount = statementCount ();
YCPValue values[statementcount];
YCPValue * values = new YCPValue[statementcount];

for (int i = 0; i < statementcount; i++)
values[i] = YCPNull ();
Expand Down Expand Up @@ -514,6 +514,7 @@ YBlock::toStringSwitch (map<YCPValue, int, ycp_less> cases, int defaultcase) con
stmt = stmt->next;
index++;
}
delete[] values;

s += "\n}\n";
return s;
Expand All @@ -525,7 +526,8 @@ YBlock::toXmlSwitch( map<YCPValue, int, ycp_less> cases, int defaultcase, std::o
{
// first, create reverse map of cases
int statementcount = statementCount ();
vector<YCPValue> values[statementcount];

vector<YCPValue> * values = new vector<YCPValue>[statementcount];

for (map<YCPValue, int, ycp_less>::iterator it = cases.begin ();
it != cases.end (); it++ )
Expand Down Expand Up @@ -566,6 +568,7 @@ YBlock::toXmlSwitch( map<YCPValue, int, ycp_less> cases, int defaultcase, std::o
index++;
}
str << closing_tag;
delete[] values;

return str;
}
Expand Down
12 changes: 6 additions & 6 deletions libycp/src/YCPBuiltinString.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,28 +299,28 @@ s_substring1 (const YCPString &s, const YCPInteger &i1)
if (s->isAscii())
{
string ss = s->value ();
string::size_type start = i1->value();
long long start = i1->value();

if (start < 0 || start > ss.size())
if (start < 0 || start > (long long)ss.size())
{
ycp2error("Substring index out of range");
return YCPString ("");
}

return YCPString(ss.substr(start, string::npos));
return YCPString(ss.substr((string::size_type) start, string::npos));
}
else
{
wstring ss = s->wvalue();
wstring::size_type start = i1->value();
long long start = i1->value();

if (start < 0 || start > ss.size())
if (start < 0 || start > (long long)ss.size())
{
ycp2error("Substring index out of range");
return YCPString("");
}

return YCPString(ss.substr(start, wstring::npos));
return YCPString(ss.substr((wstring::size_type) start, wstring::npos));
}
}

Expand Down
2 changes: 1 addition & 1 deletion libycp/src/YCPMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ YCPMapRep::compare(const YCPMap& m) const
{
// equal length ==> pairwise comparison
for( YCPMap::const_iterator pos_this = begin(), pos_m = m->begin();
pos_this != end(), pos_m != m->end();
pos_this != end();
++pos_this, ++pos_m )
{
// compare keys
Expand Down
10 changes: 8 additions & 2 deletions libycp/src/YExpression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3126,7 +3126,7 @@ YEFunction::evaluate (bool cse)
}
}

YCPValue evaluated_params [m_next_param_id];
YCPValue* evaluated_params = new YCPValue[m_next_param_id];

for (unsigned int p = 0; p < m_next_param_id ; p++)
{
Expand All @@ -3137,6 +3137,7 @@ YEFunction::evaluate (bool cse)
if (value.isNull())
{
ycp2error ("Parameter eval failed (%s)", m_parameters[p]->toString().c_str());
delete[](evaluated_params);
return value;
}

Expand All @@ -3160,6 +3161,7 @@ YEFunction::evaluate (bool cse)
if (YaST::ee.endlessRecursion())
{
ycp2error ("Returning nil instead of calling the function.");
delete[](evaluated_params);
return YCPVoid ();
}

Expand All @@ -3172,6 +3174,8 @@ YEFunction::evaluate (bool cse)
YaST::ee.setFilename(filename);

YaST::ee.popframe();
// FIXME: did the frame need ep to exist? otherwise we could delete it before evaluateCall
delete[](evaluated_params);

#if DO_DEBUG
y2debug("evaluate done (%s) = '%s'", qualifiedName ().c_str(), value.isNull() ? "NULL" : value->toString().c_str());
Expand Down Expand Up @@ -3266,7 +3270,7 @@ YEFunctionPointer::evaluate (bool cse)
// FIXME: this could fail
m_functioncall->reset ();

YCPValue m_params [m_next_param_id];
YCPValue * m_params = new YCPValue[m_next_param_id];

for (unsigned int p = 0; p < m_next_param_id ; p++)
{
Expand All @@ -3277,6 +3281,7 @@ YEFunctionPointer::evaluate (bool cse)
if (value.isNull())
{
ycp2error ("Parameter eval failed (%s)", m_parameters[p]->toString().c_str());
delete[] m_params;
return value;
}

Expand All @@ -3292,6 +3297,7 @@ YEFunctionPointer::evaluate (bool cse)
{
m_functioncall->attachParameter (m_params[p], p);
}
delete[] m_params; // can now already? why no frame push?

// save the context info
int linenumber = YaST::ee.linenumber();
Expand Down
6 changes: 3 additions & 3 deletions libycp/src/include/ycp/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "ycp/YCode.h"

class Scanner;
class blockstack_t;
class scannerstack_t;
class switchstack_t;
struct blockstack_t;
struct scannerstack_t;
struct switchstack_t;
class YBlock;

/**
Expand Down
2 changes: 1 addition & 1 deletion libycp/src/include/ycp/YCPMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// Only for backwards compatibility. See mail from aschnell on yast-devel on
// 2009-01-07. http://lists.opensuse.org/yast-devel/2009-01/msg00016.html
typedef map<YCPValue, YCPValue, ycp_less> YCPValueYCPValueMap;
class YCPMapIterator;
struct YCPMapIterator;


/**
Expand Down
6 changes: 6 additions & 0 deletions libycp/src/scanner.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

%{

#ifdef __clang__
// There are many "register" variables declared in generated flex code
// which we cannot affect, but Clang warns about them. Shut that up.
#pragma clang diagnostic ignored "-Wdeprecated-register"
#endif

#include <list>
#include <string>
#include <sstream>
Expand Down
43 changes: 30 additions & 13 deletions libycp/testsuite/tests/builtin/Builtin-String.err
Original file line number Diff line number Diff line change
Expand Up @@ -128,36 +128,53 @@ substring ("some text", 42, 2)
[Interpreter] tests/builtin/Builtin-String.ycp:59 Substring index out of range
Parsed:
----------------------------------------------------------------------
substring ("some text", -1)
----------------------------------------------------------------------
[Interpreter] tests/builtin/Builtin-String.ycp:61 Substring index out of range
Parsed:
----------------------------------------------------------------------
substring ("some text", 5, 0)
----------------------------------------------------------------------
Parsed:
----------------------------------------------------------------------
substring ("some text", 5, 42)
----------------------------------------------------------------------
Parsed:
----------------------------------------------------------------------
substring ("some text", 5, -42)
----------------------------------------------------------------------
Parsed:
----------------------------------------------------------------------
"** lsubstring **"
----------------------------------------------------------------------
[Parser] tests/builtin/Builtin-String.ycp:64 Warning: lsubstring(...) is deprecated, please fix
[Parser] tests/builtin/Builtin-String.ycp:68 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("some text", 5)
----------------------------------------------------------------------
[Parser] tests/builtin/Builtin-String.ycp:65 Warning: lsubstring(...) is deprecated, please fix
[Parser] tests/builtin/Builtin-String.ycp:69 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("some text", 42)
----------------------------------------------------------------------
[Interpreter] tests/builtin/Builtin-String.ycp:65 Substring index out of range
[Parser] tests/builtin/Builtin-String.ycp:66 Warning: lsubstring(...) is deprecated, please fix
[Interpreter] tests/builtin/Builtin-String.ycp:69 Substring index out of range
[Parser] tests/builtin/Builtin-String.ycp:70 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("ěščřžýáí", 5)
----------------------------------------------------------------------
[Parser] tests/builtin/Builtin-String.ycp:68 Warning: lsubstring(...) is deprecated, please fix
[Parser] tests/builtin/Builtin-String.ycp:72 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("some text", 5, 2)
----------------------------------------------------------------------
[Parser] tests/builtin/Builtin-String.ycp:69 Warning: lsubstring(...) is deprecated, please fix
[Parser] tests/builtin/Builtin-String.ycp:73 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("some text", 42, 2)
----------------------------------------------------------------------
[Interpreter] tests/builtin/Builtin-String.ycp:69 Substring index out of range
[Parser] tests/builtin/Builtin-String.ycp:70 Warning: lsubstring(...) is deprecated, please fix
[Interpreter] tests/builtin/Builtin-String.ycp:73 Substring index out of range
[Parser] tests/builtin/Builtin-String.ycp:74 Warning: lsubstring(...) is deprecated, please fix
Parsed:
----------------------------------------------------------------------
lsubstring ("ěščřžýáí", 5, 2)
Expand All @@ -174,9 +191,9 @@ Parsed:
----------------------------------------------------------------------
mergestring (["abc", "dev", "ghi", ""], "/")
----------------------------------------------------------------------
[Parser] tests/builtin/Builtin-String.ycp:77 No match for 'mergestring : <unspec> (list, string)'
[Parser] tests/builtin/Builtin-String.ycp:77 Please fix parameter types to match one of:
[Parser] tests/builtin/Builtin-String.ycp:77 'mergestring : string (const list <string>, string)'
[Parser] tests/builtin/Builtin-String.ycp:77 Wrong parameters in call to mergestring(...)
[Parser] tests/builtin/Builtin-String.ycp:77 Expected '(const list <string>, string)', seen '(list, string)'.
[Parser] tests/builtin/Builtin-String.ycp:81 No match for 'mergestring : <unspec> (list, string)'
[Parser] tests/builtin/Builtin-String.ycp:81 Please fix parameter types to match one of:
[Parser] tests/builtin/Builtin-String.ycp:81 'mergestring : string (const list <string>, string)'
[Parser] tests/builtin/Builtin-String.ycp:81 Wrong parameters in call to mergestring(...)
[Parser] tests/builtin/Builtin-String.ycp:81 Expected '(const list <string>, string)', seen '(list, string)'.
runycp: parser error
4 changes: 4 additions & 0 deletions libycp/testsuite/tests/builtin/Builtin-String.out
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
("")
("te")
("")
("")
("")
("text")
("text")
("** lsubstring **")
("text")
("")
Expand Down
4 changes: 4 additions & 0 deletions libycp/testsuite/tests/builtin/Builtin-String.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
(substring ("some text", 5, 2))
(substring ("some text", 42, 2))

(substring ("some text", -1))
(substring ("some text", 5, 0))
(substring ("some text", 5, 42))
(substring ("some text", 5, -42))

("** lsubstring **")

Expand Down
7 changes: 7 additions & 0 deletions package/yast2-core.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jun 2 13:46:02 UTC 2016 - mvidner@suse.com

- Optionally build with Clang instead of GCC (via bcond_with clang)
- Fixed most of Clang warnings.
- 3.1.23

-------------------------------------------------------------------
Thu Mar 3 12:36:06 CET 2016 - gs@suse.de

Expand Down

0 comments on commit d78c2ac

Please sign in to comment.