File tree Expand file tree Collapse file tree 10 files changed +568
-2
lines changed Expand file tree Collapse file tree 10 files changed +568
-2
lines changed Original file line number Diff line number Diff line change @@ -299,8 +299,7 @@ Example usage for a project using a compile commands database:
299299 llvm::outs () << " Generating assets for docs...\n " ;
300300 Err = G->get ()->createResources (CDCtx);
301301 if (Err) {
302- llvm::errs () << toString (std::move (Err)) << " \n " ;
303- return 1 ;
302+ llvm::outs () << " warning: " << toString (std::move (Err)) << " \n " ;
304303 }
305304
306305 return 0 ;
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "directory" : " $test_dir/Inputs/basic-project" ,
4+ "command" : " clang++ -o Calculator.o -I./include ./src/Calculator.cpp" ,
5+ "file" : " ./src/Calculator.cpp"
6+ },
7+ {
8+ "directory" : " $test_dir/Inputs/basic-project" ,
9+ "command" : " clang++ -o Circle.o -I./include ./src/Circle.cpp" ,
10+ "file" : " ./src/Circle.cpp"
11+ },
12+ {
13+ "directory" : " $test_dir/Inputs/basic-project" ,
14+ "command" : " clang++ -o Rectangle.o -I./include ./src/Rectangle.cpp" ,
15+ "file" : " ./src/Rectangle.cpp"
16+ }
17+ ]
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ /* *
4+ * @brief A simple calculator class.
5+ *
6+ * Provides basic arithmetic operations.
7+ */
8+ class Calculator {
9+ public:
10+ /* *
11+ * @brief Adds two integers.
12+ *
13+ * @param a First integer.
14+ * @param b Second integer.
15+ * @return int The sum of a and b.
16+ */
17+ int add (int a, int b);
18+
19+ /* *
20+ * @brief Subtracts the second integer from the first.
21+ *
22+ * @param a First integer.
23+ * @param b Second integer.
24+ * @return int The result of a - b.
25+ */
26+ int subtract (int a, int b);
27+
28+ /* *
29+ * @brief Multiplies two integers.
30+ *
31+ * @param a First integer.
32+ * @param b Second integer.
33+ * @return int The product of a and b.
34+ */
35+ int multiply (int a, int b);
36+
37+ /* *
38+ * @brief Divides the first integer by the second.
39+ *
40+ * @param a First integer.
41+ * @param b Second integer.
42+ * @return double The result of a / b.
43+ * @throw std::invalid_argument if b is zero.
44+ */
45+ double divide (int a, int b);
46+ };
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " Shape.h"
4+
5+ /* *
6+ * @brief Circle class derived from Shape.
7+ *
8+ * Represents a circle with a given radius.
9+ */
10+ class Circle : public Shape {
11+ public:
12+ /* *
13+ * @brief Constructs a new Circle object.
14+ *
15+ * @param radius Radius of the circle.
16+ */
17+ Circle (double radius);
18+
19+ /* *
20+ * @brief Calculates the area of the circle.
21+ *
22+ * @return double The area of the circle.
23+ */
24+ double area () const override ;
25+
26+ /* *
27+ * @brief Calculates the perimeter of the circle.
28+ *
29+ * @return double The perimeter of the circle.
30+ */
31+ double perimeter () const override ;
32+
33+ private:
34+ double radius_; // /< Radius of the circle.
35+ };
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " Shape.h"
4+
5+ /* *
6+ * @brief Rectangle class derived from Shape.
7+ *
8+ * Represents a rectangle with a given width and height.
9+ */
10+ class Rectangle : public Shape {
11+ public:
12+ /* *
13+ * @brief Constructs a new Rectangle object.
14+ *
15+ * @param width Width of the rectangle.
16+ * @param height Height of the rectangle.
17+ */
18+ Rectangle (double width, double height);
19+
20+ /* *
21+ * @brief Calculates the area of the rectangle.
22+ *
23+ * @return double The area of the rectangle.
24+ */
25+ double area () const override ;
26+
27+ /* *
28+ * @brief Calculates the perimeter of the rectangle.
29+ *
30+ * @return double The perimeter of the rectangle.
31+ */
32+ double perimeter () const override ;
33+
34+ private:
35+ double width_; // /< Width of the rectangle.
36+ double height_; // /< Height of the rectangle.
37+ };
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ /* *
4+ * @brief Abstract base class for shapes.
5+ *
6+ * Provides a common interface for different types of shapes.
7+ */
8+ class Shape {
9+ public:
10+ /* *
11+ * @brief Virtual destructor.
12+ */
13+ virtual ~Shape () {}
14+
15+ /* *
16+ * @brief Calculates the area of the shape.
17+ *
18+ * @return double The area of the shape.
19+ */
20+ virtual double area () const = 0;
21+
22+ /* *
23+ * @brief Calculates the perimeter of the shape.
24+ *
25+ * @return double The perimeter of the shape.
26+ */
27+ virtual double perimeter () const = 0;
28+ };
29+
30+
Original file line number Diff line number Diff line change 1+ #include " Calculator.h"
2+ #include < stdexcept>
3+
4+ int Calculator::add (int a, int b) {
5+ return a + b;
6+ }
7+
8+ int Calculator::subtract (int a, int b) {
9+ return a - b;
10+ }
11+
12+ int Calculator::multiply (int a, int b) {
13+ return a * b;
14+ }
15+
16+ double Calculator::divide (int a, int b) {
17+ if (b == 0 ) {
18+ throw std::invalid_argument (" Division by zero" );
19+ }
20+ return static_cast <double >(a) / b;
21+ }
Original file line number Diff line number Diff line change 1+ #include " Circle.h"
2+
3+ Circle::Circle (double radius) : radius_(radius) {}
4+
5+ double Circle::area () const {
6+ return 3.141 * radius_ * radius_;
7+ }
8+
9+ double Circle::perimeter () const {
10+ return 3.141 * radius_;
11+ }
Original file line number Diff line number Diff line change 1+ #include " Rectangle.h"
2+
3+ Rectangle::Rectangle (double width, double height)
4+ : width_(width), height_(height) {}
5+
6+ double Rectangle::area () const {
7+ return width_ * height_;
8+ }
9+
10+ double Rectangle::perimeter () const {
11+ return 2 * (width_ + height_);
12+ }
You can’t perform that action at this time.
0 commit comments