-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-doc] Add another test project to clang-doc #97518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a1a157a
[clang-doc] add more tests
PeterChou1 83090be
[clang-doc] add more tests
PeterChou1 263d400
[clang-doc] clean up command
PeterChou1 6e02df6
[clang-doc] remove boilerplate from testcase
PeterChou1 defda73
[clang-doc] add internal comments
PeterChou1 3ffd56a
[clang-doc] add regex to test
PeterChou1 d3988c7
[clang-doc] fix tests lines
PeterChou1 a91a6a7
[clang-doc] fix path separator
PeterChou1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
clang-tools-extra/test/clang-doc/Inputs/advance-project/database_template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"directory": "$test_dir/Inputs/advance-project", | ||
"command": "clang++ -o Array.o -I./include ./src/Array.cpp", | ||
"file": "./src/Array.cpp" | ||
}, | ||
{ | ||
"directory": "$test_dir/Inputs/advance-project", | ||
"command": "clang++ -o Circle.o -I./include ./src/Circle.cpp", | ||
"file": "./src/Circle.cpp" | ||
}, | ||
{ | ||
"directory": "$test_dir/Inputs/advance-project", | ||
"command": "clang++ -o Shape.o -I./include ./src/Shape.cpp", | ||
"file": "./src/Shape.cpp" | ||
}, | ||
{ | ||
"directory": "$test_dir/Inputs/advance-project", | ||
"command": "clang++ -o Utils.o -I./include ./src/Utils.cpp", | ||
"file": "./src/Utils.cpp" | ||
} | ||
] |
35 changes: 35 additions & 0 deletions
35
clang-tools-extra/test/clang-doc/Inputs/advance-project/include/Array.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
/** @brief Maximum size for the IntArray typedef */ | ||
#define MAX_SIZE 100 | ||
|
||
/** | ||
* @brief Template class for a simple array | ||
* | ||
* @tparam T The type of elements in the array | ||
* @tparam Size The fixed size of the array | ||
*/ | ||
template <typename T, int Size> | ||
class Array { | ||
public: | ||
/** @brief Default constructor */ | ||
Array(); | ||
|
||
/** | ||
* @brief Array access operator | ||
* | ||
* @param index The index of the element to access | ||
* @return T& Reference to the element at the given index | ||
*/ | ||
T& operator[](int index); | ||
|
||
/** | ||
* @brief Get the size of the array | ||
* | ||
* @return int The size of the array | ||
*/ | ||
int size() const; | ||
|
||
private: | ||
T m_data[Size]; /**< The array data */ | ||
}; |
32 changes: 32 additions & 0 deletions
32
clang-tools-extra/test/clang-doc/Inputs/advance-project/include/Circle.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "Shape.h" | ||
#include "Utils.h" | ||
|
||
namespace OuterNamespace { | ||
namespace InnerNamespace { | ||
/** | ||
* @brief Circle class, derived from Shape | ||
*/ | ||
class Circle : public Shape { | ||
public: | ||
/** | ||
* @brief Constructor | ||
* | ||
* @param id The unique identifier for the circle | ||
* @param radius The radius of the circle | ||
*/ | ||
Circle(int id, double radius); | ||
|
||
/** | ||
* @brief Implementation of the draw function | ||
* | ||
* Draws the circle (in this case, prints circle information) | ||
*/ | ||
void draw() const override; | ||
|
||
private: | ||
double m_radius; /**< The radius of the circle */ | ||
}; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
clang-tools-extra/test/clang-doc/Inputs/advance-project/include/Shape.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
/// Outer namespace | ||
namespace OuterNamespace { | ||
/// Inner namespace | ||
namespace InnerNamespace { | ||
/** | ||
* @brief Enum class for colors | ||
*/ | ||
enum class Color { | ||
Red, /**< Red color */ | ||
Green, /**< Green color */ | ||
Blue /**< Blue color */ | ||
}; | ||
|
||
/** | ||
* @brief Abstract base class for shapes | ||
*/ | ||
class Shape { | ||
public: | ||
/** | ||
* @brief Constructor | ||
* | ||
* @param id The unique identifier for the shape | ||
*/ | ||
explicit Shape(int id); | ||
|
||
/** | ||
* @brief Virtual destructor | ||
*/ | ||
virtual ~Shape(); | ||
|
||
/** | ||
* @brief Pure virtual function for drawing the shape | ||
*/ | ||
virtual void draw() const = 0; | ||
|
||
/** | ||
* @brief Getter for the shape's ID | ||
* | ||
* @return int The shape's ID | ||
*/ | ||
int getId() const; | ||
|
||
private: | ||
int m_id; /**< The shape's unique identifier */ | ||
}; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
clang-tools-extra/test/clang-doc/Inputs/advance-project/include/Utils.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
/// Anonymous namespace for utility functions | ||
namespace { | ||
/** | ||
* @brief Generate a "random" number | ||
* | ||
* @note This is not actually random in this implementation | ||
* | ||
* @return int A predetermined "random" number | ||
*/ | ||
int getRandomNumber(); | ||
|
||
/** | ||
* @brief Helper function to convert int to string | ||
* | ||
* @param value The integer value to convert | ||
* @param buffer The char buffer to store the result | ||
* @param index Reference to the current index in the buffer | ||
*/ | ||
void intToString(int value, char* buffer, int& index); | ||
|
||
/** | ||
* @brief Helper function to convert double to string (simplified) | ||
* | ||
* @param value The double value to convert | ||
* @param buffer The char buffer to store the result | ||
* @param index Reference to the current index in the buffer | ||
*/ | ||
void doubleToString(double value, char* buffer, int& index); | ||
|
||
/** | ||
* @brief Helper function to print a string | ||
* | ||
* @param str The null-terminated string to print | ||
*/ | ||
void print(const char* str); | ||
} |
31 changes: 31 additions & 0 deletions
31
clang-tools-extra/test/clang-doc/Inputs/advance-project/src/Array.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "Array.h" | ||
|
||
// Implementation of Array<T, Size> | ||
|
||
/** | ||
* Initializes all elements of the array to their default value. | ||
*/ | ||
template <typename T, int Size> | ||
Array<T, Size>::Array() { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* Array access operator for Array<T, Size> | ||
* Provides read and write access to elements in the array. | ||
* This implementation does not perform bounds checking | ||
*/ | ||
template <typename T, int Size> | ||
T& Array<T, Size>::operator[](int index) { | ||
// Implementation stub | ||
static T dummy; | ||
return dummy; | ||
} | ||
|
||
/** | ||
* Get the size of the array for Array<T, Size> | ||
*/ | ||
template <typename T, int Size> | ||
int Array<T, Size>::size() const { | ||
return Size; | ||
} |
24 changes: 24 additions & 0 deletions
24
clang-tools-extra/test/clang-doc/Inputs/advance-project/src/Circle.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "Circle.h" | ||
|
||
namespace OuterNamespace { | ||
namespace InnerNamespace { | ||
|
||
/** | ||
* Initializes a Circle object with a given ID and radius. | ||
*/ | ||
Circle::Circle(int id, double radius) : Shape(id), m_radius(radius) { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* This function is responsible for drawing the circle. In a real | ||
* implementation, this would perform the actual drawing operation. | ||
* In this stub implementation, it simply prints information about | ||
* the circle. | ||
*/ | ||
void Circle::draw() const { | ||
// Implementation stub | ||
} | ||
|
||
} // namespace InnerNamespace | ||
} // namespace OuterNamespace |
28 changes: 28 additions & 0 deletions
28
clang-tools-extra/test/clang-doc/Inputs/advance-project/src/Shape.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "Shape.h" | ||
|
||
namespace OuterNamespace { | ||
namespace InnerNamespace { | ||
|
||
/** | ||
* Initializes a Shape object with a given ID. | ||
*/ | ||
Shape::Shape(int id) : m_id(id) { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* Ensures proper cleanup of derived classes. | ||
*/ | ||
Shape::~Shape() { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* Get unique identifier of the shape | ||
*/ | ||
int Shape::getId() const { | ||
return m_id; | ||
} | ||
|
||
} // namespace InnerNamespace | ||
} // namespace OuterNamespace |
37 changes: 37 additions & 0 deletions
37
clang-tools-extra/test/clang-doc/Inputs/advance-project/src/Utils.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "Utils.h" | ||
|
||
namespace { | ||
|
||
/** | ||
* This function returns a predetermined number to simulate randomness. | ||
* In a real implementation, this would use a proper random number generator | ||
*/ | ||
int getRandomNumber() { | ||
// Implementation stub | ||
return 4; | ||
} | ||
|
||
/** | ||
* Converts an integer value to its string representation and stores | ||
* the result in the provided buffer. | ||
*/ | ||
void intToString(int value, char* buffer, int& index) { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* Converts a double value to its string representation with two decimal | ||
* places and stores the result in the provided buffer. | ||
*/ | ||
void doubleToString(double value, char* buffer, int& index) { | ||
// Implementation stub | ||
} | ||
|
||
/** | ||
* Prints the provided null-terminated string to the standard output. | ||
*/ | ||
void print(const char* str) { | ||
// Implementation stub | ||
} | ||
|
||
} // anonymous namespace |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.