Conversation
The Clang Static Analyzer[1] encounters some issues parsing
GoogleTest's macros, mostly where GoogleTest has deliberately
attempted to obfuscate the behavour of some code to work around
compiler warnings. Specifically, GTest defines a AlwaysTrue() function
which in reality always returns true, but who's definition lives in a
seperate compilation unit which prevents compilers (and Clang
analyzer) from knowing that certain paths are always (or never)
executed.
The net effect of this is that Clang analyzer raises a number of false
positives. For example consider code of the form:
1 Foo* foo = nullptr;
2 ASSERT_NO_THROW(foo = some_function());
3 foo->bar;
In practice foo is guaranteed to be non-NULL at line 3, as if the
assignment at line 2 failed then we wouldn't have reached line
3. However the expansion of the ASSERT_NO_THROW macro involves code of
the form:
if (AlwaysTrue()) {
try { foo = ... }
} ...
The analyzer doesn't know that the conditional will /always/ be
executed, so it belives there's a path where foo is not initialized at
line 3 and hence raises a report.
Solve this by making the function inline when running with clang
analyzer, un-hiding the definition and allowing Clang to see that the
conditional path is actually unconditional.
[1]: http://clang-analyzer.llvm.org
Change-Id: I72906e9f1f9c283bc52178730c99bf171a7c966a
Re-apply clang analyser fix
* upstream/master: (563 commits) Eliminate GTEST_TEST_FILTER_ENV_VAR_. ignore .md for appveyor builds Docs sync/internal Doc sync/internal Reduce the number of strcmp calling while initialization Sync with internal docs Sync with internal docs Removed "Documentation.md" not adding value and not consitent with internal docs Rename Samples.md to samples.md and adjust the links Rename FAQ.md to faq.md and adjust the links. Rename AdvancedGuide.md to advanced.md and adjust the links. Part of documentation rationalization work Rename "Primer.md" to "primer.md" and adjust links. Part of the documentaion rationalzation Fuchsia: Change fdio include path. Upstream, cl/199129756 Clean up Remvoe launchpad dependency from Fuchsia. formatting changes Formatting changes Downgrade to C++98. Downgrade to C++98 code. ...
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merge all of the changes in the master branch from git://github.com/google/googletest