diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index ef0d00ca89..e0a0216900 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -835,6 +835,7 @@ named_patterns: - '^[ \t]*catch\s*\(' - '^[ \t]*(class|(using[ \t]+)?namespace)\s+\w+' - '^[ \t]*(private|public|protected):$' + - '__has_cpp_attribute|__cplusplus >' - 'std::\w+' euphoria: - '^\s*namespace\s' diff --git a/samples/C++/NoDiscard.h b/samples/C++/NoDiscard.h new file mode 100644 index 0000000000..2571d996d6 --- /dev/null +++ b/samples/C++/NoDiscard.h @@ -0,0 +1,24 @@ +//===--- NoDiscard.h ------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#ifndef SWIFT_BASIC_NODISCARD_H +#define SWIFT_BASIC_NODISCARD_H + +#if __cplusplus > 201402l && __has_cpp_attribute(nodiscard) +#define SWIFT_NODISCARD [[nodiscard]] +#elif __has_cpp_attribute(clang::warn_unused_result) +#define SWIFT_NODISCARD [[clang::warn_unused_result]] +#else +#define SWIFT_NODISCARD +#endif + +#endif \ No newline at end of file diff --git a/test/test_blob.rb b/test/test_blob.rb index 6c0fee7a32..0aafbc17b8 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -260,7 +260,7 @@ def test_vendored def test_language allowed_failures = { - "#{samples_path}/C++/rpc.h" => ["C", "C++"], + "#{samples_path}/C/rpc.h" => ["C", "C++"], } Samples.each do |sample| blob = sample_blob_memory(sample[:path]) diff --git a/test/test_classifier.rb b/test/test_classifier.rb index e2ad62d3f5..20e36a8e85 100644 --- a/test/test_classifier.rb +++ b/test/test_classifier.rb @@ -46,7 +46,7 @@ def test_instance_classify_nil def test_classify_ambiguous_languages # Failures are reasonable in some cases, such as when a file is fully valid in more than one language. allowed_failures = { - "#{samples_path}/C++/rpc.h" => ["C", "C++"], + "#{samples_path}/C/rpc.h" => ["C", "C++"], } # Skip extensions with catch-all rule diff --git a/test/test_file_blob.rb b/test/test_file_blob.rb index 547035f8b3..360bd2f130 100644 --- a/test/test_file_blob.rb +++ b/test/test_file_blob.rb @@ -670,7 +670,7 @@ def test_documentation def test_language # Failures are reasonable in some cases, such as when a file is fully valid in more than one language. allowed_failures = { - "#{samples_path}/C++/rpc.h" => ["C", "C++"], + "#{samples_path}/C/rpc.h" => ["C", "C++"], } Samples.each do |sample| blob = sample_blob(sample[:path])