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
Added list of false positiitives #3999
Open
akhtarmdsaad
wants to merge
3
commits into
highlightjs:main
Choose a base branch
from
akhtarmdsaad:fix/issue-3980
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,93 @@ | ||
<span class="hljs-keyword">alignas</span>(<span class="hljs-number">16</span>) <span class="hljs-type">char</span> aligned_buffer[<span class="hljs-number">1024</span>]; | ||
<span class="hljs-keyword">alignof</span>(<span class="hljs-keyword">decltype</span>(aligned_buffer)) | ||
<span class="hljs-keyword">asm</span>(<span class="hljs-string">"movl $1, %eax"</span>); | ||
<span class="hljs-keyword">try</span> { | ||
<span class="hljs-keyword">throw</span> std::<span class="hljs-built_in">runtime_error</span>(<span class="hljs-string">"An exception occurred"</span>); | ||
} <span class="hljs-keyword">catch</span> (<span class="hljs-type">const</span> std::exception& e) { | ||
std::cout << <span class="hljs-string">"Caught exception: "</span> << e.<span class="hljs-built_in">what</span>() << std::endl; | ||
} | ||
<span class="hljs-type">const</span> <span class="hljs-type">int</span>* p = <span class="hljs-literal">nullptr</span>; | ||
<span class="hljs-type">int</span>* mutable_p = <span class="hljs-keyword">const_cast</span><<span class="hljs-type">int</span>*>(p); | ||
<span class="hljs-type">int</span> x = <span class="hljs-number">5</span>; | ||
<span class="hljs-keyword">decltype</span>(x) y = <span class="hljs-number">10</span>; | ||
Animal* animal = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Dog</span>(); | ||
<span class="hljs-keyword">if</span> (Dog* dog = <span class="hljs-keyword">dynamic_cast</span><Dog*>(animal)) { | ||
std::cout << <span class="hljs-string">"Dynamic cast successful"</span> << std::endl; | ||
} <span class="hljs-keyword">else</span> { | ||
std::cout << <span class="hljs-string">"Dynamic cast failed"</span> << std::endl; | ||
} | ||
<span class="hljs-function"><span class="hljs-type">int</span> <span class="hljs-title">add</span><span class="hljs-params">(<span class="hljs-type">int</span> a, <span class="hljs-type">int</span> b)</span> <span class="hljs-keyword">noexcept</span> </span>{ | ||
<span class="hljs-keyword">return</span> a + b; | ||
} | ||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">noexcept</span>(<span class="hljs-built_in">add</span>(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>))) { | ||
<span class="hljs-comment">// The add function will not throw an exception.</span> | ||
} <span class="hljs-keyword">else</span> { | ||
<span class="hljs-comment">// The add function may throw an exception.</span> | ||
} | ||
<span class="hljs-type">int</span> value = <span class="hljs-number">10</span>; | ||
<span class="hljs-type">double</span>* ptr = <span class="hljs-keyword">reinterpret_cast</span><<span class="hljs-type">double</span>*>(&value); | ||
std::cout << <span class="hljs-string">"Size of int: "</span> << <span class="hljs-keyword">sizeof</span>(<span class="hljs-type">int</span>) << <span class="hljs-string">" bytes"</span> << std::endl; | ||
<span class="hljs-keyword">static_assert</span>(<span class="hljs-keyword">sizeof</span>(<span class="hljs-type">int</span>) == <span class="hljs-number">4</span>, <span class="hljs-string">"int must be 4 bytes"</span>); | ||
<span class="hljs-type">float</span> z = <span class="hljs-keyword">static_cast</span><<span class="hljs-type">float</span>>(<span class="hljs-number">10</span>); | ||
<span class="hljs-type">int</span> choice = <span class="hljs-number">2</span>; | ||
<span class="hljs-keyword">switch</span>(choice) { | ||
<span class="hljs-keyword">case</span> <span class="hljs-number">1</span>: | ||
std::cout << <span class="hljs-string">"Choice is 1"</span> << std::endl; | ||
<span class="hljs-keyword">break</span>; | ||
<span class="hljs-keyword">case</span> <span class="hljs-number">2</span>: | ||
std::cout << <span class="hljs-string">"Choice is 2"</span> << std::endl; | ||
<span class="hljs-keyword">break</span>; | ||
<span class="hljs-keyword">default</span>: | ||
std::cout << <span class="hljs-string">"Choice is not 1 or 2"</span> << std::endl; | ||
} | ||
std::cout << <span class="hljs-string">"Type of x: "</span> << <span class="hljs-keyword">typeid</span>(x).<span class="hljs-built_in">name</span>() << std::endl; | ||
<span class="hljs-type">int</span> i = <span class="hljs-number">0</span>; | ||
<span class="hljs-keyword">while</span>(i < <span class="hljs-number">5</span>) { | ||
std::cout << <span class="hljs-string">"Iteration "</span> << i << std::endl; | ||
i++; | ||
} | ||
<span class="hljs-comment">// requires</span> | ||
<span class="hljs-keyword">template</span><<span class="hljs-keyword">class</span> <span class="hljs-title class_">T</span>> | ||
<span class="hljs-keyword">concept</span> dereferenceable = | ||
<span class="hljs-keyword">requires</span> { <span class="hljs-keyword">typename</span> <span class="hljs-type">iter_value_t</span><I>; } <span class="hljs-function"><span class="hljs-keyword">and</span> | ||
<span class="hljs-title">requires</span><span class="hljs-params">(I i)</span> </span>{ | ||
*i; | ||
}; | ||
|
||
<span class="hljs-comment">// explicit</span> | ||
<span class="hljs-keyword">template</span><<span class="hljs-keyword">class</span> <span class="hljs-title class_">T</span>> | ||
<span class="hljs-keyword">struct</span> <span class="hljs-title class_">S</span> { | ||
<span class="hljs-keyword">explicit</span>(weakly_incrementable<T>) <span class="hljs-built_in">S</span>(); | ||
}; | ||
|
||
<span class="hljs-comment">// auto, operators</span> | ||
<span class="hljs-function"><span class="hljs-type">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> | ||
</span>{ | ||
<span class="hljs-keyword">auto</span> x = <span class="hljs-keyword">auto</span>(<span class="hljs-number">0</span>); | ||
x bitand_eq x; <span class="hljs-comment">// needs to be added too</span> | ||
<span class="hljs-function">x <span class="hljs-title">bitand_eq</span> <span class="hljs-params">(x)</span></span>; | ||
x bitor_eq x; <span class="hljs-comment">// needs to be added too</span> | ||
<span class="hljs-function">x <span class="hljs-title">bitor_eq</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">xor</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">xor</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">and</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">and</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">or</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">or</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">bitand</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">bitand</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">bitor</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">bitor</span> <span class="hljs-params">(x)</span></span>; | ||
x <span class="hljs-keyword">not_eq</span> x; | ||
<span class="hljs-function">x <span class="hljs-title">not_eq</span> <span class="hljs-params">(x)</span></span>; | ||
<span class="hljs-keyword">not</span> x; | ||
<span class="hljs-keyword">not</span> (x); | ||
<span class="hljs-keyword">compl</span> x; | ||
<span class="hljs-keyword">compl</span> (x); | ||
<span class="hljs-keyword">co_await</span> x; | ||
<span class="hljs-keyword">co_await</span> (x); | ||
<span class="hljs-keyword">co_return</span> x; | ||
<span class="hljs-keyword">co_return</span> (x); | ||
<span class="hljs-keyword">co_yield</span> x; | ||
<span class="hljs-keyword">co_yield</span> (x); | ||
} |
This file contains 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,93 @@ | ||
alignas(16) char aligned_buffer[1024]; | ||
alignof(decltype(aligned_buffer)) | ||
asm("movl $1, %eax"); | ||
try { | ||
throw std::runtime_error("An exception occurred"); | ||
} catch (const std::exception& e) { | ||
std::cout << "Caught exception: " << e.what() << std::endl; | ||
} | ||
const int* p = nullptr; | ||
int* mutable_p = const_cast<int*>(p); | ||
int x = 5; | ||
decltype(x) y = 10; | ||
Animal* animal = new Dog(); | ||
if (Dog* dog = dynamic_cast<Dog*>(animal)) { | ||
std::cout << "Dynamic cast successful" << std::endl; | ||
} else { | ||
std::cout << "Dynamic cast failed" << std::endl; | ||
} | ||
int add(int a, int b) noexcept { | ||
return a + b; | ||
} | ||
if (noexcept(add(1, 2))) { | ||
// The add function will not throw an exception. | ||
} else { | ||
// The add function may throw an exception. | ||
} | ||
int value = 10; | ||
double* ptr = reinterpret_cast<double*>(&value); | ||
std::cout << "Size of int: " << sizeof(int) << " bytes" << std::endl; | ||
static_assert(sizeof(int) == 4, "int must be 4 bytes"); | ||
float z = static_cast<float>(10); | ||
int choice = 2; | ||
switch(choice) { | ||
case 1: | ||
std::cout << "Choice is 1" << std::endl; | ||
break; | ||
case 2: | ||
std::cout << "Choice is 2" << std::endl; | ||
break; | ||
default: | ||
std::cout << "Choice is not 1 or 2" << std::endl; | ||
} | ||
std::cout << "Type of x: " << typeid(x).name() << std::endl; | ||
int i = 0; | ||
while(i < 5) { | ||
std::cout << "Iteration " << i << std::endl; | ||
i++; | ||
} | ||
// requires | ||
template<class T> | ||
concept dereferenceable = | ||
requires { typename iter_value_t<I>; } and | ||
requires(I i) { | ||
*i; | ||
}; | ||
|
||
// explicit | ||
template<class T> | ||
struct S { | ||
explicit(weakly_incrementable<T>) S(); | ||
}; | ||
|
||
// auto, operators | ||
int main() | ||
{ | ||
auto x = auto(0); | ||
x bitand_eq x; // needs to be added too | ||
x bitand_eq (x); | ||
x bitor_eq x; // needs to be added too | ||
x bitor_eq (x); | ||
x xor x; | ||
x xor (x); | ||
x and x; | ||
x and (x); | ||
x or x; | ||
x or (x); | ||
x bitand x; | ||
x bitand (x); | ||
x bitor x; | ||
x bitor (x); | ||
x not_eq x; | ||
x not_eq (x); | ||
not x; | ||
not (x); | ||
compl x; | ||
compl (x); | ||
co_await x; | ||
co_await (x); | ||
co_return x; | ||
co_return (x); | ||
co_yield x; | ||
co_yield (x); | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these types really working properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is already working properly. No need to change anything.