Add clang support.

This commit is contained in:
James Grogan 2023-01-23 11:32:18 +00:00
parent 3fad113178
commit e559f9674d
27 changed files with 84 additions and 63 deletions

View file

@ -16,7 +16,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(MSVC) if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
elseif(CMAKE_COMPILER_IS_GNUCC) #elseif(CMAKE_COMPILER_IS_GNUCC)
else()
#set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") #set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
#set(GCC_COVERAGE_LINK_FLAGS "-lgcov") #set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")

View file

@ -36,7 +36,7 @@ void TextEditorView::initialize()
saveButton->setBackground(Theme::Sys::Color::Primary); saveButton->setBackground(Theme::Sys::Color::Primary);
saveButton->setMargin(2); saveButton->setMargin(2);
auto onSave = [this](Widget* self){ auto onSave = [this](Widget* self){
if(this && mController && mTextBox) if(mController && mTextBox)
{ {
mController->SetContent(mTextBox->getContent()); mController->SetContent(mTextBox->getContent());
mController->OnSave(); mController->OnSave();
@ -48,7 +48,7 @@ void TextEditorView::initialize()
clearButton->setLabel("Clear"); clearButton->setLabel("Clear");
clearButton->setMargin(2); clearButton->setMargin(2);
auto onClear = [this](Widget* self){ auto onClear = [this](Widget* self){
if(this && mController && mTextBox) if(mController && mTextBox)
{ {
mController->OnClear(); mController->OnClear();
mTextBox->setContent(""); mTextBox->setContent("");
@ -60,7 +60,7 @@ void TextEditorView::initialize()
loadButton->setLabel("Load"); loadButton->setLabel("Load");
loadButton->setMargin(2); loadButton->setMargin(2);
auto onLoad = [this](Widget* self){ auto onLoad = [this](Widget* self){
if(this && mController && mTextBox) if(mController && mTextBox)
{ {
mController->OnLoad(); mController->OnLoad();
mTextBox->setContent(mController->GetContent()); mTextBox->setContent(mController->GetContent());

View file

@ -0,0 +1,20 @@
# Compiler Support
## Linux
### GCC
gcc 11.3.0
### clang
```
sudo apt-get install clang
mkdir build_clang
cd build_clang
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
cmake $PATH_TO_SOURCE
make
```
Version 14.0

View file

@ -28,8 +28,7 @@ public:
private: private:
std::string mLabel; std::string mLabel;
bool mValue{ false };
TerminalType mType; TerminalType mType;
Wire* mConnection{ nullptr }; Wire* mConnection{ nullptr };
}; };
using TerminalPtr = std::unique_ptr<Terminal>; using TerminalPtr = std::unique_ptr<Terminal>;

View file

@ -6,27 +6,27 @@
class TruthTable class TruthTable
{ {
public: public:
using TableData = std::map<std::vector<bool>, std::vector<bool> >; using TableData = std::map<std::vector<bool>, std::vector<bool> >;
TruthTable(std::size_t numInputColumns, std::size_t numOutputColumns) TruthTable(std::size_t numInputColumns, std::size_t numOutputColumns)
: mNumInputColumns(numInputColumns), //: mNumInputColumns(numInputColumns),
mNumOutputColumns(numOutputColumns) // mNumOutputColumns(numOutputColumns)
{ {
} }
void setTable(const TableData& data) void setTable(const TableData& data)
{ {
mTable = data; mTable = data;
} }
static TruthTable getAndTruthTable(); static TruthTable getAndTruthTable();
static const TruthTable::TableData AND_TRUTH_TABLE; static const TruthTable::TableData AND_TRUTH_TABLE;
private: private:
std::size_t mNumInputColumns{ 0 }; //std::size_t mNumInputColumns{ 0 };
std::size_t mNumOutputColumns{ 0 }; //std::size_t mNumOutputColumns{ 0 };
TableData mTable; TableData mTable;
}; };

View file

@ -49,7 +49,6 @@ private:
void dumpNode(RawNode<CountPair>* node, unsigned depth) const; void dumpNode(RawNode<CountPair>* node, unsigned depth) const;
bool mUseFixedCode{false}; bool mUseFixedCode{false};
bool mTableIsInitialized{false};
std::vector<unsigned char> mSymbolMapping; std::vector<unsigned char> mSymbolMapping;
HuffmanCodeLengthTable mLiteralLengthTable; HuffmanCodeLengthTable mLiteralLengthTable;

View file

@ -30,7 +30,6 @@ public:
KeyValuePairs getKeyValuePairs() const; KeyValuePairs getKeyValuePairs() const;
private: private:
unsigned mLineOffset{ 0 };
std::string mHeader; std::string mHeader;
std::unordered_map<std::string, std::unique_ptr<TomlTable> > mTables; std::unordered_map<std::string, std::unique_ptr<TomlTable> > mTables;
KeyValuePairs mMap; KeyValuePairs mMap;

View file

@ -25,6 +25,5 @@ public:
void writeBytes(const std::vector<unsigned char> data) override; void writeBytes(const std::vector<unsigned char> data) override;
private: private:
unsigned mBufferSize{0};
std::vector<unsigned char> mBuffer; std::vector<unsigned char> mBuffer;
}; };

View file

@ -9,6 +9,11 @@ AbstractGrid::AbstractGrid(const Bounds& bounds, std::size_t numPointsX, std::si
} }
AbstractGrid::~AbstractGrid()
{
}
const Bounds& AbstractGrid::getBounds() const const Bounds& AbstractGrid::getBounds() const
{ {
return mBounds; return mBounds;
@ -29,4 +34,4 @@ double AbstractGrid::getYSpacing() const
void AbstractGrid::resetBounds(const Bounds& bounds) void AbstractGrid::resetBounds(const Bounds& bounds)
{ {
mBounds = bounds; mBounds = bounds;
} }

View file

@ -10,6 +10,8 @@ class AbstractGrid
public: public:
AbstractGrid(const Bounds& bounds, std::size_t numPointsX, std::size_t numPointsY, std::size_t numPointsZ = 1); AbstractGrid(const Bounds& bounds, std::size_t numPointsX, std::size_t numPointsY, std::size_t numPointsZ = 1);
virtual ~AbstractGrid();
const Bounds& getBounds() const; const Bounds& getBounds() const;
virtual std::size_t getDataSize() const = 0; virtual std::size_t getDataSize() const = 0;
@ -25,4 +27,4 @@ protected:
std::size_t mNumX{ 0 }; std::size_t mNumX{ 0 };
std::size_t mNumY{ 0 }; std::size_t mNumY{ 0 };
std::size_t mNumZ{ 0 }; std::size_t mNumZ{ 0 };
}; };

View file

@ -32,7 +32,7 @@ public:
this->mData->setItem(getOffset(idx, jdx, kdx), value); this->mData->setItem(getOffset(idx, jdx, kdx), value);
} }
std::size_t getDataSize() const std::size_t getDataSize() const override
{ {
return this->mData->getLength(); return this->mData->getLength();
} }

View file

@ -14,7 +14,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
UnixSocketInterface::UnixSocketInterface() UnixSocketInterface::UnixSocketInterface()
: mBufferSize(1024)
{ {
mMessageHandler = std::make_unique<HttpMessageHandler>(); mMessageHandler = std::make_unique<HttpMessageHandler>();
} }

View file

@ -27,7 +27,6 @@ public:
private: private:
static constexpr unsigned BUFFER_SIZE{1024}; static constexpr unsigned BUFFER_SIZE{1024};
std::size_t mBufferSize { 0 };
std::unique_ptr<ISocketMessageHandler> mMessageHandler; std::unique_ptr<ISocketMessageHandler> mMessageHandler;
}; };

View file

@ -9,20 +9,22 @@ class Image;
class IImageWriter class IImageWriter
{ {
public: public:
enum class ImgFormat enum class ImgFormat
{ {
PNG, PNG,
UNKNOWN UNKNOWN
}; };
IImageWriter(ImgFormat format) IImageWriter(ImgFormat format)
: mFormat(format) : mFormat(format)
{ {
};
virtual void write(const Path& path, Image* image) = 0; };
virtual ~IImageWriter() = default;
virtual void write(const Path& path, Image* image) = 0;
protected: protected:
ImgFormat mFormat{ ImgFormat::UNKNOWN }; ImgFormat mFormat{ ImgFormat::UNKNOWN };
}; };

View file

@ -19,7 +19,7 @@ public:
std::string toString(PdfXRefTable* xRefTable) override; std::string toString(PdfXRefTable* xRefTable) override;
void updateDictionary(); void updateDictionary() override;
private: private:
std::vector<PdfOutlinePtr> mOutlines; std::vector<PdfOutlinePtr> mOutlines;

View file

@ -17,7 +17,7 @@ class PdfFont : public PdfObject
public: public:
std::string toString(PdfXRefTable* xRefTable) override; std::string toString(PdfXRefTable* xRefTable) override;
void updateDictionary(); void updateDictionary() override;
}; };
class PdfPage : public PdfObject class PdfPage : public PdfObject
@ -25,11 +25,11 @@ class PdfPage : public PdfObject
public: public:
PdfPage(PdfPageTree* parent); PdfPage(PdfPageTree* parent);
unsigned indexObjects(unsigned count); unsigned indexObjects(unsigned count) override;
std::string toString(PdfXRefTable* xRefTable) override; std::string toString(PdfXRefTable* xRefTable) override;
void updateDictionary(); void updateDictionary() override;
private: private:
unsigned mWidth{612}; unsigned mWidth{612};

View file

@ -20,7 +20,7 @@ public:
std::size_t getNumNodes() const override; std::size_t getNumNodes() const override;
void replaceEdge(Edge* original, Edge* replacement); void replaceEdge(Edge* original, Edge* replacement) override;
std::size_t getEdge0Id () const; std::size_t getEdge0Id () const;
std::size_t getEdge1Id () const; std::size_t getEdge1Id () const;

View file

@ -11,5 +11,5 @@ public:
std::unique_ptr<AbstractMesh> copy() const override; std::unique_ptr<AbstractMesh> copy() const override;
MeshType getType() const; MeshType getType() const override;
}; };

View file

@ -12,10 +12,10 @@ class LineNode : public GeometryNode
public: public:
LineNode(const Transform& transform, const std::vector<Point>& points); LineNode(const Transform& transform, const std::vector<Point>& points);
Type getType(); Type getType() override;
private: private:
void createOrUpdateGeometry(SceneInfo* sceneInfo) override; void createOrUpdateGeometry(SceneInfo* sceneInfo) override;
std::vector<Point> mPoints; std::vector<Point> mPoints;
}; };

View file

@ -135,6 +135,7 @@ void TextNode::updateLines(FontsManager* fontsManager)
} }
output_lines.push_back(working_line); output_lines.push_back(working_line);
running_width = 0; running_width = 0;
(void)running_width;
} }
mTextData.mLines = output_lines; mTextData.mLines = output_lines;

View file

@ -42,6 +42,5 @@ private:
std::unique_ptr<AbstractGeometricItem> mGeometry; std::unique_ptr<AbstractGeometricItem> mGeometry;
bool mGeometryIsDirty{true}; bool mGeometryIsDirty{true};
bool mColorMapIsDirty{true};
bool mShowOutline{false}; bool mShowOutline{false};
}; };

View file

@ -120,7 +120,7 @@ void SvgPainter::setStyle(SceneModel* model, SvgShapeElement* element) const
if (!transform.isDefaultTransform()) if (!transform.isDefaultTransform())
{ {
element->addAttribute(std::move(toTransform(transform))); element->addAttribute(toTransform(transform));
} }
} }

View file

@ -43,7 +43,7 @@ void TabbedPanelWidget::addPanel(WidgetUPtr panel, const std::string& label)
auto rawPanel = panel.get(); auto rawPanel = panel.get();
auto onClick = [this, rawPanel](Widget*){ auto onClick = [this, rawPanel](Widget*){
if(this && rawPanel) if(rawPanel)
{ {
this->getStack()->showChild(rawPanel); this->getStack()->showChild(rawPanel);
} }

View file

@ -17,12 +17,9 @@ TopBar::TopBar()
fileButton->setMaxWidth(60); fileButton->setMaxWidth(60);
auto onClick = [this](Widget* self){ auto onClick = [this](Widget* self){
if(this) auto menu = std::make_unique<TopBarMenu>();
{ auto window = getTopLevelWindow();
auto menu = std::make_unique<TopBarMenu>(); window->addPopup(std::move(menu));
auto window = getTopLevelWindow();
window->addPopup(std::move(menu));
};
}; };
fileButton->setOnClickFunction(onClick); fileButton->setOnClickFunction(onClick);
addWidget(std::move(fileButton)); addWidget(std::move(fileButton));

View file

@ -12,8 +12,7 @@
TextBox::TextBox() TextBox::TextBox()
: Widget(), : Widget(),
mContent(), mContent()
mCaps(false)
{ {
mBackground = Theme::Sys::Color::Background; mBackground = Theme::Sys::Color::Background;
mPadding = {20, 0, 20, 0}; mPadding = {20, 0, 20, 0};

View file

@ -32,7 +32,6 @@ private:
std::string mContent; std::string mContent;
std::unique_ptr<TextNode> mTextNode; std::unique_ptr<TextNode> mTextNode;
bool mContentDirty{true}; bool mContentDirty{true};
bool mCaps;
}; };
using TextBoxUPtr = std::unique_ptr<TextBox>; using TextBoxUPtr = std::unique_ptr<TextBox>;

View file

@ -47,4 +47,6 @@ class ITheme
{ {
public: public:
virtual Color getColor(Theme::Sys::Color token) const = 0; virtual Color getColor(Theme::Sys::Color token) const = 0;
virtual ~ITheme() = default;
}; };